asjon/scripts/meta.coffee

39 lines
907 B
CoffeeScript
Raw Normal View History

2015-05-08 19:34:08 +02:00
# 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)
2015-05-09 12:57:05 +02:00
if message.room == message.user
2015-05-08 19:34:08 +02:00
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
2015-05-09 12:57:05 +02:00
robot.receive = receive