Update server.py

This commit is contained in:
Nova Cat 2024-12-09 14:08:31 -08:00
parent 08b8f93ce8
commit 6b901a42fb

View file

@ -33,10 +33,11 @@ def session(connection, client):
already_set = False # If the client gave the server a NICK packet already_set = False # If the client gave the server a NICK packet
ready = False # If the client gave the server a USER packet ready = False # If the client gave the server a USER packet
finished = False # If the server gave the client its information, indicating it's ready. finished = False # If the server gave the client its information, indicating it's ready.
username = "oreo" username = "oreo" # Username/ident specified by client
hostname = "" hostname = "" # Hostname, can be IP or domain
realname = "realname" realname = "realname" # Realname specified by client
safe_quit = False safe_quit = False # If the client safely exited, or if the server should manually drop the connection
cause = "Unknown" # The cause of the unexpected exit
try: try:
print("Connected to client IP: {}".format(client)) print("Connected to client IP: {}".format(client))
connection.sendall(bytes(f":{server} NOTICE * :*** Looking for your hostname...\r\n","UTF-8")) connection.sendall(bytes(f":{server} NOTICE * :*** Looking for your hostname...\r\n","UTF-8"))
@ -215,8 +216,9 @@ def session(connection, client):
except: except Exception as ex:
print(traceback.format_exc()) print(traceback.format_exc())
cause = str(ex)
break break
if not data: if not data:
@ -232,7 +234,7 @@ def session(connection, client):
if pending in users: if pending in users:
for j in users: for j in users:
if j != pending and not j in done: if j != pending and not j in done:
nickname_list[j].sendall(bytes(f":{pending}!~{username}@{hostname} QUIT :Error, possibly disconnected.\r\n","UTF-8")) nickname_list[j].sendall(bytes(f":{pending}!~{username}@{hostname} QUIT :Read error: {cause}\r\n","UTF-8"))
done.append(j) done.append(j)
# Remove the quitting user from the channel. # Remove the quitting user from the channel.
try: try: