# 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 # ignore blacklisted users if message.user.id in (robot.brain.get('blacklist') or []) robot.logger.info 'ignored message from user ' + message.user.name return results = listeners() # 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 message.text = robot.name + ' ' + message.text results.push listeners()... if message not instanceof CatchAllMessage and (true not in results) robot.receive new CatchAllMessage message robot.receive = receive