New event when connection with server is closed

This commit is contained in:
Némunaire 2012-11-08 13:22:46 +01:00
parent cb0056b605
commit 818bc5f889
2 changed files with 6 additions and 2 deletions

4
DCC.py
View File

@ -206,13 +206,15 @@ class DCC(server.Server):
print ("Closing connection with", self.nick)
self.stopping.set()
if self.closing_event is not None:
self.closing_event()
#Rearm Thread
threading.Thread.__init__(self)
def treat_msg(self, line):
"""Treat a receive message, *can be overwritten*"""
if line == b'NEMUBOT###':
bot = self.srv.context.add_networkbot(self.srv, self.sender, self)
bot = self.srv.add_networkbot(self.srv, self.sender, self)
self.treatement = bot.treat_msg
self.send_dcc("NEMUBOT###")
elif (line[:self.nicksize] == self.Bnick and

View File

@ -204,6 +204,8 @@ class IRCServer(server.Server):
if self.connected:
self.s.close()
self.connected = False
if self.closing_event is not None:
self.closing_event()
print ("Server `%s' successfully stopped." % self.id)
self.stopping.set()
# Rearm Thread