mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-22 18:39:31 +01:00
Added isCtcp.
This commit is contained in:
parent
2e5b900da4
commit
3f6d347e2b
@ -104,6 +104,12 @@ def nickEqual(nick1, nick2):
|
||||
_nickchars = r'_[]\`^{}|-'
|
||||
nickRe = re.compile(r'^[A-Za-z%s][0-9A-Za-z%s]*$' % (re.escape(_nickchars),
|
||||
re.escape(_nickchars)))
|
||||
def isCtcp(msg):
|
||||
"""Returns whether or not msg is a CTCP message."""
|
||||
return msg.command == 'PRIVMSG' and \
|
||||
msg.args[1].startswith('\x01') and \
|
||||
msg.args[1].endswith('\x01')
|
||||
|
||||
def isNick(s):
|
||||
"""Returns True if s is a valid IRC nick."""
|
||||
if re.match(nickRe, s):
|
||||
|
@ -55,7 +55,6 @@ class FunctionsTestCase(unittest.TestCase):
|
||||
'abr-ubr1.sbo-abr.ma.cable.rcn.com'
|
||||
self.failUnless(ircutils.hostmaskPatternEqual(s, s))
|
||||
|
||||
|
||||
def testIsUserHostmask(self):
|
||||
self.failUnless(ircutils.isUserHostmask(self.hostmask))
|
||||
self.failUnless(ircutils.isUserHostmask('a!b@c'))
|
||||
@ -85,6 +84,10 @@ class FunctionsTestCase(unittest.TestCase):
|
||||
self.failIf(ircutils.isChannel('foo'))
|
||||
self.failIf(ircutils.isChannel(''))
|
||||
|
||||
def testIsCtcp(self):
|
||||
self.failUnless(ircutils.isCtcp(ircmsgs.privmsg('foo',
|
||||
'\x01VERSION\x01')))
|
||||
|
||||
def testBold(self):
|
||||
s = ircutils.bold('foo')
|
||||
self.assertEqual(s[0], '\x02')
|
||||
|
Loading…
Reference in New Issue
Block a user