diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2006-10-28 11:19:46 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2006-10-28 11:19:46 +0000 |
commit | 9c33f608f0d150076f2acb869be1c390a0fade09 (patch) | |
tree | f059f0ca5d4160141005ec4299fe9bf0e64abdda /lib/rbot/rfc2812.rb | |
parent | cdd8cd43c4b26ee0d45aebaf3478e40df3dff37b (diff) |
Move irc_send_penalty method of string in ircsocket.rb, and rework flood control to be more reactive while still preventing excessive flood disconnections
Diffstat (limited to 'lib/rbot/rfc2812.rb')
-rw-r--r-- | lib/rbot/rfc2812.rb | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/lib/rbot/rfc2812.rb b/lib/rbot/rfc2812.rb index 9fa81cb5..26549539 100644 --- a/lib/rbot/rfc2812.rb +++ b/lib/rbot/rfc2812.rb @@ -1,67 +1,3 @@ -class ::String - # Calculate the penalty which will be assigned to this message - # by the IRCd - def irc_send_penalty - # According to eggrdop, the initial penalty is - penalty = 1 + self.length/100 - # on everything but UnderNET where it's - # penalty = 2 + self.length/120 - - cmd, pars = self.split($;,2) - debug "cmd: #{cmd}, pars: #{pars.inspect}" - case cmd.to_sym - when :KICK - chan, nick, msg = pars.split - chan = chan.split(',') - nick = nick.split(',') - penalty += nick.length - penalty *= chan.length - when :MODE - chan, modes, argument = pars.split - extra = 0 - if modes - extra = 1 - if argument - extra += modes.split(/\+|-/).length - else - extra += 3 * modes.split(/\+|-/).length - end - end - if argument - extra += 2 * argument.split.length - end - penalty += extra * chan.split.length - when :TOPIC - penalty += 1 - penalty += 2 unless pars.split.length < 2 - when :PRIVMSG, :NOTICE - dests = pars.split($;,2).first - penalty += dests.split(',').length - when :WHO - # I'm too lazy to implement this one correctly - penalty += 5 - when :AWAY, :JOIN, :VERSION, :TIME, :TRACE, :WHOIS, :DNS - penalty += 2 - when :INVITE, :NICK - penalty += 3 - when :ISON - penalty += 1 - else # Unknown messages - penalty += 1 - end - if penalty > 99 - debug "Wow, more than 99 secs of penalty!" - penalty = 99 - end - if penalty < 2 - debug "Wow, less than 2 secs of penalty!" - penalty = 2 - end - debug "penalty: #{penalty}" - return penalty - end -end - module Irc # RFC 2812 Internet Relay Chat: Client Protocol # |