kritzware / twitch-bot

🤖 Easily create chat bots for Twitch.tv
https://www.npmjs.com/package/twitch-bot
MIT License
149 stars 36 forks source link

Rate Limiting Feature Discussion #32

Open PBug90 opened 6 years ago

PBug90 commented 6 years ago

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:

Source

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

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 commented 6 years ago

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

npm install circular-buffer run.