vspiewak/hubot-twitter-mention

Avoid starting the poller repeatedly

Opened this issue · 0 comments

The robot.brain.event 'loaded' may be fired multiple times; it does not represent "brain functionality is initialised" but rather "data has been loaded from brain" (source). Tests show it is emitted when data is set to robot.brain and emitted when data is merged to robot.brain

Symptom is that hubot exhausts Twitter API keys making too many Twitter API calls!

It's OK to use this event to initialise the poller, but we should use robot.brain.once rather than robot.brain.on to avoid multiple timers calling doAutomaticSearch simultaneously.