From 32f53f6a17396a8828c30c58ce8545c93c04ff2c Mon Sep 17 00:00:00 2001 From: Tom Gilbert Date: Sun, 21 Aug 2005 12:31:41 +0000 Subject: Sun Aug 21 13:29:55 BST 2005 Tom Gilbert * fix for bug in quakenet plugin (trac #14) * multiple fixes for unescaped bot nick in regexp's (trac #13) --- lib/rbot/ircbot.rb | 13 ++++--------- lib/rbot/message.rb | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'lib/rbot') diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 29d4711d..68c2bd47 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -203,7 +203,7 @@ class IrcBot sourceurl = data[:sourceaddress] message = data[:message] m = QuitMessage.new(self, data[:source], data[:sourcenick], data[:message]) - if(data[:sourcenick] =~ /#{@nick}/i) + if(data[:sourcenick] =~ /#{Regexp.escape(@nick)}/i) else @channels.each {|k,v| if(v.users.has_key?(sourcenick)) @@ -255,7 +255,7 @@ class IrcBot onkick(m) } @client[:invite] = proc {|data| - if(data[:target] =~ /^#{@nick}$/i) + if(data[:target] =~ /^#{Regexp.escape(@nick)}$/i) join data[:channel] if (@auth.allow?("join", data[:source], data[:sourcenick])) end } @@ -500,11 +500,6 @@ class IrcBot end # attempt to change bot's nick to +name+ - # FIXME - # if rbot is already taken, this happens: - # rbot_, nick rbot - # --- rbot_ is now known as rbot__ - # he should of course just keep his existing nick and report the error :P def nickchg(name) sendq "NICK #{name}" end @@ -707,9 +702,9 @@ class IrcBot else # stuff to handle when not addressed case m.message - when (/^\s*(hello|howdy|hola|salut|bonjour|sup|niihau|hey|hi|yo(\W|$))[\s,-.]+#{@nick}$/i) + when (/^\s*(hello|howdy|hola|salut|bonjour|sup|niihau|hey|hi|yo(\W|$))[\s,-.]+#{Regexp.escape(@nick)}$/i) say m.replyto, @lang.get("hello_X") % m.sourcenick - when (/^#{@nick}!*$/) + when (/^#{Regexp.escape(@nick)}!*$/) say m.replyto, @lang.get("hello_X") % m.sourcenick else @keywords.privmsg(m) diff --git a/lib/rbot/message.rb b/lib/rbot/message.rb index ba5dcb43..eabb569a 100644 --- a/lib/rbot/message.rb +++ b/lib/rbot/message.rb @@ -141,7 +141,7 @@ module Irc # even if they used above prefixes, we allow for silly people who # combine all possible types, e.g. "|rbot: hello", or # "/msg rbot rbot: hello", etc - if @message.gsub!(/^\s*#{bot.nick}\s*([:;,>]|\s)\s*/, "") + if @message.gsub!(/^\s*#{Regexp.escape(bot.nick)}\s*([:;,>]|\s)\s*/, "") @address = true end -- cgit v1.2.3