diff --git a/src/ircmsgs.py b/src/ircmsgs.py index ee5f5286a..df6a70872 100644 --- a/src/ircmsgs.py +++ b/src/ircmsgs.py @@ -210,9 +210,11 @@ class IrcMsg(object): def isAction(msg): """A predicate returning true if the PRIVMSG in question is an ACTION""" - return msg.command == 'PRIVMSG' and \ - msg.args[1].startswith('\x01ACTION') and \ - msg.args[1].endswith('\x01') + 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' + else: + return False _unactionre = re.compile(r'^\x01ACTION (.*)\x01$') def unAction(msg): diff --git a/test/test_ircmsgs.py b/test/test_ircmsgs.py index be5059894..36b639e1c 100644 --- a/test/test_ircmsgs.py +++ b/test/test_ircmsgs.py @@ -129,6 +129,10 @@ class FunctionsTestCase(unittest.TestCase): for msg in msgs: self.failUnless(ircmsgs.isAction(msg)) + def testIsActionFalseWhenNoSpaces(self): + msg = ircmsgs.IrcMsg('PRIVMSG #foo :\x01ACTIONfoobar\x01') + self.failIf(ircmsgs.isAction(msg)) + def testUnAction(self): s = 'foo bar baz' msg = ircmsgs.action('#foo', s)