]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/ircbot.rb
ircbot: do not use debug in sendmsg() because it breaks script. script plugin: handle...
[user/henk/code/ruby/rbot.git] / lib / rbot / ircbot.rb
index e503924817f66abf8406e37c224a8660f1b01461..619150fbf6d591552ede4c52af6ba4db28073b8f 100644 (file)
@@ -257,7 +257,7 @@ class Bot
       },
       :desc => "String used to replace newlines when send.newlines is set to join")
     BotConfig.register BotConfigIntegerValue.new('send.max_lines',
-      :default => 0,
+      :default => 5,
       :validate => Proc.new { |v| v >= 0 },
       :on_change => Proc.new { |bot, v|
         bot.set_default_send_options :max_lines => v
@@ -879,12 +879,13 @@ class Bot
           sub_lines = Array.new
           begin
             sub_lines << msg.slice!(0, left)
+            break if msg.empty?
             lastspace = sub_lines.last.rindex(opts[:split_at])
             if lastspace
               msg.replace sub_lines.last.slice!(lastspace, sub_lines.last.size) + msg
               msg.gsub!(/^#{opts[:split_at]}/, "") if opts[:purge_split]
             end
-          end while msg.size > 0
+          end until msg.empty?
           sub_lines
         when :truncate
           line.slice(0, left - truncate.size) << truncate
@@ -896,8 +897,8 @@ class Bot
 
     if opts[:max_lines] > 0 and all_lines.length > opts[:max_lines]
       lines = all_lines[0...opts[:max_lines]]
-      lines.last.slice!(0, left - truncate.size)
-      lines.last << truncate
+      new_last = lines.last.slice(0, left - truncate.size) << truncate
+      lines.last.replace(new_last)
     else
       lines = all_lines
     end