Fixed bug where the bot would respond with 'there is no such command' if it wasn't the canonical name.

This commit is contained in:
Jeremy Fincher 2003-09-12 06:59:41 +00:00
parent 407da29675
commit da8ee2a758
3 changed files with 9 additions and 2 deletions

View File

@ -68,6 +68,7 @@ class MiscCommands(callbacks.Privmsg):
notCommands = []
tokens = callbacks.tokenize(s)
for command in callbacks.getCommands(tokens):
command = callbacks.canonicalName(command)
if not callbacks.findCallbackForCommand(irc, command):
notCommands.append(repr(command))
if notCommands:
@ -308,7 +309,6 @@ class MiscCommands(callbacks.Privmsg):
message; --regexp requires a regular expression the message must match
--fancy determines whether or not to show the nick; the default is not
"""
(optlist, rest) = getopt.getopt(args, '', ['from=', 'in=', 'to=',
'with=', 'regexp=',
'fancy'])

View File

@ -579,6 +579,7 @@ class Privmsg(irclib.IrcCallback):
try:
args = tokenize(s)
for command in getCommands(args):
command = canonicalName(command)
if not findCallbackForCommand(irc, command):
return
self.Proxy(irc, msg, args)

View File

@ -36,7 +36,6 @@ class MiscCommandsTestCase(PluginTestCase, PluginDocumentation):
def testReplyWhenNotCommand(self):
conf.replyWhenNotCommand = True
self.prefix = 'somethingElse!user@host.domain.tld'
self.irc.nick = 'foobarlkajdf'
self.assertRegexp('foo bar baz', 'not.*command')
self.assertRegexp('foo | bar | baz', 'not.*commands')
self.assertRegexp('baz [foo] [bar]', 'not.*commands')
@ -47,6 +46,13 @@ class MiscCommandsTestCase(PluginTestCase, PluginDocumentation):
self.prefix = 'somethingElse!user@host.domain.tld'
self.assertNoResponse('@coffee++', 2)
conf.replyWhenNotCommand = False
def testNotReplyWhenNotCanonicalName(self):
conf.replyWhenNotCommand = True
self.prefix = 'somethingElse!user@host.domain.tld'
self.assertNotRegexp('STrLeN foobar', 'command')
self.assertResponse('StRlEn foobar', '6')
conf.repylWhenNotCommand = False
def testHelp(self):
self.assertNotError('help list')