mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-02 15:44:06 +01:00
Fix bug #1093594, UnboundLocalError
This commit is contained in:
parent
a6a45f9dc3
commit
a4545d45a7
@ -553,6 +553,9 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
isAre = None
|
isAre = None
|
||||||
else:
|
else:
|
||||||
value = self.db.getAre(channel, key)
|
value = self.db.getAre(channel, key)
|
||||||
|
else:
|
||||||
|
self.log.debug('Returning early: Got a bad isAre value.')
|
||||||
|
return
|
||||||
except dbi.InvalidDBError, e:
|
except dbi.InvalidDBError, e:
|
||||||
self._error('Unable to access db: %s' % e)
|
self._error('Unable to access db: %s' % e)
|
||||||
return
|
return
|
||||||
@ -730,6 +733,11 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
r"^(.+?)\s+(?<!\\)(was|is|am|were|are)\s+(also\s+)?(.+?)[?!. ]*$"
|
r"^(.+?)\s+(?<!\\)(was|is|am|were|are)\s+(also\s+)?(.+?)[?!. ]*$"
|
||||||
(key, isAre, also, value) = match.groups()
|
(key, isAre, also, value) = match.groups()
|
||||||
key = key.replace('\\', '')
|
key = key.replace('\\', '')
|
||||||
|
isAre = isAre.lower()
|
||||||
|
if isAre in ('was', 'is', 'am'):
|
||||||
|
isAre = 'is'
|
||||||
|
else:
|
||||||
|
isAre = 'are'
|
||||||
if key.lower() in ('where', 'what', 'who', 'wtf'):
|
if key.lower() in ('where', 'what', 'who', 'wtf'):
|
||||||
# It's a question.
|
# It's a question.
|
||||||
if msg.addressed or \
|
if msg.addressed or \
|
||||||
@ -739,10 +747,9 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
if not msg.addressed and \
|
if not msg.addressed and \
|
||||||
not self.registryValue('unaddressed.snarfDefinitions'):
|
not self.registryValue('unaddressed.snarfDefinitions'):
|
||||||
return
|
return
|
||||||
isAre = isAre.lower()
|
|
||||||
if self.added:
|
if self.added:
|
||||||
return
|
return
|
||||||
if isAre in ('was', 'is', 'am'):
|
if isAre == 'is':
|
||||||
if self.db.hasIs(dynamic.channel, key):
|
if self.db.hasIs(dynamic.channel, key):
|
||||||
oldValue = self.db.getIs(dynamic.channel, key)
|
oldValue = self.db.getIs(dynamic.channel, key)
|
||||||
if oldValue.lower() == value.lower():
|
if oldValue.lower() == value.lower():
|
||||||
|
@ -52,6 +52,7 @@ class InfobotTestCase(ChannelPluginTestCase):
|
|||||||
m = self.getMsg('bar is at http://foo.com/')
|
m = self.getMsg('bar is at http://foo.com/')
|
||||||
self.failUnless(self._endRe.sub('', m.args[1]) in confirms)
|
self.failUnless(self._endRe.sub('', m.args[1]) in confirms)
|
||||||
self.assertRegexp('bar?', r'bar.*is.*http://foo.com/')
|
self.assertRegexp('bar?', r'bar.*is.*http://foo.com/')
|
||||||
|
self.assertRegexp('what was bar?', r'http://foo.com/')
|
||||||
finally:
|
finally:
|
||||||
ibot.unaddressed.snarfDefinitions.setValue(learn)
|
ibot.unaddressed.snarfDefinitions.setValue(learn)
|
||||||
ibot.unaddressed.answerQuestions.setValue(answer)
|
ibot.unaddressed.answerQuestions.setValue(answer)
|
||||||
@ -87,6 +88,7 @@ class InfobotTestCase(ChannelPluginTestCase):
|
|||||||
self.assertSnarfRegexp('bars?', 'bars.*are.*dirty')
|
self.assertSnarfRegexp('bars?', 'bars.*are.*dirty')
|
||||||
self.assertSnarfNoResponse('bars are not dirty', 2)
|
self.assertSnarfNoResponse('bars are not dirty', 2)
|
||||||
self.assertSnarfNotRegexp('bars?', 'not')
|
self.assertSnarfNotRegexp('bars?', 'not')
|
||||||
|
self.assertSnarfRegexp('what were bars?', 'dirty')
|
||||||
finally:
|
finally:
|
||||||
ibot.unaddressed.snarfDefinitions.setValue(learn)
|
ibot.unaddressed.snarfDefinitions.setValue(learn)
|
||||||
ibot.unaddressed.answerQuestions.setValue(answer)
|
ibot.unaddressed.answerQuestions.setValue(answer)
|
||||||
|
Loading…
Reference in New Issue
Block a user