summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-08-19 20:30:14 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-08-19 20:30:14 +0200
commit5aa23b55a4547257580d047118ec4019a93499f7 (patch)
tree8bda940d00d7424621dc73c59ecdf86c9dcacf87 /lib/rbot
parent43b5cd9777cc13c6d3ac14a4015a0c8e8d9e5b50 (diff)
IRC socket: minor flood_send logic fixes
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/ircsocket.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/rbot/ircsocket.rb b/lib/rbot/ircsocket.rb
index 81a7fd16..6039b9a6 100644
--- a/lib/rbot/ircsocket.rb
+++ b/lib/rbot/ircsocket.rb
@@ -396,15 +396,13 @@ module Irc
loop do
begin
now = Time.now
- flood_delay = @flood_send - MAX_IRC_SEND_PENALTY - now
- delay = [flood_delay, 0].max
- if delay > 0
+ flood_delay = @flood_send - MAX_IRC_SEND_PENALTY - now
+ delay = [flood_delay, 0].max
+ if delay > 0
debug "sleep(#{delay}) # (f: #{flood_delay})"
sleep(delay)
end
msg = @sendq.shift
- now = Time.now
- @flood_send = now if @flood_send < now
debug "got #{msg.inspect} from queue, sending"
emergency_puts(msg, true)
rescue Exception => e
@@ -427,8 +425,10 @@ module Irc
# the latter is racy and can cause double message output in
# some circumstances
actual = @filter.out(message) + "\n"
+ now = Time.new
@sock.syswrite actual
- @last_send = Time.new
+ @last_send = now
+ @flood_send = now if @flood_send < now
@flood_send += message.irc_send_penalty if penalty
@lines_sent += 1
end