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):
while True:
char = self.s.recv(1).decode("UTF-8")
char = self.s.recv(1)
if not char:
exit(f"{self.nick}: no response from IRC server")
line = ""
line = b""
while char:
if char == "\n":
if char == b"\n":
break
elif char != "\r":
elif char != b"\r":
line += char
char = self.s.recv(1).decode("UTF-8")
line = line.strip()
char = self.s.recv(1)
line = line.decode("UTF-8").strip()
if line.startswith("PING"):
pong = "PONG " + line[5:]
self.sendline(pong)