Do not repeat JOIN when already in the channel, +1 other
Automatically run WHO on JOIN
This commit is contained in:
parent
d09649a93d
commit
8c1aee5be6
1 changed files with 16 additions and 6 deletions
22
server.py
22
server.py
|
@ -77,6 +77,10 @@ def session(connection, client):
|
||||||
if text.split(" ")[0].upper() == "JOIN":
|
if text.split(" ")[0].upper() == "JOIN":
|
||||||
channel = text.split(" ")[1]
|
channel = text.split(" ")[1]
|
||||||
success = True
|
success = True
|
||||||
|
if channel in channels_list:
|
||||||
|
if pending in channels_list[channel]:
|
||||||
|
success=False
|
||||||
|
print(f"{pending} is already in {channel} , ignoring JOIN request.")
|
||||||
if success:
|
if success:
|
||||||
try:
|
try:
|
||||||
if channel in channels_list:
|
if channel in channels_list:
|
||||||
|
@ -85,12 +89,18 @@ def session(connection, client):
|
||||||
channels_list[channel] = [pending]
|
channels_list[channel] = [pending]
|
||||||
except:
|
except:
|
||||||
connection.sendall(bytes(f":{server} NOTICE * :*** Could not join {channel}\r\n","UTF-8"))
|
connection.sendall(bytes(f":{server} NOTICE * :*** Could not join {channel}\r\n","UTF-8"))
|
||||||
print(channels_list)
|
print(channels_list)
|
||||||
for i in channels_list[channel]:
|
for i in channels_list[channel]:
|
||||||
try:
|
try:
|
||||||
nickname_list[i].sendall(bytes(f":{pending}!~{username}@{client[0]} JOIN {channel}\r\n","UTF-8"))
|
nickname_list[i].sendall(bytes(f":{pending}!~{username}@{client[0]} JOIN {channel}\r\n","UTF-8"))
|
||||||
except:
|
except:
|
||||||
pass
|
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 text.split(" ")[0].upper() == "PART":
|
elif text.split(" ")[0].upper() == "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