room is now an object
This commit is contained in:
parent
4ecdfb58d7
commit
7c0f760a51
@ -11,7 +11,7 @@ before = (done) ->
|
|||||||
robot = new Robot null, "mock-adapter", no, 'asjon'
|
robot = new Robot null, "mock-adapter", no, 'asjon'
|
||||||
robot.adapter.on 'connected', ->
|
robot.adapter.on 'connected', ->
|
||||||
# Initialize mocked environment
|
# 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
|
adapter = robot.adapter
|
||||||
send = (s) -> robot.adapter.receive new TextMessage user, s
|
send = (s) -> robot.adapter.receive new TextMessage user, s
|
||||||
receive = (f) -> robot.adapter.on 'send', f
|
receive = (f) -> robot.adapter.on 'send', f
|
||||||
|
@ -22,13 +22,13 @@ module.exports = (robot) ->
|
|||||||
'ne sei certo?', 'direi che è meglio di no']
|
'ne sei certo?', 'direi che è meglio di no']
|
||||||
notFound = ['non so chi sia', 'sicuro? non lo trovo', 'boh, chi è?',
|
notFound = ['non so chi sia', 'sicuro? non lo trovo', 'boh, chi è?',
|
||||||
'mai sentito, hai scritto giusto?', 'boh, non lo trovo']
|
'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 ADMIN-NOT-DETECTED', 'BZBZ IS-NOT-AUTHORIZED',
|
||||||
'BZBZ ACCESS-DENIED']
|
'BZBZ ACCESS-DENIED']
|
||||||
|
|
||||||
isFromAdmin = (res) ->
|
isFromAdmin = (res) ->
|
||||||
res.robot.adapterName is 'shell' or
|
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
|
# find closest match with levenshtein metric
|
||||||
@ -63,7 +63,7 @@ module.exports = (robot) ->
|
|||||||
else
|
else
|
||||||
robot.logger.info "no known user matches #{name}"
|
robot.logger.info "no known user matches #{name}"
|
||||||
res.send res.random notFound
|
res.send res.random notFound
|
||||||
|
|
||||||
|
|
||||||
robot.respond /ascolta (.+)/i, (res) ->
|
robot.respond /ascolta (.+)/i, (res) ->
|
||||||
if not isFromAdmin res
|
if not isFromAdmin res
|
||||||
|
@ -34,7 +34,7 @@ module.exports = (robot) ->
|
|||||||
|
|
||||||
# allow direct talk in user chat or campfire
|
# allow direct talk in user chat or campfire
|
||||||
unless message.done or (true in results)
|
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
|
message.text = robot.name + ' ' + message.text
|
||||||
results.push listeners()...
|
results.push listeners()...
|
||||||
|
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
|
|
||||||
cp = require 'child_process'
|
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 ADMIN-NOT-DETECTED', 'BZBZ IS-NOT-AUTHORIZED',
|
||||||
'BZBZ ACCESS-DENIED']
|
'BZBZ ACCESS-DENIED']
|
||||||
|
|
||||||
isFromAdmin = (res) ->
|
isFromAdmin = (res) ->
|
||||||
res.robot.adapterName is 'shell' or
|
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) ->
|
runCmd = (cmd,res,cb) ->
|
||||||
@ -44,31 +44,31 @@ module.exports = (robot) ->
|
|||||||
runCmd 'npm test', dest
|
runCmd 'npm test', dest
|
||||||
|
|
||||||
if process.env.AUTO_INFORM_ON_START
|
if process.env.AUTO_INFORM_ON_START
|
||||||
r = room: process.env.AUTO_INFORM_ON_START
|
room = id: process.env.AUTO_INFORM_ON_START
|
||||||
robot.send r, 'asjon avviato e operativo!'
|
robot.messageRoom room, 'asjon avviato e operativo!'
|
||||||
|
|
||||||
robot.respond /aggiornati|scarica (?:gli )?aggiornamenti/i, (res) ->
|
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
|
runCmd 'git pull && npm install', res
|
||||||
|
|
||||||
robot.respond /(?:controlla gli )?aggiornamenti/i, (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
|
runCmd 'git fetch && git status', res
|
||||||
|
|
||||||
robot.respond /(?:installa (?:le )?)?dipendenze/i, (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
|
runCmd 'npm install', res
|
||||||
|
|
||||||
robot.respond /(?:esegui (?:i )?)?test/i, (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
|
runCmd 'npm test', res
|
||||||
|
|
||||||
robot.respond /secret-kill-code/i, (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
|
process.exit 0
|
||||||
|
|
||||||
robot.respond /(emergency|reverse) shell|phone home/i, (res) ->
|
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
|
rhost = process.env.REV_REMOTE_HOST
|
||||||
rport = process.env.REV_REMOTE_PORT || 22
|
rport = process.env.REV_REMOTE_PORT || 22
|
||||||
rtport = process.env.REV_REMOTE_TUNNEL_PORT || 2200
|
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 'non è impostato nessun host' unless rhost?
|
||||||
return res.send 'manca una chiave ssh' unless key?
|
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 "ok, apro una reverse shell #{rhost}:#{rtport} -> #{host}:#{port}"
|
||||||
res.send "connettiti entro 10s"
|
res.send "connettiti entro 10s"
|
||||||
|
Loading…
Reference in New Issue
Block a user