Skip to content

Instantly share code, notes, and snippets.

@awfulcooking
Created April 29, 2023 22:05
Show Gist options
  • Save awfulcooking/7755a0b7b9bb34299b2b74355e08c79c to your computer and use it in GitHub Desktop.
Save awfulcooking/7755a0b7b9bb34299b2b74355e08c79c to your computer and use it in GitHub Desktop.
Example of overriding #<< to implement rate limiting (with iirc gem)
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