mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-02 17:29:22 +01:00
Fixed jamessan's multiple-invalidCommand bug.
This commit is contained in:
parent
0d83dde909
commit
dff2862bb1
@ -451,7 +451,7 @@ class RichReplyMethods(object):
|
|||||||
return msg
|
return msg
|
||||||
|
|
||||||
def noReply(self):
|
def noReply(self):
|
||||||
self.msg.tag('repliedTo')
|
self.repliedTo = True
|
||||||
|
|
||||||
def _error(self, s, Raise=False, **kwargs):
|
def _error(self, s, Raise=False, **kwargs):
|
||||||
if Raise:
|
if Raise:
|
||||||
@ -579,6 +579,7 @@ class NestedCommandsIrcProxy(ReplyIrcProxy):
|
|||||||
self.irc = irc
|
self.irc = irc
|
||||||
self.msg = msg
|
self.msg = msg
|
||||||
self.nested = nested
|
self.nested = nested
|
||||||
|
self.repliedTo = False
|
||||||
if not self.nested and isinstance(irc, self.__class__):
|
if not self.nested and isinstance(irc, self.__class__):
|
||||||
# This means we were given an NestedCommandsIrcProxy instead of an
|
# This means we were given an NestedCommandsIrcProxy instead of an
|
||||||
# irclib.Irc, and so we're obviously nested. But nested wasn't
|
# irclib.Irc, and so we're obviously nested. But nested wasn't
|
||||||
@ -624,6 +625,7 @@ class NestedCommandsIrcProxy(ReplyIrcProxy):
|
|||||||
|
|
||||||
def evalArgs(self):
|
def evalArgs(self):
|
||||||
while self.counter < len(self.args):
|
while self.counter < len(self.args):
|
||||||
|
self.repliedTo = False
|
||||||
if isinstance(self.args[self.counter], basestring):
|
if isinstance(self.args[self.counter], basestring):
|
||||||
# If it's a string, just go to the next arg. There is no
|
# If it's a string, just go to the next arg. There is no
|
||||||
# evaluation to be done for strings. If, at some point,
|
# evaluation to be done for strings. If, at some point,
|
||||||
@ -660,9 +662,18 @@ class NestedCommandsIrcProxy(ReplyIrcProxy):
|
|||||||
threaded = threaded or cb.threaded
|
threaded = threaded or cb.threaded
|
||||||
def callInvalidCommands():
|
def callInvalidCommands():
|
||||||
for cb in cbs:
|
for cb in cbs:
|
||||||
self._callInvalidCommand(cb)
|
log.debug('Calling %s.invalidCommand.', cb.name())
|
||||||
if self.msg.repliedTo:
|
try:
|
||||||
|
cb.invalidCommand(self, self.msg, self.args)
|
||||||
|
except Error, e:
|
||||||
|
self.error(str(e))
|
||||||
|
except Exception, e:
|
||||||
|
log.exception('Uncaught exception in %s.invalidCommand.',
|
||||||
|
cb.name())
|
||||||
|
log.debug('Finished calling %s.invalidCommand.', cb.name())
|
||||||
|
if self.repliedTo:
|
||||||
log.debug('Done calling invalidCommands: %s.',cb.name())
|
log.debug('Done calling invalidCommands: %s.',cb.name())
|
||||||
|
self.repliedTo = False
|
||||||
return
|
return
|
||||||
if threaded:
|
if threaded:
|
||||||
name = 'Thread #%s (for invalidCommands)' % world.threadsSpawned
|
name = 'Thread #%s (for invalidCommands)' % world.threadsSpawned
|
||||||
@ -672,15 +683,6 @@ class NestedCommandsIrcProxy(ReplyIrcProxy):
|
|||||||
else:
|
else:
|
||||||
callInvalidCommands()
|
callInvalidCommands()
|
||||||
|
|
||||||
def _callInvalidCommand(self, cb):
|
|
||||||
try:
|
|
||||||
cb.invalidCommand(self, self.msg, self.args)
|
|
||||||
except Error, e:
|
|
||||||
return self.error(str(e))
|
|
||||||
except Exception, e:
|
|
||||||
log.exception('Uncaught exception in %s.invalidCommand.'%
|
|
||||||
cb.name())
|
|
||||||
|
|
||||||
def findCallbacksForArgs(self, args):
|
def findCallbacksForArgs(self, args):
|
||||||
"""Returns a two-tuple of (command, plugins) that has the command
|
"""Returns a two-tuple of (command, plugins) that has the command
|
||||||
(a list of strings) and the plugins for which it was a command."""
|
(a list of strings) and the plugins for which it was a command."""
|
||||||
@ -803,6 +805,7 @@ class NestedCommandsIrcProxy(ReplyIrcProxy):
|
|||||||
# False use or.
|
# False use or.
|
||||||
assert not isinstance(s, ircmsgs.IrcMsg), \
|
assert not isinstance(s, ircmsgs.IrcMsg), \
|
||||||
'Old code alert: there is no longer a "msg" argument to reply.'
|
'Old code alert: there is no longer a "msg" argument to reply.'
|
||||||
|
self.repliedTo = True
|
||||||
if msg is None:
|
if msg is None:
|
||||||
msg = self.msg
|
msg = self.msg
|
||||||
if prefixNick is not None:
|
if prefixNick is not None:
|
||||||
|
Loading…
Reference in New Issue
Block a user