Commit ec98073f authored by Kasalehlia's avatar Kasalehlia

irc: improve error handling

parent 88057810
......@@ -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()
......
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