mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 20:59:27 +01:00
Added isSplit, a function for checking whether a given QUIT message is a split quit.
This commit is contained in:
parent
50d390ece4
commit
13e1f7ccb9
@ -221,6 +221,19 @@ def isAction(msg):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def isSplit(msg):
|
||||||
|
if msg.command == 'QUIT':
|
||||||
|
# It's a quit.
|
||||||
|
quitmsg = msg.args[0]
|
||||||
|
if not quitmsg.startswith('"') and not quitmsg.endswith('"'):
|
||||||
|
# It's not a user-generated quitmsg.
|
||||||
|
servers = quitmsg.split()
|
||||||
|
if len(servers) == 2:
|
||||||
|
# We could check if domains match, or if the hostnames actually
|
||||||
|
# resolve, but we're going to put that off for now.
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
_unactionre = re.compile(r'^\x01ACTION\s+(.*)\x01$')
|
_unactionre = re.compile(r'^\x01ACTION\s+(.*)\x01$')
|
||||||
def unAction(msg):
|
def unAction(msg):
|
||||||
"""Returns the payload (i.e., non-ACTION text) of an ACTION msg."""
|
"""Returns the payload (i.e., non-ACTION text) of an ACTION msg."""
|
||||||
|
@ -239,5 +239,19 @@ class FunctionsTestCase(SupyTestCase):
|
|||||||
s = str(m)
|
s = str(m)
|
||||||
self.assertEqual(s, 'MODE #foo -b :foo!bar@baz\r\n')
|
self.assertEqual(s, 'MODE #foo -b :foo!bar@baz\r\n')
|
||||||
|
|
||||||
|
def testIsSplit(self):
|
||||||
|
m = ircmsgs.IrcMsg(prefix="caker!~caker@ns.theshore.net",
|
||||||
|
command="QUIT",
|
||||||
|
args=('jupiter.oftc.net quasar.oftc.net',))
|
||||||
|
self.failUnless(ircmsgs.isSplit(m))
|
||||||
|
m = ircmsgs.IrcMsg(prefix="bzbot!Brad2901@ACC87473.ipt.aol.com",
|
||||||
|
command="QUIT",
|
||||||
|
args=('Read error: 110 (Connection timed out)',))
|
||||||
|
self.failIf(ircmsgs.isSplit(m))
|
||||||
|
m = ircmsgs.IrcMsg(prefix="JibberJim!~none@8212cl.b0nwbeoe.co.uk",
|
||||||
|
command="QUIT",
|
||||||
|
args=('"Bye!"',))
|
||||||
|
self.failIf(ircmsgs.isSplit(m))
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
Loading…
Reference in New Issue
Block a user