Update server.py
This commit is contained in:
parent
0a0fc636fd
commit
cc657461b9
1 changed files with 8 additions and 0 deletions
|
@ -74,6 +74,7 @@ def pinger(nick, connection):
|
||||||
elif property_list[nick]["ping_pending"] and ((time.time() - property_list[nick]["last_ping"]) > 255):
|
elif property_list[nick]["ping_pending"] and ((time.time() - property_list[nick]["last_ping"]) > 255):
|
||||||
if nick in property_list:
|
if nick in property_list:
|
||||||
property_list[nick]["cause"] = "Ping timeout: 255 seconds"
|
property_list[nick]["cause"] = "Ping timeout: 255 seconds"
|
||||||
|
print("SHUTTING DOWN FOR " + nick)
|
||||||
connection.shutdown(socket.SHUT_WR)
|
connection.shutdown(socket.SHUT_WR)
|
||||||
connection.close()
|
connection.close()
|
||||||
break
|
break
|
||||||
|
@ -196,26 +197,33 @@ def session(connection, client):
|
||||||
elif pending2.lower() in lower_nicks or pending2 in reserved:
|
elif pending2.lower() in lower_nicks or pending2 in reserved:
|
||||||
connection.sendall(bytes(f":{server} 433 {pending} {pending2} :Nickname is already in use.\r\n","UTF-8"))
|
connection.sendall(bytes(f":{server} 433 {pending} {pending2} :Nickname is already in use.\r\n","UTF-8"))
|
||||||
else:
|
else:
|
||||||
|
print("Broadcasting nickname change...")
|
||||||
# Broadcast the nickname change
|
# Broadcast the nickname change
|
||||||
done = []
|
done = []
|
||||||
for i, users in channels_list.items():
|
for i, users in channels_list.items():
|
||||||
if pending in users:
|
if pending in users:
|
||||||
for j in users:
|
for j in users:
|
||||||
if j != pending and j != pending2 and not j in done:
|
if j != pending and j != pending2 and not j in done:
|
||||||
|
print("Broadcasting on " + i)
|
||||||
nickname_list[j].sendall(bytes(f":{pending}!~{username}@{hostname} {text}\r\n","UTF-8"))
|
nickname_list[j].sendall(bytes(f":{pending}!~{username}@{hostname} {text}\r\n","UTF-8"))
|
||||||
done.append(j)
|
done.append(j)
|
||||||
# Replace the nickname
|
# Replace the nickname
|
||||||
try:
|
try:
|
||||||
|
print("Changing on " + i)
|
||||||
channels_list[i].remove(pending)
|
channels_list[i].remove(pending)
|
||||||
channels_list[i].append(pending2)
|
channels_list[i].append(pending2)
|
||||||
except:
|
except:
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
|
print("Sending nickname change...")
|
||||||
conection.sendall(bytes(f":{pending}!~{username}@{hostname} NICK {pending2}\r\n","UTF-8"))
|
conection.sendall(bytes(f":{pending}!~{username}@{hostname} NICK {pending2}\r\n","UTF-8"))
|
||||||
|
print("Moving config...")
|
||||||
property_list[pending2] = property_list.pop(pending)
|
property_list[pending2] = property_list.pop(pending)
|
||||||
nickname_list[pending2] = nickname_list.pop(pending)
|
nickname_list[pending2] = nickname_list.pop(pending)
|
||||||
del lower_nicks[pending.lower()]
|
del lower_nicks[pending.lower()]
|
||||||
lower_nicks[pending2.lower()] = pending2
|
lower_nicks[pending2.lower()] = pending2
|
||||||
|
print("starting pinger...")
|
||||||
pending = pending2
|
pending = pending2
|
||||||
|
property_list[pending2]["ping_pending"] = False
|
||||||
threading.Thread(target=pinger, args=[pending, connection]).start()
|
threading.Thread(target=pinger, args=[pending, connection]).start()
|
||||||
print(f"User {pending} set nick")
|
print(f"User {pending} set nick")
|
||||||
elif command == "PART":
|
elif command == "PART":
|
||||||
|
|
Loading…
Reference in a new issue