diff --git a/src/MiscCommands.py b/src/MiscCommands.py index 84bd23696..28136dfab 100755 --- a/src/MiscCommands.py +++ b/src/MiscCommands.py @@ -59,8 +59,14 @@ class MiscCommands(callbacks.Privmsg): if conf.replyWhenNotCommand and msg.nick != irc.nick: s = callbacks.addressed(irc.nick, msg) if s: - tokens = callbacks.tokenize(s) + for cb in irc.callbacks: + if isinstance(cb, callbacks.PrivmsgRegexp) or \ + isinstance(cb, callbacks.PrivmsgCommandAndRegexp): + for (r, _) in cb.res: + if r.search(msg.args[1]): + return notCommands = [] + tokens = callbacks.tokenize(s) for command in callbacks.getCommands(tokens): if not callbacks.findCallbackForCommand(irc, command): notCommands.append(repr(command)) diff --git a/test/test_MiscCommands.py b/test/test_MiscCommands.py index bb82ef0eb..38fdeac17 100644 --- a/test/test_MiscCommands.py +++ b/test/test_MiscCommands.py @@ -32,7 +32,7 @@ from test import * class MiscCommandsTestCase(PluginTestCase, PluginDocumentation): - plugins = ('MiscCommands', 'Utilities') + plugins = ('MiscCommands', 'Utilities', 'ChannelDB') def testReplyWhenNotCommand(self): conf.replyWhenNotCommand = True self.prefix = 'somethingElse!user@host.domain.tld' @@ -41,6 +41,12 @@ class MiscCommandsTestCase(PluginTestCase, PluginDocumentation): self.assertRegexp('foo | bar | baz', 'not.*commands') self.assertRegexp('baz [foo] [bar]', 'not.*commands') conf.replyWhenNotCommand = False + + def testNotReplyWhenRegexpsMatch(self): + conf.replyWhenNotCommand = True + self.prefix = 'somethingElse!user@host.domain.tld' + self.assertNoResponse('@coffee++', 2) + conf.replyWhenNotCommand = False def testHelp(self): self.assertNotError('help list')