From a92733f2f61cbce1b867d6ec3d7c7d8e434f5013 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Mon, 5 Feb 2007 15:53:54 +0000 Subject: Fix max_lines handling in new sendmsg code --- lib/rbot/ircbot.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 5cd0ac4d..c744ca51 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -786,19 +786,21 @@ class IrcBot # Counter to check the number of lines sent by this command cmd_lines = 0 max_lines = opts[:max_lines] + maxed = false line = String.new lines.each { |msg| begin - if(left >= msg.length) - sendq "#{fixed}#{msg}", chan, ring - log_sent(type, where, msg) - break - end - if opts[:max_lines] and cmd_lines == max_lines - 1 + if max_lines and cmd_lines == max_lines - 1 debug "Max lines count reached for message #{original_message.inspect} while sending #{msg.inspect}, truncating" truncate = opts[:truncate_text] truncate = @default_send_options[:truncate_text] if truncate.length > left truncate = "" if truncate.length > left + maxed = true + end + if(left >= msg.length) and not maxed + sendq "#{fixed}#{msg}", chan, ring + log_sent(type, where, msg) + break end if truncate line.replace msg.slice(0, left-truncate.length) -- cgit v1.2.3