Fix bug that caused commands like '@google google google google translate' to be valid. Closes GH-19.

This commit is contained in:
Valentin Lorentz 2013-08-10 15:22:47 +02:00
parent c23f25545f
commit 1ee8bc3480
2 changed files with 6 additions and 3 deletions

View File

@ -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):

View File

@ -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))