Created
April 29, 2023 22:05
-
-
Save awfulcooking/7755a0b7b9bb34299b2b74355e08c79c to your computer and use it in GitHub Desktop.
Example of overriding #<< to implement rate limiting (with iirc gem)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Limiter | |
def <<(line) | |
if parse(line).verb == :privmsg | |
limit_outgoing_msgs! | |
end | |
super | |
end | |
def limit_outgoing_msgs! | |
sleep 0.25 # real slowdown logic here | |
end | |
end | |
MyBot.include Limiter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment