简体   繁体   中英

Stop Hubot (with Flowdock) from responding to itself?

I'm using Hubot with the Hubot-Flowdock adapter.

I'm using robot.hear to respond to messages with a certain string in them (eg "chocolate").

I then call msg.send with a message, which also happens to contain the trigger string ("chocolate") in it.

This causes Hubot to hear itself, and then just loop endlessly, triggering over and over again.

I'm trying to find a way to get Hubot to not respond to itself.

From what I gather, the Hubot Campfire adapter seems to include a specific check to prevent Hubot from listening to itself:

https://github.com/github/hubot/blob/b96ea30654ef2dbf93f710c6e310c909fa1bdd65/src/adapters/campfire.coffee#L71

However, other adapters don't seem to have this.

Is there another way to write a Hubot script with robot.hear and msg.send such that it will not respond to itself?

I found the answer to this - Hubot is not meant to respond/hear itself.

It's the responsibility of each adapter to handle filtering these messages out.

Some adapter (eg hubot-hipchat) will actually set the hubot bot name to the name of the user you authenticate in Hubot as.

In the case of hubot-flowdock, it will check the hubot bot name against the Flowdock "Display name" of the user you authenticate as - so you just need to make sure those match up (either by changing the "Display name" on the Flowdock account page, or using the -n flag or HUBOT_NAME environment variable to set the bot name).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM