Properly disconnect DCC connexion when any part leave
This commit is contained in:
parent
9c7884f092
commit
7de644a784
13
DCC.py
13
DCC.py
|
@ -132,7 +132,7 @@ class DCC(threading.Thread):
|
||||||
except:
|
except:
|
||||||
self.setError("Une erreur s'est produite durant la tentative"
|
self.setError("Une erreur s'est produite durant la tentative"
|
||||||
" d'ouverture d'une session DCC.")
|
" d'ouverture d'une session DCC.")
|
||||||
return
|
return False
|
||||||
print ('Listen on', self.port, "for", self.sender)
|
print ('Listen on', self.port, "for", self.sender)
|
||||||
|
|
||||||
#Send CTCP request for DCC
|
#Send CTCP request for DCC
|
||||||
|
@ -146,6 +146,7 @@ class DCC(threading.Thread):
|
||||||
(self.conn, addr) = s.accept()
|
(self.conn, addr) = s.accept()
|
||||||
print ('Connected by', addr)
|
print ('Connected by', addr)
|
||||||
self.connected = True
|
self.connected = True
|
||||||
|
return True
|
||||||
|
|
||||||
def send_dcc_raw(self, line):
|
def send_dcc_raw(self, line):
|
||||||
self.conn.sendall(line + b'\n')
|
self.conn.sendall(line + b'\n')
|
||||||
|
@ -196,7 +197,9 @@ class DCC(threading.Thread):
|
||||||
# Messages connection
|
# Messages connection
|
||||||
else:
|
else:
|
||||||
if not self.connected:
|
if not self.connected:
|
||||||
self.request_user()
|
if not self.request_user():
|
||||||
|
#TODO: do something here
|
||||||
|
return False
|
||||||
|
|
||||||
#Start by sending all queued messages
|
#Start by sending all queued messages
|
||||||
for mess in self.messages:
|
for mess in self.messages:
|
||||||
|
@ -221,6 +224,12 @@ class DCC(threading.Thread):
|
||||||
if self.connected:
|
if self.connected:
|
||||||
self.conn.close()
|
self.conn.close()
|
||||||
self.connected = False
|
self.connected = False
|
||||||
|
|
||||||
|
#Remove from DCC connections server list
|
||||||
|
if self.realname in self.srv.dcc_clients:
|
||||||
|
del self.srv.dcc_clients[self.realname]
|
||||||
|
|
||||||
|
print ("Close connection with", self.nick)
|
||||||
self.stopping.set()
|
self.stopping.set()
|
||||||
#Rearm Thread
|
#Rearm Thread
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
|
2
hooks.py
2
hooks.py
|
@ -53,7 +53,7 @@ class MessagesHook:
|
||||||
del self.context.hooks_cache[store]
|
del self.context.hooks_cache[store]
|
||||||
|
|
||||||
if not hasattr(self, store):
|
if not hasattr(self, store):
|
||||||
print ("\033[1;35mWarning:\033[0m unrecognized hook store type")
|
print ("\033[1;35mWarning:\033[0m unrecognized hook store")
|
||||||
return
|
return
|
||||||
attr = getattr(self, store)
|
attr = getattr(self, store)
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ class NetworkBot:
|
||||||
|
|
||||||
self.dcc = dcc # DCC connection to the other bot
|
self.dcc = dcc # DCC connection to the other bot
|
||||||
self.hooks = list()
|
self.hooks = list()
|
||||||
|
self.REGISTERED_HOOKS = list()
|
||||||
|
|
||||||
# Tags monitor
|
# Tags monitor
|
||||||
self.my_tag = random.randint(0,255)
|
self.my_tag = random.randint(0,255)
|
||||||
|
@ -179,7 +180,7 @@ class NetworkBot:
|
||||||
if args[4] == "": args[4] = list()
|
if args[4] == "": args[4] = list()
|
||||||
else: args[4] = args[4].split(',')
|
else: args[4] = args[4].split(',')
|
||||||
|
|
||||||
self.hooks[level].add_hook(args[0], hooks.Hook(self.exec_hook, args[2], None, args[3], args[4]))
|
self.hooks[level].add_hook(args[0], hooks.Hook(self.exec_hook, args[2], None, args[3], args[4]), self)
|
||||||
|
|
||||||
elif cmd == "HOOK" and len(args) >= 8:
|
elif cmd == "HOOK" and len(args) >= 8:
|
||||||
# Rebuild the response
|
# Rebuild the response
|
||||||
|
|
Loading…
Reference in New Issue
Block a user