Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rate Limiting Feature Discussion #32

Open
PBug90 opened this issue Mar 26, 2018 · 1 comment
Open

Rate Limiting Feature Discussion #32

PBug90 opened this issue Mar 26, 2018 · 1 comment

Comments

@PBug90
Copy link
Contributor

PBug90 commented Mar 26, 2018

As pointed out in the feature suggestion issue, seamless rate limitation is important for the usability of the bot. I think it's a good idea to dedicate an issue to this feature in order to discuss an approach for implemetnation.

The rate limitation threshold depends on the Bot's user status in the channel:

  • 20 per 30 seconds, if not mod / operator
  • 100 per 30 seconds if mod / operator
  • 50 per 30 seconds for known bots
  • 7500 per 30 seconds for known bots

Source

This requires to introduce a new data structure that fulfills the following tasks:

  • keep track of messages sent in a particular channel
  • if rate limit is reached, buffer messages in a FIFO queue and send them whenever a message slot becomes available again
  • keep track of the Bot's user level
  • keep track of a reference to the say-function so it can decide on its own when to send buffered messages

A useful data structure for implementation is a circular buffer.

In the future this data structure can also be used to save channel-specific information like current users.

@PBug90
Copy link
Contributor Author

PBug90 commented Mar 26, 2018

Standalone working sample implementation:
https://gist.github.com/anXieTyPB/66622eae5c0da2a37869bfbed055a5d2

npm install circular-buffer
run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants