-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Describe the bug
I encountered a bug with this library while playing around with hubot's IRC adapter hubot-irc, which uses this library. hubot-irc allows you to configure the flood protection functionality offered by this library. However, I found that no matter what I set the flood protection delay value to, there didn't seem to be any flood protection at all. I noticed this when trying to use hubot's help command, which sends multiple messages each time it's called. These messages were not rate-limited at all; they would all get sent to the channel almost immediately. I did verify with console.log messages that hubot-irc was passing the flood protection config correctly to node-irc.
node-irc version: f222abe
To Reproduce
I don't have a super simple test for this, but it is fairly easy to spin up a hubot instance with the IRC adapter and test it that way.
Steps to reproduce the behavior:
- Open up a terminal on a system that has node/npm installed, and enter the following (changing server and room info as needed):
npm install -g yo generator-hubot
mkdir myhubot
cd myhubot
yo hubot --adapter=irc
HUBOT_IRC_SERVER=irc.freenode.net \
HUBOT_IRC_ROOMS="#myhubot-irc" \
HUBOT_IRC_NICK="myhubot" \
HUBOT_IRC_UNFLOOD="1000" \
bin/hubot -a irc --name myhubot- Go to the channel that you configured hubot to join and type
myhubot: help - Observe that the messages all come in nearly at once rather than once per second.
Expected behavior
Since flood protection was configured above with a 1 second delay, you'd expect messages to come in once per second.
Screenshots
N/A
Desktop (please complete the following information):
- OS: node:15.1.0 docker container
- Browser: N/A
- Version: N/A
Smartphone (please complete the following information):
N/A
Additional context
I dug around in the flood protection code and I believe I've figured out the cause of the bug. I also have a fix for it located at davidscholberg#2. I can move that PR here if it's acceptable.