fix decoding

main
nebula 2024-12-15 15:42:14 -06:00
parent 98efc6a871
commit df68318c7f
1 changed files with 6 additions and 6 deletions

12
main.py
View File

@ -286,17 +286,17 @@ class IRCBot():
def ping_pong(self): def ping_pong(self):
while True: while True:
char = self.s.recv(1).decode("UTF-8") char = self.s.recv(1)
if not char: if not char:
exit(f"{self.nick}: no response from IRC server") exit(f"{self.nick}: no response from IRC server")
line = "" line = b""
while char: while char:
if char == "\n": if char == b"\n":
break break
elif char != "\r": elif char != b"\r":
line += char line += char
char = self.s.recv(1).decode("UTF-8") char = self.s.recv(1)
line = line.strip() line = line.decode("UTF-8").strip()
if line.startswith("PING"): if line.startswith("PING"):
pong = "PONG " + line[5:] pong = "PONG " + line[5:]
self.sendline(pong) self.sendline(pong)