diff --git a/src/ircmsgs.py b/src/ircmsgs.py index 25233eaab..9b69f7704 100644 --- a/src/ircmsgs.py +++ b/src/ircmsgs.py @@ -221,6 +221,19 @@ def isAction(msg): else: 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$') def unAction(msg): """Returns the payload (i.e., non-ACTION text) of an ACTION msg.""" diff --git a/test/test_ircmsgs.py b/test/test_ircmsgs.py index 84a9b3caa..df4fb4d9f 100644 --- a/test/test_ircmsgs.py +++ b/test/test_ircmsgs.py @@ -239,5 +239,19 @@ class FunctionsTestCase(SupyTestCase): s = str(m) 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: