From 78ec2730460e8271e3a9d96056799785e6866f83 Mon Sep 17 00:00:00 2001 From: "Sean B. Palmer" Date: Fri, 20 May 2011 19:11:55 +0100 Subject: [PATCH] Fixing a bug with regexp matching when the bot has a metachar name. --- bot.py | 4 ++-- modules/wikipedia.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) mode change 100755 => 100644 modules/wikipedia.py diff --git a/bot.py b/bot.py index e71aa96..3886a87 100755 --- a/bot.py +++ b/bot.py @@ -94,8 +94,8 @@ class Phenny(irc.Bot): def sub(pattern, self=self): # These replacements have significant order - pattern = pattern.replace('$nickname', self.nick) - return pattern.replace('$nick', r'%s[,:] +' % self.nick) + pattern = pattern.replace('$nickname', re.escape(self.nick)) + return pattern.replace('$nick', r'%s[,:] +' % re.escape(self.nick)) for name, func in self.variables.iteritems(): # print name, func diff --git a/modules/wikipedia.py b/modules/wikipedia.py old mode 100755 new mode 100644 index 4a4a11b..b476ba3 --- a/modules/wikipedia.py +++ b/modules/wikipedia.py @@ -127,7 +127,8 @@ def wikipedia(term, language='en', last=False): sentence = ' '.join(words) + ' [...]' if (('using the Article Wizard if you wish' in sentence) - or ('or add a request for it' in sentence)): + or ('or add a request for it' in sentence) + or ('in existing articles' in sentence)): if not last: term = search(term) return wikipedia(term, language=language, last=True)