Fixing a bug with regexp matching when the bot has a metachar name.
parent
ccd0343d13
commit
78ec273046
4
bot.py
4
bot.py
|
@ -94,8 +94,8 @@ class Phenny(irc.Bot):
|
||||||
|
|
||||||
def sub(pattern, self=self):
|
def sub(pattern, self=self):
|
||||||
# These replacements have significant order
|
# These replacements have significant order
|
||||||
pattern = pattern.replace('$nickname', self.nick)
|
pattern = pattern.replace('$nickname', re.escape(self.nick))
|
||||||
return pattern.replace('$nick', r'%s[,:] +' % self.nick)
|
return pattern.replace('$nick', r'%s[,:] +' % re.escape(self.nick))
|
||||||
|
|
||||||
for name, func in self.variables.iteritems():
|
for name, func in self.variables.iteritems():
|
||||||
# print name, func
|
# print name, func
|
||||||
|
|
|
@ -127,7 +127,8 @@ def wikipedia(term, language='en', last=False):
|
||||||
sentence = ' '.join(words) + ' [...]'
|
sentence = ' '.join(words) + ' [...]'
|
||||||
|
|
||||||
if (('using the Article Wizard if you wish' in sentence)
|
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:
|
if not last:
|
||||||
term = search(term)
|
term = search(term)
|
||||||
return wikipedia(term, language=language, last=True)
|
return wikipedia(term, language=language, last=True)
|
||||||
|
|
Loading…
Reference in New Issue