def join(self, sock, source, name): user = self.users[sock] if name not in self.channels: channel = self.channels[name] = Channel(name) else: channel = self.channels[name] if user in channel.users: return user.channels.append(name) channel.users.append(user) self._notify(channel.users, Message("JOIN", name, prefix=user.prefix)) if channel.topic: self.fire(reply(sock, RPL_TOPIC(channel.topic))) else: self.fire(reply(sock, RPL_NOTOPIC(channel.name))) self.fire( reply( sock, RPL_NAMEREPLY(channel.name, [x.prefix for x in channel.users]))) self.fire(reply(sock, RPL_ENDOFNAMES(channel.name)))
def names(self, sock, source, name): channel = models.Channel.objects.filter(name=name).first() if channel is None: return ERR_NOSUCHCHANNEL(name) return [ RPL_NAMEREPLY(channel.name, channel.userprefixes), RPL_ENDOFNAMES(name), ]