ping verbose

This commit is contained in:
Nova Cat 2024-12-09 16:46:15 -08:00
parent d9f6c605af
commit 60426cd155

View file

@ -36,6 +36,7 @@ print("Now listening on port 6667")
def pinger(nick, connection): def pinger(nick, connection):
while nick in property_list: while nick in property_list:
if (time.time() - property_list[nick]["last_ping"]) > 60 and not property_list[nick]["ping_pending"]: if (time.time() - property_list[nick]["last_ping"]) > 60 and not property_list[nick]["ping_pending"]:
print("Sent ping message to " + nick)
connection.sendall(bytes(f"PING {server}\r\n","UTF-8")) connection.sendall(bytes(f"PING {server}\r\n","UTF-8"))
ping_pending = True ping_pending = True
elif ping_pending and ((time.time() - property_list[nick]["last_ping"]) > 120): elif ping_pending and ((time.time() - property_list[nick]["last_ping"]) > 120):
@ -142,7 +143,7 @@ def session(connection, client):
elif command == "PONG": elif command == "PONG":
e = text.split(" ")[1] e = text.split(" ")[1]
if e == server: if e == server:
print("Client replied to PING.") print(pending + " replied to PING.")
property_list[pending]["last_ping"] = time.time() property_list[pending]["last_ping"] = time.time()
property_list[pending]["ping_pending"] = False property_list[pending]["ping_pending"] = False
elif command == "PART": elif command == "PART":