Based DCC connection state on realname instead of nickname and realname

This commit is contained in:
Némunaire 2012-07-23 04:19:53 +02:00
parent 336cab6b2a
commit e4ea24bfa9
3 changed files with 12 additions and 11 deletions

12
DCC.py
View File

@ -153,7 +153,8 @@ class DCC(threading.Thread):
self.conn.recv(4) #The client send a confirmation after each packet
d = f.read(268435456) #Packets size: 256Mo
else:
self.request_user()
if not self.connected:
self.request_user()
#Start by sending all queued messages
for mess in self.messages:
@ -179,12 +180,9 @@ class DCC(threading.Thread):
if name not in self.srv.dcc_clients:
del self.srv.dcc_clients[self.sender]
self.nick = name
if len(self.sender.split("!")) > 1:
self.sender = self.nick + "!" + self.sender.split("!")[1]
else:
self.sender = self.nick
self.srv.dcc_clients[self.sender] = self
self.send_dcc("Hi "+self.nick)
self.sender = self.nick + "!" + self.realname
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.")
else:

View File

@ -51,6 +51,7 @@ class Message:
self.realname = (self.sender.split('!'))[1]
else:
self.realname = self.nick
self.sender = self.nick + "!" + self.realname
if len(words) > 2:
self.channel = words[2].decode()

View File

@ -106,10 +106,11 @@ class Server(threading.Thread):
def send_dcc(self, msg, to):
"""Send a message through DCC connection"""
if msg is not None and to is not None:
realname = to.split("!")[1]
if to not in self.dcc_clients.keys():
d = dcc.DCC(self, to)
self.dcc_clients[to] = d
self.dcc_clients[to].send_dcc(msg)
d = dcc.DCC(self, realname)
self.dcc_clients[realname] = d
self.dcc_clients[realname].send_dcc(msg)
def send_msg_final(self, channel, msg, cmd = "PRIVMSG", endl = "\r\n"):
@ -131,7 +132,8 @@ class Server(threading.Thread):
def send_msg_usr(self, user, msg):
if user is not None and user[0] != "#":
if user in self.dcc_clients:
realname = to.split("!")[1]
if realname in self.dcc_clients:
self.send_dcc(msg, user)
else:
self.send_msg_final(user.split('!')[0], msg)