From da8ee2a758363cdb9e52b9b4ba1350af5fd2cbcc Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Fri, 12 Sep 2003 06:59:41 +0000 Subject: [PATCH] Fixed bug where the bot would respond with 'there is no such command' if it wasn't the canonical name. --- src/MiscCommands.py | 2 +- src/callbacks.py | 1 + test/test_MiscCommands.py | 8 +++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/MiscCommands.py b/src/MiscCommands.py index 80f11e3a5..5a8d42c0a 100755 --- a/src/MiscCommands.py +++ b/src/MiscCommands.py @@ -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']) diff --git a/src/callbacks.py b/src/callbacks.py index d376c221c..7b5303689 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -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) diff --git a/test/test_MiscCommands.py b/test/test_MiscCommands.py index 38fdeac17..4a2725d6a 100644 --- a/test/test_MiscCommands.py +++ b/test/test_MiscCommands.py @@ -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')