Talk without prefix to assa
This commit is contained in:
parent
e984d4da56
commit
7d3e4d1eea
38
scripts/meta.coffee
Normal file
38
scripts/meta.coffee
Normal file
@ -0,0 +1,38 @@
|
||||
# Description:
|
||||
# meta-asjon
|
||||
#
|
||||
# Dependencies:
|
||||
# None
|
||||
#
|
||||
# Configuration:
|
||||
# None
|
||||
#
|
||||
# Author:
|
||||
# Michele Guerini Rocco (rnhmjoj)
|
||||
|
||||
{ CatchAllMessage } = require 'hubot'
|
||||
|
||||
module.exports = (robot) ->
|
||||
|
||||
#direct talk in user chat
|
||||
receive = (message) ->
|
||||
listeners = ->
|
||||
res = []
|
||||
for listener in robot.listeners
|
||||
try
|
||||
res.push listener.call message
|
||||
break if message.done
|
||||
catch error
|
||||
robot.emit 'error', error, new (robot.Response robot, message, [])
|
||||
false
|
||||
res
|
||||
|
||||
results = listeners()
|
||||
unless message.done or (results.reduce (x, y) -> x or y)
|
||||
if message.room is 'Shell' or message.room.match /user#/
|
||||
message.text = robot.name + ' ' + message.text
|
||||
results.push listeners()...
|
||||
if message not instanceof CatchAllMessage and (results.indexOf true) is -1
|
||||
robot.receive new CatchAllMessage message
|
||||
|
||||
robot.receive = receive
|
Loading…
Reference in New Issue
Block a user