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) ->
|
|
|
|
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
|
|
|
|
|
2016-04-14 21:27:05 +02:00
|
|
|
# ignore blacklisted users
|
|
|
|
if message.user.id in (robot.brain.get('blacklist') or [])
|
|
|
|
robot.logger.info 'ignored message from user ' + message.user.name
|
|
|
|
return
|
|
|
|
|
2015-05-08 19:34:08 +02:00
|
|
|
results = listeners()
|
2016-04-14 21:27:05 +02:00
|
|
|
|
|
|
|
# allow direct talk in user chat or campfire
|
|
|
|
unless message.done or (true in results)
|
2017-02-22 22:11:20 +01:00
|
|
|
if robot.adapterName is 'shell' or message.room.private
|
2015-05-08 19:34:08 +02:00
|
|
|
message.text = robot.name + ' ' + message.text
|
|
|
|
results.push listeners()...
|
2016-04-14 21:27:05 +02:00
|
|
|
|
|
|
|
if message not instanceof CatchAllMessage and (true not in results)
|
2015-05-08 19:34:08 +02:00
|
|
|
robot.receive new CatchAllMessage message
|
|
|
|
|
2015-05-09 12:57:05 +02:00
|
|
|
robot.receive = receive
|