kritzware / kritzware/twitch-bot
Rate Limiting Feature Discussion
- Dominant language
- JavaScript
- Stars
- 159
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
Description
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](https://dev.twitch.tv/docs/irc#irc-command-and-message-limits)
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](https://www.npmjs.com/package/circular-buffer).
In the future this data structure can also be used to save channel-specific information like current users.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the Twitch IRC command and message limits linked in the issue, then review the per-channel tracking, FIFO buffering, user-level handling, and say-function coordination described here. Done means the bot applies the stated limits and sends buffered messages when capacity returns.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend, networking
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100