Beispiel #1
0
    def nick(self, sock, source, nick):
        user = User.objects.filter(sock=sock).first()

        if not VALID_NICK_REGEX.match(nick):
            return ERR_ERRONEUSNICKNAME(nick)

        if len(nick) > self.parent.nicklen:
            return ERR_ERRONEUSNICKNAME(nick)

        if any(x for x in User.objects.all()
               if x.nick and x.nick.lower() == nick.lower()):
            return ERR_NICKNAMEINUSE(nick)

        prefix = user.prefix or joinprefix(*source)
        user.nick = nick
        user.save()

        if user.userinfo and user.userinfo.user is not None:
            user.registered = True
            user.save()
            return signon(sock, user.source)

        users = chain(*map(attrgetter("users"), user.channels))

        self.notify(users, Message(u("NICK"), nick, prefix=prefix))
Beispiel #2
0
    def nick(self, sock, source, nick):
        user = self.users[sock]

        if nick in self.nicks:
            return self.fire(reply(sock, ERR_NICKNAMEINUSE(nick)))

        if not user.registered:
            user.registered = True
            self.fire(response.create("signon", sock, user))

        user.nick = nick
        self.nicks[nick] = user