Update server.py
This commit is contained in:
parent
3d840515a3
commit
74e63f9e9c
1 changed files with 27 additions and 25 deletions
52
server.py
52
server.py
|
@ -82,32 +82,34 @@ def session(connection, client):
|
||||||
connection.sendall(bytes(f"PONG {e}\r\n","UTF-8"))
|
connection.sendall(bytes(f"PONG {e}\r\n","UTF-8"))
|
||||||
elif (ready and already_set) and finished:
|
elif (ready and already_set) and finished:
|
||||||
if command == "JOIN":
|
if command == "JOIN":
|
||||||
channel = text.split(" ")[1]
|
channels = text.split(" ")[1]
|
||||||
success = True
|
for channelt in channels.split(","):
|
||||||
if channel in channels_list:
|
channel = channelt.strip()
|
||||||
if pending in channels_list[channel]:
|
success = True
|
||||||
success=False
|
if channel in channels_list:
|
||||||
print(f"{pending} is already in {channel} , ignoring JOIN request.")
|
|
||||||
if success:
|
|
||||||
try:
|
|
||||||
if channel in channels_list:
|
|
||||||
channels_list[channel].append(pending)
|
|
||||||
else:
|
|
||||||
channels_list[channel] = [pending]
|
|
||||||
except:
|
|
||||||
connection.sendall(bytes(f":{server} NOTICE * :*** Could not join {channel}\r\n","UTF-8"))
|
|
||||||
print(channels_list)
|
|
||||||
for i in channels_list[channel]:
|
|
||||||
try:
|
|
||||||
nickname_list[i].sendall(bytes(f":{pending}!~{username}@{client[0]} JOIN {channel}\r\n","UTF-8"))
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
# Code re-used in the WHO command
|
|
||||||
if channel in channels_list:
|
|
||||||
if pending in channels_list[channel]:
|
if pending in channels_list[channel]:
|
||||||
users = " ".join(channels_list[channel])
|
success=False
|
||||||
connection.sendall(bytes(f":{server} 353 {pending} = {channel} :{users}\r\n","UTF-8"))
|
print(f"{pending} is already in {channel} , ignoring JOIN request.")
|
||||||
connection.sendall(bytes(f":{server} 366 {pending} {channel} :End of /NAMES list.\r\n","UTF-8"))
|
if success:
|
||||||
|
try:
|
||||||
|
if channel in channels_list:
|
||||||
|
channels_list[channel].append(pending)
|
||||||
|
else:
|
||||||
|
channels_list[channel] = [pending]
|
||||||
|
except:
|
||||||
|
connection.sendall(bytes(f":{server} NOTICE * :*** Could not join {channel}\r\n","UTF-8"))
|
||||||
|
print(channels_list)
|
||||||
|
for i in channels_list[channel]:
|
||||||
|
try:
|
||||||
|
nickname_list[i].sendall(bytes(f":{pending}!~{username}@{client[0]} JOIN {channel}\r\n","UTF-8"))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
# Code re-used in the WHO command
|
||||||
|
if channel in channels_list:
|
||||||
|
if pending in channels_list[channel]:
|
||||||
|
users = " ".join(channels_list[channel])
|
||||||
|
connection.sendall(bytes(f":{server} 353 {pending} = {channel} :{users}\r\n","UTF-8"))
|
||||||
|
connection.sendall(bytes(f":{server} 366 {pending} {channel} :End of /NAMES list.\r\n","UTF-8"))
|
||||||
elif command == "PART":
|
elif command == "PART":
|
||||||
channel = text.split(" ")[1]
|
channel = text.split(" ")[1]
|
||||||
for i in channels_list[channel]:
|
for i in channels_list[channel]:
|
||||||
|
|
Loading…
Reference in a new issue