From ec98073fb30582bcbac63a3bcebeed40eaec1b5c Mon Sep 17 00:00:00 2001 From: Kasalehlia <kasalehlia@clonejo.de> Date: Wed, 3 Oct 2018 18:15:03 +0200 Subject: [PATCH] irc: improve error handling --- modules/irc.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/irc.py b/modules/irc.py index ec03705..21033e6 100644 --- a/modules/irc.py +++ b/modules/irc.py @@ -28,9 +28,9 @@ def run(emit, log_err): try: while 1: line = fp.readline().decode() - print(line) if line[:4] == 'PING': - conn.write(line.replace(b'PING',b'PONG', 1)) + ans = line.replace('PING','PONG', 1) + conn.write(ans.encode()) continue source, command, args = line.split(' ', 2) if command == 'PRIVMSG' and 'znc@znc.in' not in source: @@ -47,6 +47,8 @@ def run(emit, log_err): if len(cache) > CACHE_LIMIT: cache.pop(0) emit(''.join(cache), outlet='inner') + except Exception as e: + log_err(str(e)) finally: log_err('Connection cycled') fp.close() -- GitLab