diff --git a/src/ircmsgs.py b/src/ircmsgs.py index 2e3323687..90c44826e 100644 --- a/src/ircmsgs.py +++ b/src/ircmsgs.py @@ -220,7 +220,10 @@ def isCtcp(msg): def isAction(msg): """A predicate returning true if the PRIVMSG in question is an ACTION""" if isCtcp(msg): - return len(msg.args[1].split(None, 1)) == 2 + s = msg.args[1] + payload = s[1:-1] # Chop off \x01. + command = payload.split(None, 1)[0] + return command == 'ACTION' else: return False diff --git a/test/test_ircmsgs.py b/test/test_ircmsgs.py index eddd24b90..d7fd60093 100644 --- a/test/test_ircmsgs.py +++ b/test/test_ircmsgs.py @@ -129,6 +129,12 @@ class FunctionsTestCase(SupyTestCase): for msg in msgs: self.failUnless(ircmsgs.isAction(msg)) + def testIsActionIsntStupid(self): + m = ircmsgs.privmsg('#x', '\x01NOTANACTION foo\x01') + self.failIf(ircmsgs.isAction(m)) + m = ircmsgs.privmsg('#x', '\x01ACTION foo bar\x01') + self.failUnless(ircmsgs.isAction(m)) + def testIsCtcp(self): self.failUnless(ircmsgs.isCtcp(ircmsgs.privmsg('foo', '\x01VERSION\x01')))