From 5aa23b55a4547257580d047118ec4019a93499f7 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Tue, 19 Aug 2008 20:30:14 +0200 Subject: IRC socket: minor flood_send logic fixes --- lib/rbot/ircsocket.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib') 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 -- cgit v1.2.3