Skip to content

Instantly share code, notes, and snippets.

@radar
Created July 15, 2015 01:03
Show Gist options
  • Save radar/5f0acb03fba687910196 to your computer and use it in GitHub Desktop.
Save radar/5f0acb03fba687910196 to your computer and use it in GitHub Desktop.
def spam_protection(sender, channel, message)
key = "irc-#{sender[:nick]}"
count = @redis.get(key)
if count
count = @redis.incr(key)
if count > 5
privmsg("#{sender[:nick]} is spamming in #{channel}", "Radar")
end
else
@redis.set(key, 1)
@redis.expire(key, 30)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment