From 4c7fe5695011b6d28da12082e14c54f8b15f2daa Mon Sep 17 00:00:00 2001 From: Juhani Haverinen Date: Tue, 5 Sep 2017 11:40:44 +0300 Subject: [PATCH] Implement PING/PONG --- ircbot.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ircbot.py b/ircbot.py index 9c4ed69..72b9cf4 100644 --- a/ircbot.py +++ b/ircbot.py @@ -31,8 +31,12 @@ class ServerThread(threading.Thread): self.logging_channel.send((logmessage_types.sent, line.decode(encoding = 'utf-8', errors = 'replace'))) def handle_line(self, line): - # TODO: implement line handling - self.logging_channel.send((logmessage_types.received, line.decode(encoding = 'utf-8', errors = 'replace'))) + command, _, arguments = line.partition(b' ') + if command.upper() == b'PING': + self.send_line_raw(b'PONG ' + arguments) + else: + # TODO: implement line handling + self.logging_channel.send((logmessage_types.received, line.decode(encoding = 'utf-8', errors = 'replace'))) def mainloop(self): # Register both the server socket and the control channel to or polling object @@ -43,6 +47,7 @@ class ServerThread(threading.Thread): # Keep buffer for input server_input_buffer = bytearray() + # TODO: Implement timeouting quitting = False while not quitting: # Wait until we can do something