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.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
|
||||
|
@ -28,7 +28,7 @@ module.exports = (robot) ->
|
||||
|
||||
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
|
||||
|
@ -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()...
|
||||
|
||||
|
@ -18,7 +18,7 @@ nope = ['BZBZ 400-BAD-REQUEST', 'BZBZ DOES-NOT-COMPUTE',
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user