catch empty lines and thelike

This commit is contained in:
Stefan Harmuth 2021-12-06 08:35:05 +01:00
parent 57ba56bf2b
commit f5d6f2deb0

7
irc.py
View File

@ -170,7 +170,12 @@ class Client:
self.__server.sendline("PONG " + line.split()[1]) self.__server.sendline("PONG " + line.split()[1])
continue continue
(msg_from, msg_type, msg_to, *msg) = line[1:].split() try:
(msg_from, msg_type, msg_to, *msg) = line[1:].split()
except ValueError:
print("[E] Invalid message received:", line)
continue
if len(msg) > 0 and msg[0].startswith(":"): if len(msg) > 0 and msg[0].startswith(":"):
msg[0] = msg[0][1:] msg[0] = msg[0][1:]
message = " ".join(msg) message = " ".join(msg)