Exemplo n.º 1
0
def logout(args):
    user = get_user(args[1])
    if user:
        s = socket_by_user(user)
        if s:
            dblogout(s, user)
        else:
            user.online = False
Exemplo n.º 2
0
def friend_request_send(socket, args):
    target = db.get_user(args[1])
    if target:
        if target not in inputs[socket].profile.friends:
            if target not in inputs[socket].profile.requests and\
                    inputs[socket].profile not in target.requests:
                target.requests.append(inputs[socket].profile)
                send_cmd_success(socket, 140)
                # Lets notify the user that it has new friend request
                if target.online:
                    sock = socket_by_user(target)
                    if sock:
                        send_event(sock, 110, inputs[socket].profile.username)
            else:
                send_error(socket, 222)
        else:
            send_error(socket, 221)
    else:
        send_error(socket, 220)
Exemplo n.º 3
0
def friend_request_accept(socket, args):
    target = db.get_user(args[1])
    if target:
        if target in inputs[socket].profile.requests:
            # Remove request
            inputs[socket].profile.requests.remove(target)
            # Add users to eachothers friends lists
            inputs[socket].profile.friends.append(target)
            target.friends.append(inputs[socket].profile)
            send_cmd_success(socket, 141)
            if target.online:
                s = socket_by_user(target)
                if s:
                    send_event(s, 111, inputs[socket].profile.username)
                    send_event(socket, 111, target.username)
        else:
            send_error(socket, 223)
    else:
        send_error(socket, 220)