summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-04-05 14:55:12 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-04-05 14:55:12 +0000
commitc8f734a05ab2a77e11144c146395bc0ea108846b (patch)
treedd4646211fd875741d3d3637bc56748d0bfdb9b7 /lib/rbot
parent601a5f7f8b817f331c54165b20ed6482618b1c62 (diff)
Fix overconservative line splitting and bug in last line truncation
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/ircbot.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb
index e5039248..1b013c17 100644
--- a/lib/rbot/ircbot.rb
+++ b/lib/rbot/ircbot.rb
@@ -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,11 +897,12 @@ 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
+ debug lines.inspect
lines.each { |line|
sendq "#{fixed}#{line}", chan, ring