Separate treat_msg function in DCC, in ordre to overwrite it
This commit is contained in:
parent
f5166aca16
commit
64d4997605
28
DCC.py
28
DCC.py
@ -96,7 +96,7 @@ class DCC(threading.Thread):
|
||||
return True
|
||||
return False
|
||||
|
||||
def launch(self, mods = None):
|
||||
def launch(self, mods=None):
|
||||
"""Connect to the client if not already connected"""
|
||||
if not self.connected:
|
||||
self.stop = False
|
||||
@ -212,6 +212,17 @@ class DCC(threading.Thread):
|
||||
readbuffer = temp.pop()
|
||||
|
||||
for line in temp:
|
||||
self.treat_msg(line)
|
||||
|
||||
if self.connected:
|
||||
self.conn.close()
|
||||
self.connected = False
|
||||
self.stopping.set()
|
||||
#Rearm Thread
|
||||
threading.Thread.__init__(self)
|
||||
|
||||
def treat_msg(self, line):
|
||||
"""Treat a receive message, *can be overwritten*"""
|
||||
if (line[:nicksize] == Bnick and
|
||||
line[nicksize+1:].strip()[:10] == b'my name is'):
|
||||
name = line[nicksize+1:].strip()[11:].decode('utf-8',
|
||||
@ -224,20 +235,13 @@ class DCC(threading.Thread):
|
||||
self.srv.dcc_clients[self.realname] = self
|
||||
self.send_dcc("Hi " + self.nick)
|
||||
else:
|
||||
self.send_dcc("This nickname is already in use,"
|
||||
" please choose another one.")
|
||||
self.send_dcc("This nickname is already in use"
|
||||
", please choose another one.")
|
||||
else:
|
||||
self.send_dcc("The name you entered contain"
|
||||
" invalid char.")
|
||||
else:
|
||||
self.srv.treat_msg(
|
||||
(":%s PRIVMSG %s :" % (self.sender,
|
||||
self.srv.nick)).encode() + line,
|
||||
(":%s PRIVMSG %s :" % (
|
||||
self.sender,self.srv.nick)).encode() + line,
|
||||
True)
|
||||
|
||||
if self.connected:
|
||||
self.conn.close()
|
||||
self.connected = False
|
||||
self.stopping.set()
|
||||
#Rearm Thread
|
||||
threading.Thread.__init__(self)
|
||||
|
Loading…
Reference in New Issue
Block a user