fix quit
This commit is contained in:
parent
674e29c7a0
commit
ca1c13c543
1 changed files with 10 additions and 5 deletions
15
server.py
15
server.py
|
@ -2,8 +2,10 @@
|
||||||
__version__ = 0
|
__version__ = 0
|
||||||
print(f"INTERNET RELAY CAT v{__version__}")
|
print(f"INTERNET RELAY CAT v{__version__}")
|
||||||
print("Welcome! /ᐠ ˵> ⩊ <˵マ")
|
print("Welcome! /ᐠ ˵> ⩊ <˵マ")
|
||||||
import socket, time, threading, traceback
|
import socket, time, threading, traceback, sys, os
|
||||||
from requests import get
|
from requests import get
|
||||||
|
if not len(sys.argv) == 2:
|
||||||
|
print("IRCat requires the following arguments: config.yml")
|
||||||
ip = get('https://api.ipify.org').content.decode('utf8')
|
ip = get('https://api.ipify.org').content.decode('utf8')
|
||||||
tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
tcp_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
tcp_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
|
@ -110,14 +112,17 @@ def session(connection, client):
|
||||||
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.
|
# Broadcast all users in the joined channels that the person left.
|
||||||
for i in channels_list:
|
for i, users in channels_list.items():
|
||||||
if pending in i:
|
if pending in users:
|
||||||
for j in channels_list[i]:
|
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}!~oreo@{client[0]} {text}\r\n","UTF-8"))
|
nickname_list[j].sendall(bytes(f":{pending}!~oreo@{client[0]} {text}\r\n","UTF-8"))
|
||||||
done.append(j)
|
done.append(j)
|
||||||
# Remove the quitting user from the channel.
|
# Remove the quitting user from the channel.
|
||||||
channels_list[i].remove(pending)
|
try:
|
||||||
|
channels_list[i].remove(pending)
|
||||||
|
except:
|
||||||
|
print(traceback.format_exc())
|
||||||
# Finally, confirm that the client quitted by mirroring the QUIT message.
|
# Finally, confirm that the client quitted by mirroring the QUIT message.
|
||||||
connection.sendall(bytes(f":{pending}!~oreo@{client[0]} {text}\r\nERROR :Closing Link: {client[0]} ({msg})\r\n","UTF-8"))
|
connection.sendall(bytes(f":{pending}!~oreo@{client[0]} {text}\r\nERROR :Closing Link: {client[0]} ({msg})\r\n","UTF-8"))
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in a new issue