mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-20 01:19:26 +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)
|
assert isinstance(command, list)
|
||||||
return self.getCommand(command) == command
|
return self.getCommand(command) == command
|
||||||
|
|
||||||
def getCommand(self, args):
|
def getCommand(self, args, stripOwnName=True):
|
||||||
assert args == map(canonicalName, args)
|
assert args == map(canonicalName, args)
|
||||||
first = args[0]
|
first = args[0]
|
||||||
for cb in self.cbs:
|
for cb in self.cbs:
|
||||||
if first == cb.canonicalName():
|
if first == cb.canonicalName():
|
||||||
return cb.getCommand(args)
|
return cb.getCommand(args)
|
||||||
if first == self.canonicalName() and len(args) > 1:
|
if first == self.canonicalName() and len(args) > 1 and \
|
||||||
ret = self.getCommand(args[1:])
|
stripOwnName:
|
||||||
|
ret = self.getCommand(args[1:], stripOwnName=False)
|
||||||
if ret:
|
if ret:
|
||||||
return [first] + ret
|
return [first] + ret
|
||||||
if self.isCommandMethod(first):
|
if self.isCommandMethod(first):
|
||||||
|
@ -433,6 +433,8 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
|||||||
self.assertResponse('secondcmd', 'bar')
|
self.assertResponse('secondcmd', 'bar')
|
||||||
self.assertResponse('first firstcmd', 'foo')
|
self.assertResponse('first firstcmd', 'foo')
|
||||||
self.assertResponse('second secondcmd', 'bar')
|
self.assertResponse('second secondcmd', 'bar')
|
||||||
|
self.assertRegexp('first first firstcmd',
|
||||||
|
'there is no command named "first" in it')
|
||||||
|
|
||||||
def testAmbiguousError(self):
|
def testAmbiguousError(self):
|
||||||
self.irc.addCallback(self.First(self.irc))
|
self.irc.addCallback(self.First(self.irc))
|
||||||
|
Loading…
Reference in New Issue
Block a user