hubot icon indicating copy to clipboard operation
hubot copied to clipboard

how to stop from further parsing in a module or across all modules?

Open sr105 opened this issue 7 years ago • 2 comments

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???

sr105 avatar Sep 12 '18 21:09 sr105

Found it: https://github.com/hubotio/hubot/blob/master/src/response.js#L132,L137

Just call res.finish(), correct?

sr105 avatar Sep 14 '18 20:09 sr105

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

JCMais avatar Nov 19 '18 12:11 JCMais