mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-27 13:12:45 +01:00
Fix bug that caused commands like '@google google google google translate' to be valid. Closes GH-19.
This commit is contained in:
parent
c23f25545f
commit
1ee8bc3480
@ -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):
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user