mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-06 09:34:05 +01:00
Fixed bug in isAction.
This commit is contained in:
parent
0cc2c2f49f
commit
966a09437c
@ -210,9 +210,11 @@ class IrcMsg(object):
|
|||||||
|
|
||||||
def isAction(msg):
|
def isAction(msg):
|
||||||
"""A predicate returning true if the PRIVMSG in question is an ACTION"""
|
"""A predicate returning true if the PRIVMSG in question is an ACTION"""
|
||||||
return msg.command == 'PRIVMSG' and \
|
if msg.command == 'PRIVMSG' and msg.args[1].endswith('\x01'):
|
||||||
msg.args[1].startswith('\x01ACTION') and \
|
L = msg.args[1].split(None, 1)
|
||||||
msg.args[1].endswith('\x01')
|
return len(L) == 2 and L[0] == '\x01ACTION'
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
_unactionre = re.compile(r'^\x01ACTION (.*)\x01$')
|
_unactionre = re.compile(r'^\x01ACTION (.*)\x01$')
|
||||||
def unAction(msg):
|
def unAction(msg):
|
||||||
|
@ -129,6 +129,10 @@ class FunctionsTestCase(unittest.TestCase):
|
|||||||
for msg in msgs:
|
for msg in msgs:
|
||||||
self.failUnless(ircmsgs.isAction(msg))
|
self.failUnless(ircmsgs.isAction(msg))
|
||||||
|
|
||||||
|
def testIsActionFalseWhenNoSpaces(self):
|
||||||
|
msg = ircmsgs.IrcMsg('PRIVMSG #foo :\x01ACTIONfoobar\x01')
|
||||||
|
self.failIf(ircmsgs.isAction(msg))
|
||||||
|
|
||||||
def testUnAction(self):
|
def testUnAction(self):
|
||||||
s = 'foo bar baz'
|
s = 'foo bar baz'
|
||||||
msg = ircmsgs.action('#foo', s)
|
msg = ircmsgs.action('#foo', s)
|
||||||
|
Loading…
Reference in New Issue
Block a user