summaryrefslogtreecommitdiff
path: root/data/rbot/plugins/topic.rb
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-06-23 15:57:14 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-06-23 15:57:14 +0000
commita0638048c397a0d0b920cca50989b585a250f1ab (patch)
tree0ade1f5ff8ffaa1066b561591eebd51eb3ef3e6a /data/rbot/plugins/topic.rb
parent8002a9891da12b4da8de9437fb1b524f228e7258 (diff)
Apply patch proposed in ticket #99
Diffstat (limited to 'data/rbot/plugins/topic.rb')
-rwxr-xr-xdata/rbot/plugins/topic.rb16
1 files changed, 8 insertions, 8 deletions
diff --git a/data/rbot/plugins/topic.rb b/data/rbot/plugins/topic.rb
index c3e5bf24..e1c81808 100755
--- a/data/rbot/plugins/topic.rb
+++ b/data/rbot/plugins/topic.rb
@@ -45,7 +45,7 @@ class TopicPlugin < Plugin
cmd = param[:command]
txt = param[:text].join(" ")
case cmd
- when /a(dd|ppend)/
+ when /^a(dd|ppend)$/
topicappend(m, ch, txt)
when 'prepend'
topicprepend(m, ch, txt)
@@ -56,19 +56,19 @@ class TopicPlugin < Plugin
txt = $2
topicaddat(m, ch, num, txt)
end
- when /del(ete)?/
+ when /^del(ete)?$/
if txt =~ /\s*(-?\d+)\s*/
num=$1.to_i - 1
num += 1 if num < 0
topicdel(m, ch, num)
end
- when /set/
+ when 'set'
topicset(m, ch, txt)
- when /sep(arator)?/
+ when /^sep(arator)?$/
topicsep(m, ch, txt)
- when /learn/
+ when 'learn'
learntopic(m, ch)
- when /restore/
+ when 'restore'
restoretopic(m, ch)
else
m.reply 'unknown command'
@@ -107,7 +107,7 @@ class TopicPlugin < Plugin
def topicaddat(m, channel, num, txt)
sep = getsep(channel)
topic = @bot.channels[channel].topic.to_s
- topicarray = topic.split(/\s+#{sep}\s*/)
+ topicarray = topic.split(/\s+#{Regexp.escape(sep)}\s*/)
topicarray.insert(num, txt)
newtopic = topicarray.join(" #{sep} ")
@bot.topic channel, newtopic
@@ -124,7 +124,7 @@ class TopicPlugin < Plugin
def topicdel(m, channel, num)
sep = getsep(channel)
topic = @bot.channels[channel].topic.to_s
- topicarray = topic.split(/\s+#{sep}\s*/)
+ topicarray = topic.split(/\s+#{Regexp.escape(sep)}\s*/)
topicarray.delete_at(num)
newtopic = topicarray.join(" #{sep} ")
@bot.topic channel, newtopic