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 True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def launch(self, mods = None):
|
def launch(self, mods=None):
|
||||||
"""Connect to the client if not already connected"""
|
"""Connect to the client if not already connected"""
|
||||||
if not self.connected:
|
if not self.connected:
|
||||||
self.stop = False
|
self.stop = False
|
||||||
@ -212,6 +212,17 @@ class DCC(threading.Thread):
|
|||||||
readbuffer = temp.pop()
|
readbuffer = temp.pop()
|
||||||
|
|
||||||
for line in temp:
|
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
|
if (line[:nicksize] == Bnick and
|
||||||
line[nicksize+1:].strip()[:10] == b'my name is'):
|
line[nicksize+1:].strip()[:10] == b'my name is'):
|
||||||
name = line[nicksize+1:].strip()[11:].decode('utf-8',
|
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.srv.dcc_clients[self.realname] = self
|
||||||
self.send_dcc("Hi " + self.nick)
|
self.send_dcc("Hi " + self.nick)
|
||||||
else:
|
else:
|
||||||
self.send_dcc("This nickname is already in use,"
|
self.send_dcc("This nickname is already in use"
|
||||||
" please choose another one.")
|
", please choose another one.")
|
||||||
else:
|
else:
|
||||||
self.send_dcc("The name you entered contain"
|
self.send_dcc("The name you entered contain"
|
||||||
" invalid char.")
|
" invalid char.")
|
||||||
else:
|
else:
|
||||||
self.srv.treat_msg(
|
self.srv.treat_msg(
|
||||||
(":%s PRIVMSG %s :" % (self.sender,
|
(":%s PRIVMSG %s :" % (
|
||||||
self.srv.nick)).encode() + line,
|
self.sender,self.srv.nick)).encode() + line,
|
||||||
True)
|
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