Fix bad parsing of JOIN command

This commit is contained in:
Némunaire 2012-07-20 17:11:21 +02:00
parent 05cf740151
commit f4d3c6a500
3 changed files with 23 additions and 20 deletions

View File

@ -8,23 +8,23 @@ class Channel:
self.people = dict()
self.topic = ""
def join(self, msg):
#print ("%s arrive sur %s" % (self.sender, self.channel))
self.people[msg.sender] = 0
def join(self, nick, level = 0):
#print ("%s arrive sur %s" % (nick, self.name))
self.people[nick] = level
def nick(self, msg):
#print ("%s change de nom pour %s" % (self.sender, self.content))
if msg.sender in self.people:
lvl = self.people[msg.sender]
del self.people[msg.sender]
def nick(self, oldnick, newnick):
print ("%s change de nom pour %s" % (oldnick, newnick))
if oldnick in self.people:
lvl = self.people[oldnick]
del self.people[oldnick]
else:
lvl = 0
self.people[msg.content] = lvl
self.people[newnick] = lvl
def part(self, msg):
def part(self, nick):
#print ("%s vient de quitter %s" % (self.sender, self.channel))
if msg.sender in self.people:
del self.people[msg.sender]
if nick in self.people:
del self.people[nick]
def mode(self, msg):
if msg.content[0] == "-k":

View File

@ -66,6 +66,8 @@ class Message:
break
elif self.cmd == 'MODE':
self.content = words[3:]
elif self.cmd == 'JOIN' and self.channel[0] == ":":
self.channel = self.channel[1:]
elif self.cmd == '332':
self.channel = words[3]
self.content = ' '.join(words[4:])[1:]
@ -130,15 +132,16 @@ class Message:
self.srv.channels[self.channel].parse332(self)
elif self.cmd == "MODE":
self.srv.channels[self.channel].mode(self)
elif self.cmd == "NICK":
self.srv.channels[self.channel].nick(self)
elif self.cmd == "JOIN":
self.srv.channels[self.channel].join(self)
self.srv.channels[self.channel].join(self.sender)
elif self.cmd == "PART":
self.srv.channels[self.channel].part(self)
elif self.cmd == "QUIT":
for chn in self.srv.channels.keys():
self.srv.channels[chn].part(self)
self.srv.channels[self.channel].part(self.sender)
elif self.cmd == "NICK":
for chn in self.srv.channels.keys():
self.srv.channels[chn].nick(self.sender, self.content)
elif self.cmd == "QUIT":
for chn in self.srv.channels.keys():
self.srv.channels[chn].part(self.sender)
def pong (self):

View File

@ -312,7 +312,7 @@ def liste(cmds, servers):
elif l == "chan" or l == "channel" or l == "channels":
if selectedServer is not None:
for chn in selectedServer.channels:
print (" - %s ;" % chn)
print (" - %s: %s ;" % (chn, selectedServer.channels[chn].people.keys()))
else:
print (" Please SELECT a server before ask for channels list.")
else: