Skip to content

Flood protection is not working #50

@davidscholberg

Description

@davidscholberg

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:

  1. 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
  1. Go to the channel that you configured hubot to join and type myhubot: help
  2. 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):

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions