diff --git a/plugins/Infobot.py b/plugins/Infobot.py index f82ad8a27..c89788a5b 100755 --- a/plugins/Infobot.py +++ b/plugins/Infobot.py @@ -212,7 +212,6 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp): assert self.msg is not None msg = self.msg isAre = None - key = plugins.standardSubstitute(irc, msg, key) if self.db.hasIs(key): isAre = 'is' value = self.db.getIs(key) @@ -246,7 +245,7 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp): _forceRe = re.compile(r'^no[,: -]+', re.I) def doPrivmsg(self, irc, msg): - if ircmsgs.isAction(msg): + if ircmsgs.isCtcp(msg): return maybeAddressed = callbacks.addressed(irc.nick, msg, whenAddressedByNick=True) @@ -316,7 +315,6 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp): def doUnknown(self, irc, msg, match): r"^(.+?)\?[?!. ]*$" key = match.group(1) - key = plugins.standardSubstitute(irc, msg, key) if self.addressed or self.registryValue('answerUnaddressedQuestions'): self.factoid(key) # Does the dunno'ing for us itself. # TODO: Add invalidCommand. @@ -335,8 +333,6 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp): not self.registryValue('snarfUnaddressedDefinitions'): return isAre = isAre.lower() - key = plugins.standardSubstitute(irc, msg, key) - value = plugins.standardSubstitute(irc, msg, value) if isAre in ('was', 'is', 'am'): if self.db.hasIs(key): if also: diff --git a/plugins/Relay.py b/plugins/Relay.py index df2f85aa6..67d2269d6 100644 --- a/plugins/Relay.py +++ b/plugins/Relay.py @@ -480,7 +480,7 @@ class Relay(callbacks.Privmsg): irc = self._getRealIrc(irc) if channel not in self.registryValue('channels'): return - if ircutils.isCtcp(msg) and \ + if ircmsgs.isCtcp(msg) and \ 'AWAY' not in text and 'ACTION' not in text: return network = self._getIrcName(irc) diff --git a/src/callbacks.py b/src/callbacks.py index 72381e81a..896b7b9be 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -481,7 +481,7 @@ class IrcObjectProxy(RichReplyMethods): self.finalEval() def _callInvalidCommands(self): - if ircutils.isCtcp(self.msg): + if ircmsgs.isCtcp(self.msg): log.debug('Skipping invalidCommand, msg is CTCP.') return log.debug('Calling invalidCommands.') diff --git a/src/ircmsgs.py b/src/ircmsgs.py index d9df9226c..c924c375a 100644 --- a/src/ircmsgs.py +++ b/src/ircmsgs.py @@ -211,11 +211,16 @@ class IrcMsg(object): ## pass +def isCtcp(msg): + """Returns whether or not msg is a CTCP message.""" + return msg.command == 'PRIVMSG' and \ + msg.args[1].startswith('\x01') and \ + msg.args[1].endswith('\x01') + def isAction(msg): """A predicate returning true if the PRIVMSG in question is an ACTION""" - if msg.command == 'PRIVMSG' and msg.args[1].endswith('\x01'): - L = msg.args[1].split(None, 1) - return len(L) == 2 and L[0] == '\x01ACTION' + if isCtcp(msg): + return len(msg.args[1].split(None, 1)) == 2 else: return False diff --git a/src/ircutils.py b/src/ircutils.py index 2b0ee120e..e6fc56967 100644 --- a/src/ircutils.py +++ b/src/ircutils.py @@ -127,12 +127,6 @@ def isChannel(s): return (s and s[0] in '#&+!' and len(s) <= 50 and \ '\x07' not in s and ',' not in s and ' ' not in s) -def isCtcp(msg): - """Returns whether or not msg is a CTCP message.""" - return msg.command == 'PRIVMSG' and \ - msg.args[1].startswith('\x01') and \ - msg.args[1].endswith('\x01') - _patternCache = {} def _hostmaskPatternEqual(pattern, hostmask): """Returns True if hostmask matches the hostmask pattern pattern.""" diff --git a/test/test_ircmsgs.py b/test/test_ircmsgs.py index 4488e6708..539674a5f 100644 --- a/test/test_ircmsgs.py +++ b/test/test_ircmsgs.py @@ -129,6 +129,10 @@ class FunctionsTestCase(SupyTestCase): for msg in msgs: self.failUnless(ircmsgs.isAction(msg)) + def testIsCtcp(self): + self.failUnless(ircutils.isCtcp(ircmsgs.privmsg('foo', + '\x01VERSION\x01'))) + def testIsActionFalseWhenNoSpaces(self): msg = ircmsgs.IrcMsg('PRIVMSG #foo :\x01ACTIONfoobar\x01') self.failIf(ircmsgs.isAction(msg)) diff --git a/test/test_ircutils.py b/test/test_ircutils.py index 3549e7793..fe3d904b9 100644 --- a/test/test_ircutils.py +++ b/test/test_ircutils.py @@ -84,10 +84,6 @@ class FunctionsTestCase(SupyTestCase): self.failIf(ircutils.isChannel('foo')) self.failIf(ircutils.isChannel('')) - def testIsCtcp(self): - self.failUnless(ircutils.isCtcp(ircmsgs.privmsg('foo', - '\x01VERSION\x01'))) - def testBold(self): s = ircutils.bold('foo') self.assertEqual(s[0], '\x02')