def change_nick(self,user,newnick): self.dbg('server nick change %s -> %s' % (user.nick,newnick)) if user.nick not in self.users: self.users[user.nick] = user self.users[newnick] = self.users.pop(user.nick) user.nick_change(user,newnick) for chan in user.chans: self.dbg('inform %s of nick change'%chan) if chan in self.chans: self.chans[chan].nick_change(user,newnick) user.nick = newnick user.usr = newnick self.dbg('user is now %s'%user)
def change_nick(self,user,newnick): self.dbg('server nick change %s -> %s' % (user.nick,newnick)) if len(newnick) > 30: user.send_num(432, "%s :Erroneous nickname"%newnick) newnick = user.do_nickname('') elif newnick in self.users: user.send_num(433, "%s :Nickname is already in use"%newnick) if newnick == user.nick: return newnick = user.do_nickname('') self.users[user.nick] = user #FIXME: this isn't necessary...is it? self.users[newnick] = self.users.pop(user.nick) user.nick_change(user,newnick) for chan in user.chans: self.dbg('inform %s of nick change'%chan) if chan in self.chans: self.chans[chan].nick_change(user,newnick) user.nick = newnick user.usr = newnick self.dbg('user is now %s'%user)
def change_nick(self,user,newnick): self.dbg('server nick change %s -> %s' % (user.nick,newnick)) if len(newnick) > 30: user.send_num(432, "%s :Erroneous nickname"%newnick) newnick = user.do_nickname('') elif newnick in self.users: user.send_num(433, "%s :Nickname is already in use"%newnick) if newnick == user.nick: return newnick = user.do_nickname('') self.users[user.nick] = user #FIXME: this isn't necessary...is it? self.users[newnick] = self.users.pop(user.nick) for u in self.users.values(): if not isinstance(u, User): continue if u == user: continue print u.nick, user.chans, u.chans for chan in set(user.chans).intersection(u.chans): print chan, self.chans[chan].is_anon() if not self.chans[chan].is_anon(): u.nick_change(user,newnick) break user.nick_change(user,newnick) user.nick = newnick user.usr = newnick self.dbg('user is now %s'%user)