Fixed bug where he'd reply that a command didn't match when regexp methods matched.

This commit is contained in:
Jeremy Fincher 2003-09-11 05:31:01 +00:00
parent ec1e60bf00
commit ab88ee0d25
2 changed files with 14 additions and 2 deletions

View File

@ -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))

View File

@ -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'
@ -42,6 +42,12 @@ class MiscCommandsTestCase(PluginTestCase, PluginDocumentation):
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')
self.assertNotError('help help')