Fixing a bug with regexp matching when the bot has a metachar name.

This commit is contained in:
Sean B. Palmer
2011-05-20 19:11:55 +01:00
parent ccd0343d13
commit 78ec273046
2 changed files with 4 additions and 3 deletions

4
bot.py
View File

@@ -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