fix decoding
parent
98efc6a871
commit
df68318c7f
12
main.py
12
main.py
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue