Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
config, bot: Configurable message rate
Original change description by @larsks (from #908, slightly edited): This adds several knobs that control how fast the bot sends multiple messages to the same recipient: - bucket_burst_tokens -- this controls how many messages may be sent in "burst mode", i.e., without any inter-message delay. - bucket_refill_rate -- once exhausted, burst tokens are refilled at a rate of bucket_refill_rate tokens/second. - bucket_empty_wait -- how long to wait between sending messages when not in burst mode. This permits the bot to return a few lines of information quickly and not trigger flood protection. How it works: When sending to a new recipient, we initialize a token counter to bucket_burst_tokens. Every time we send a message, we decrement this by 1. If the token counter reaches 0, we engage the rate limiting behavior (which is identical to the existing code, except that the minimum wait of 0.7 seconds is now configurable). When sending a new message to an existing recipient, we check if the token counter is exhausted. If it is, we refill it based on the elapsed time since the last message and the value of bucket_refill_rate, and then proceed as described above. ---- Adapted to current Sopel code and rebased by these users, respectively: Co-authored-by: kwaaak <kwaaak@users.noreply.github.com> Co-authored-by: dgw <dgw@technobabbl.es>
- Loading branch information