diff --git a/asjon-testing.coffee b/asjon-testing.coffee index 6eb895e..d26cdf6 100644 --- a/asjon-testing.coffee +++ b/asjon-testing.coffee @@ -11,7 +11,7 @@ before = (done) -> robot = new Robot null, "mock-adapter", no, 'asjon' robot.adapter.on 'connected', -> # Initialize mocked environment - user = robot.brain.userForId "1", { name: 'mocha', room: '#mocha' } + user = robot.brain.userForId "1", { name: 'mocha', room: name: 'mocha', id: '#mocha' } adapter = robot.adapter send = (s) -> robot.adapter.receive new TextMessage user, s receive = (f) -> robot.adapter.on 'send', f diff --git a/scripts/blacklist.coffee b/scripts/blacklist.coffee index e123ea6..5da5486 100644 --- a/scripts/blacklist.coffee +++ b/scripts/blacklist.coffee @@ -22,13 +22,13 @@ module.exports = (robot) -> 'ne sei certo?', 'direi che è meglio di no'] notFound = ['non so chi sia', 'sicuro? non lo trovo', 'boh, chi è?', 'mai sentito, hai scritto giusto?', 'boh, non lo trovo'] - noPermit = ['BZBZ 403-NOT-AUTHORIZED', 'BZBZ DOES-NOT-COMPUTE', + noPermit = ['BZBZ 403-NOT-AUTHORIZED', 'BZBZ DOES-NOT-COMPUTE', 'BZBZ ADMIN-NOT-DETECTED', 'BZBZ IS-NOT-AUTHORIZED', 'BZBZ ACCESS-DENIED'] isFromAdmin = (res) -> res.robot.adapterName is 'shell' or - res.message.room is process.env.ADMIN_ROOM + res.message.room.id is process.env.ADMIN_ROOM # find closest match with levenshtein metric @@ -63,7 +63,7 @@ module.exports = (robot) -> else robot.logger.info "no known user matches #{name}" res.send res.random notFound - + robot.respond /ascolta (.+)/i, (res) -> if not isFromAdmin res diff --git a/scripts/meta.coffee b/scripts/meta.coffee index 5fdca51..560dc44 100644 --- a/scripts/meta.coffee +++ b/scripts/meta.coffee @@ -34,7 +34,7 @@ module.exports = (robot) -> # allow direct talk in user chat or campfire unless message.done or (true in results) - if message.room == message.user.id or message.user.id is 1 + if robot.adapterName is 'shell' or message.room.private message.text = robot.name + ' ' + message.text results.push listeners()... diff --git a/scripts/shell.coffee b/scripts/shell.coffee index de5e059..a7a86f8 100644 --- a/scripts/shell.coffee +++ b/scripts/shell.coffee @@ -12,13 +12,13 @@ cp = require 'child_process' -nope = ['BZBZ 400-BAD-REQUEST', 'BZBZ DOES-NOT-COMPUTE', +nope = ['BZBZ 400-BAD-REQUEST', 'BZBZ DOES-NOT-COMPUTE', 'BZBZ ADMIN-NOT-DETECTED', 'BZBZ IS-NOT-AUTHORIZED', 'BZBZ ACCESS-DENIED'] isFromAdmin = (res) -> res.robot.adapterName is 'shell' or - res.message.room is process.env.ADMIN_ROOM + res.message.room.id is process.env.ADMIN_ROOM runCmd = (cmd,res,cb) -> @@ -44,31 +44,31 @@ module.exports = (robot) -> runCmd 'npm test', dest if process.env.AUTO_INFORM_ON_START - r = room: process.env.AUTO_INFORM_ON_START - robot.send r, 'asjon avviato e operativo!' + room = id: process.env.AUTO_INFORM_ON_START + robot.messageRoom room, 'asjon avviato e operativo!' robot.respond /aggiornati|scarica (?:gli )?aggiornamenti/i, (res) -> - return res.send res.random nope unless isFromAdmin(res) + return res.send res.random nope unless isFromAdmin res runCmd 'git pull && npm install', res robot.respond /(?:controlla gli )?aggiornamenti/i, (res) -> - return res.send res.random nope unless isFromAdmin(res) + return res.send res.random nope unless isFromAdmin res runCmd 'git fetch && git status', res robot.respond /(?:installa (?:le )?)?dipendenze/i, (res) -> - return res.send res.random nope unless isFromAdmin(res) + return res.send res.random nope unless isFromAdmin res runCmd 'npm install', res robot.respond /(?:esegui (?:i )?)?test/i, (res) -> - return res.send res.random nope unless isFromAdmin(res) + return res.send res.random nope unless isFromAdmin res runCmd 'npm test', res robot.respond /secret-kill-code/i, (res) -> - return res.send res.random nope unless isFromAdmin(res) + return res.send res.random nope unless isFromAdmin res process.exit 0 robot.respond /(emergency|reverse) shell|phone home/i, (res) -> - return res.send res.random nope unless isFromAdmin(res) + return res.send res.random nope unless isFromAdmin res rhost = process.env.REV_REMOTE_HOST rport = process.env.REV_REMOTE_PORT || 22 rtport = process.env.REV_REMOTE_TUNNEL_PORT || 2200 @@ -78,7 +78,7 @@ module.exports = (robot) -> return res.send 'non è impostato nessun host' unless rhost? return res.send 'manca una chiave ssh' unless key? - ssh = "ssh -R #{rtport}:#{host}:#{port} -i #{key} -p #{rport} #{rhost}" + ssh = "ssh -R #{rtport}:#{host}:#{port} -i #{key} -p #{rport} #{rhost}" res.send "ok, apro una reverse shell #{rhost}:#{rtport} -> #{host}:#{port}" res.send "connettiti entro 10s"