hubot
hubot copied to clipboard
how to stop from further parsing in a module or across all modules?
For both inside a script and across all scripts, how can I tell hubot/robot to stop parsing an incoming message? I'm looking to sometimes implement the behavior of "first match stops searching/parsing".
module.exports = (robot) ->
robot.hear /no further/i, (res) ->
res.send "Will not parse further in this module"
# return from this module-exported method???
robot.hear /all stop/i, (res) ->
res.send "No more parsing in any modules"
# command???
Found it: https://github.com/hubotio/hubot/blob/master/src/response.js#L132,L137
Just call res.finish(), correct?
According to this check: https://github.com/hubotio/hubot/blob/d0c13d2d8cd1ba30dc7f8765778988ca5a4d00c9/src/robot.js#L312-L320
You can have:
res.message.done = true
inside your listener callback.
But this only works if your callbacks are not async, I think this is a major drawback of this architecture, it would be better if hubot could handle async.
It's kinda of documented here https://github.com/hubotio/hubot/blob/d0c13d2d8cd1ba30dc7f8765778988ca5a4d00c9/docs/implementation.md#listeners