Add chantype
This commit is contained in:
parent
4ac6f594dd
commit
eafc3a1c8d
1 changed files with 11 additions and 10 deletions
21
server.py
21
server.py
|
@ -57,7 +57,7 @@ def session(connection, client):
|
||||||
if not already_set:
|
if not already_set:
|
||||||
nickname_list[pending] = connection
|
nickname_list[pending] = connection
|
||||||
already_set = True
|
already_set = True
|
||||||
elif text.split(" ")[0] == "USER":
|
elif text.split(" ")[0].upper() == "USER":
|
||||||
if not ready:
|
if not ready:
|
||||||
username = text.split(" ")[1]
|
username = text.split(" ")[1]
|
||||||
ready = True
|
ready = True
|
||||||
|
@ -65,12 +65,12 @@ def session(connection, client):
|
||||||
connection.sendall(bytes(f":{server} 001 {pending} :Welcome to the {displayname} Internet Relay Chat Network {pending}\r\n", "UTF-8"))
|
connection.sendall(bytes(f":{server} 001 {pending} :Welcome to the {displayname} Internet Relay Chat Network {pending}\r\n", "UTF-8"))
|
||||||
connection.sendall(bytes(f":{server} 002 {pending} :Your host is {server}[{ip}/6667], running version IRCat-v{__version__}\r\n", "UTF-8"))
|
connection.sendall(bytes(f":{server} 002 {pending} :Your host is {server}[{ip}/6667], running version IRCat-v{__version__}\r\n", "UTF-8"))
|
||||||
connection.sendall(bytes(f":{server} 004 {pending} {server} IRCat-{__version__} iow ovmsitnlbkq\r\n", "UTF-8"))
|
connection.sendall(bytes(f":{server} 004 {pending} {server} IRCat-{__version__} iow ovmsitnlbkq\r\n", "UTF-8"))
|
||||||
connection.sendall(bytes(f":{server} 005 {pending} CHANMODES=bq NETWORK={displayname} :are supported by this server\r\n", "UTF-8"))
|
connection.sendall(bytes(f":{server} 005 {pending} CHANMODES=bq NETWORK={displayname} CHANTYPES=# :are supported by this server\r\n", "UTF-8"))
|
||||||
|
|
||||||
connection.sendall(bytes(f":{pending} MODE {pending} +iw\r\n","UTF-8"))
|
connection.sendall(bytes(f":{pending} MODE {pending} +iw\r\n","UTF-8"))
|
||||||
finished = True
|
finished = True
|
||||||
elif (ready and already_set) and finished:
|
elif (ready and already_set) and finished:
|
||||||
if text.split(" ")[0] == "JOIN":
|
if text.split(" ")[0].upper() == "JOIN":
|
||||||
channel = text.split(" ")[1]
|
channel = text.split(" ")[1]
|
||||||
success = True
|
success = True
|
||||||
if success:
|
if success:
|
||||||
|
@ -87,7 +87,7 @@ def session(connection, client):
|
||||||
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
|
||||||
if text.split(" ")[0] == "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]:
|
||||||
try:
|
try:
|
||||||
|
@ -98,14 +98,14 @@ def session(connection, client):
|
||||||
channels_list[channel].remove(pending)
|
channels_list[channel].remove(pending)
|
||||||
except:
|
except:
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
if text.split(" ")[0] == "WHO":
|
elif text.split(" ")[0].upper() == "WHO":
|
||||||
channel = text.split(" ")[1]
|
channel = text.split(" ")[1]
|
||||||
if channel in channels_list:
|
if channel in channels_list:
|
||||||
if pending in channels_list[channel]:
|
if pending in channels_list[channel]:
|
||||||
users = " ".join(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} 353 {pending} = {channel} :{users}\r\n","UTF-8"))
|
||||||
connection.sendall(bytes(f":{server} 366 {pending} {channel} :End of /NAMES list.\r\n","UTF-8"))
|
connection.sendall(bytes(f":{server} 366 {pending} {channel} :End of /NAMES list.\r\n","UTF-8"))
|
||||||
if text.split(" ")[0] == "PRIVMSG":
|
elif text.split(" ")[0].upper() == "PRIVMSG":
|
||||||
target = text.split(" ")[1]
|
target = text.split(" ")[1]
|
||||||
if target in channels_list:
|
if target in channels_list:
|
||||||
if pending in channels_list[target]:
|
if pending in channels_list[target]:
|
||||||
|
@ -120,7 +120,7 @@ def session(connection, client):
|
||||||
else:
|
else:
|
||||||
nickname_list[target].sendall(bytes(f":{server} 401 {pending} {target} :No such nick/channel\r\n","UTF-8"))
|
nickname_list[target].sendall(bytes(f":{server} 401 {pending} {target} :No such nick/channel\r\n","UTF-8"))
|
||||||
nickname_list[i].sendall(bytes(f":{server} 366 {pending} {channel} :End of /NAMES list.\r\n","UTF-8"))
|
nickname_list[i].sendall(bytes(f":{server} 366 {pending} {channel} :End of /NAMES list.\r\n","UTF-8"))
|
||||||
if text.split(" ")[0] == "QUIT":
|
elif text.split(" ")[0].upper() == "QUIT":
|
||||||
# Parse the quit message.
|
# Parse the quit message.
|
||||||
done = []
|
done = []
|
||||||
msg = text.split(" ")[1:]
|
msg = text.split(" ")[1:]
|
||||||
|
@ -130,7 +130,10 @@ def session(connection, client):
|
||||||
else:
|
else:
|
||||||
msg = "Client Quit"
|
msg = "Client Quit"
|
||||||
text = f"QUIT :{msg}"
|
text = f"QUIT :{msg}"
|
||||||
# Broadcast all users in the joined channels that the person left.
|
# Confirm QUIT and close the socket.
|
||||||
|
connection.sendall(bytes(f":{pending}!~{username}@{client[0]} {text}\r\nERROR :Closing Link: {client[0]} ({msg})\r\n","UTF-8"))
|
||||||
|
connection.close()
|
||||||
|
# Broadcast all users in the joined channels that the person quit.
|
||||||
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:
|
||||||
|
@ -142,8 +145,6 @@ def session(connection, client):
|
||||||
channels_list[i].remove(pending)
|
channels_list[i].remove(pending)
|
||||||
except:
|
except:
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
# Finally, confirm that the client quitted by mirroring the QUIT message.
|
|
||||||
connection.sendall(bytes(f":{pending}!~{username}@{client[0]} {text}\r\nERROR :Closing Link: {client[0]} ({msg})\r\n","UTF-8"))
|
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
|
|
Loading…
Reference in a new issue