From 0cd0a44e7d6394d644637a59db48b3177f9e4a97 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Mon, 30 Aug 2004 06:02:57 +0000 Subject: [PATCH] I honestly cannot believe that this wasn't caught sooner. --- src/ircmsgs.py | 5 ++++- test/test_ircmsgs.py | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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')))