From 1ee8bc3480f99e47e489491af941624842818f1e Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 10 Aug 2013 15:22:47 +0200 Subject: [PATCH] Fix bug that caused commands like '@google google google google translate' to be valid. Closes GH-19. --- src/callbacks.py | 7 ++++--- test/test_callbacks.py | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/callbacks.py b/src/callbacks.py index 5528079d0..f6e90f623 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -1190,14 +1190,15 @@ class Commands(BasePlugin): assert isinstance(command, list) return self.getCommand(command) == command - def getCommand(self, args): + def getCommand(self, args, stripOwnName=True): assert args == map(canonicalName, args) first = args[0] for cb in self.cbs: if first == cb.canonicalName(): return cb.getCommand(args) - if first == self.canonicalName() and len(args) > 1: - ret = self.getCommand(args[1:]) + if first == self.canonicalName() and len(args) > 1 and \ + stripOwnName: + ret = self.getCommand(args[1:], stripOwnName=False) if ret: return [first] + ret if self.isCommandMethod(first): diff --git a/test/test_callbacks.py b/test/test_callbacks.py index ab9c758ee..f8025173b 100644 --- a/test/test_callbacks.py +++ b/test/test_callbacks.py @@ -433,6 +433,8 @@ class PrivmsgTestCase(ChannelPluginTestCase): self.assertResponse('secondcmd', 'bar') self.assertResponse('first firstcmd', 'foo') self.assertResponse('second secondcmd', 'bar') + self.assertRegexp('first first firstcmd', + 'there is no command named "first" in it') def testAmbiguousError(self): self.irc.addCallback(self.First(self.irc))