Commit ec98073f authored by Kasalehlia's avatar Kasalehlia

irc: improve error handling

parent 88057810
...@@ -28,9 +28,9 @@ def run(emit, log_err): ...@@ -28,9 +28,9 @@ def run(emit, log_err):
try: try:
while 1: while 1:
line = fp.readline().decode() line = fp.readline().decode()
print(line)
if line[:4] == 'PING': if line[:4] == 'PING':
conn.write(line.replace(b'PING',b'PONG', 1)) ans = line.replace('PING','PONG', 1)
conn.write(ans.encode())
continue continue
source, command, args = line.split(' ', 2) source, command, args = line.split(' ', 2)
if command == 'PRIVMSG' and 'znc@znc.in' not in source: if command == 'PRIVMSG' and 'znc@znc.in' not in source:
...@@ -47,6 +47,8 @@ def run(emit, log_err): ...@@ -47,6 +47,8 @@ def run(emit, log_err):
if len(cache) > CACHE_LIMIT: if len(cache) > CACHE_LIMIT:
cache.pop(0) cache.pop(0)
emit(''.join(cache), outlet='inner') emit(''.join(cache), outlet='inner')
except Exception as e:
log_err(str(e))
finally: finally:
log_err('Connection cycled') log_err('Connection cycled')
fp.close() fp.close()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment