Slight bugfix in isCtcp.

This commit is contained in:
Jeremy Fincher 2004-12-10 08:48:24 +00:00
parent 93e9fa3180
commit 1932ed4d02
2 changed files with 3 additions and 1 deletions

View File

@ -213,7 +213,8 @@ def isCtcp(msg):
"""Returns whether or not msg is a CTCP message."""
return msg.command in ('PRIVMSG', 'NOTICE') and \
msg.args[1].startswith('\x01') and \
msg.args[1].endswith('\x01')
msg.args[1].endswith('\x01') and \
len(msg.args[1]) >= 2
def isAction(msg):
"""A predicate returning true if the PRIVMSG in question is an ACTION"""

View File

@ -147,6 +147,7 @@ class FunctionsTestCase(SupyTestCase):
def testIsCtcp(self):
self.failUnless(ircmsgs.isCtcp(ircmsgs.privmsg('foo',
'\x01VERSION\x01')))
self.failIf(ircmsgs.isCtcp(ircmsgs.privmsg('foo', '\x01')))
def testIsActionFalseWhenNoSpaces(self):
msg = ircmsgs.IrcMsg('PRIVMSG #foo :\x01ACTIONfoobar\x01')