I honestly cannot believe that this wasn't caught sooner.

This commit is contained in:
Jeremy Fincher 2004-08-30 06:02:57 +00:00
parent 3aedb305f9
commit 0cd0a44e7d
2 changed files with 10 additions and 1 deletions

View File

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

View File

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