mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-07 01:54:08 +01:00
Fixed bug #858008, and a fix for another bug that invalidCommands that raise an exception stop the whole process; now it'll continue to later plugins.
This commit is contained in:
parent
627dd87baf
commit
8f777db9f9
@ -327,7 +327,13 @@ class IrcObjectProxy:
|
|||||||
if self.finished:
|
if self.finished:
|
||||||
break
|
break
|
||||||
if hasattr(cb, 'invalidCommand'):
|
if hasattr(cb, 'invalidCommand'):
|
||||||
cb.invalidCommand(self, self.msg, self.args)
|
try:
|
||||||
|
cb.invalidCommand(self, self.msg, self.args)
|
||||||
|
except Exception, e:
|
||||||
|
cb.log.exception('Uncaught exception in invalidCommand:')
|
||||||
|
log.warning('Uncaught exception in %s.invalidCommand, '
|
||||||
|
'continuing to call other invalidCommands.' %
|
||||||
|
cb.name())
|
||||||
|
|
||||||
def finalEval(self):
|
def finalEval(self):
|
||||||
assert not self.finalEvaled, 'finalEval called twice.'
|
assert not self.finalEvaled, 'finalEval called twice.'
|
||||||
@ -433,6 +439,7 @@ class IrcObjectProxy:
|
|||||||
if len(s) < allowedLength:
|
if len(s) < allowedLength:
|
||||||
self.irc.queueMsg(reply(msg, s, self.prefixName,
|
self.irc.queueMsg(reply(msg, s, self.prefixName,
|
||||||
self.private,self.notice,self.to))
|
self.private,self.notice,self.to))
|
||||||
|
self.finished = True
|
||||||
return
|
return
|
||||||
msgs = textwrap.wrap(s, allowedLength-30) # -30 is for "nick:"
|
msgs = textwrap.wrap(s, allowedLength-30) # -30 is for "nick:"
|
||||||
msgs.reverse()
|
msgs.reverse()
|
||||||
|
@ -323,6 +323,35 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
|||||||
def testNoEscapingAttributeErrorFromTokenizeWithFirstElementList(self):
|
def testNoEscapingAttributeErrorFromTokenizeWithFirstElementList(self):
|
||||||
self.assertError('[plugin list] list')
|
self.assertError('[plugin list] list')
|
||||||
|
|
||||||
|
class InvalidCommand(callbacks.Privmsg):
|
||||||
|
def invalidCommand(self, irc, msg, tokens):
|
||||||
|
irc.reply(msg, 'foo')
|
||||||
|
|
||||||
|
def testInvalidCommandOneReplyOnly(self):
|
||||||
|
try:
|
||||||
|
original = conf.replyWhenNotCommand
|
||||||
|
conf.replyWhenNotCommand = True
|
||||||
|
self.assertRegexp('asdfjkl', 'not a valid command')
|
||||||
|
self.irc.addCallback(self.InvalidCommand())
|
||||||
|
self.assertResponse('asdfjkl', 'foo')
|
||||||
|
self.assertNoResponse(' ', 2)
|
||||||
|
finally:
|
||||||
|
conf.replyWhenNotCommand = original
|
||||||
|
|
||||||
|
class BadInvalidCommand(callbacks.Privmsg):
|
||||||
|
def invalidCommand(self, irc, msg, tokens):
|
||||||
|
s = 'This shouldn\'t keep Misc.invalidCommand from being called'
|
||||||
|
raise Exception, s
|
||||||
|
|
||||||
|
def testBadInvalidCommandDoesNotKillAll(self):
|
||||||
|
try:
|
||||||
|
original = conf.replyWhenNotCommand
|
||||||
|
conf.replyWhenNotCommand = True
|
||||||
|
self.irc.addCallback(self.BadInvalidCommand())
|
||||||
|
self.assertRegexp('asdfjkl', 'not a valid command')
|
||||||
|
finally:
|
||||||
|
conf.replyWhenNotCommand = original
|
||||||
|
|
||||||
|
|
||||||
class PrivmsgCommandAndRegexpTestCase(PluginTestCase):
|
class PrivmsgCommandAndRegexpTestCase(PluginTestCase):
|
||||||
plugins = ('Utilities',) # Gotta put something.
|
plugins = ('Utilities',) # Gotta put something.
|
||||||
|
Loading…
Reference in New Issue
Block a user