Beispiel #1
0
        await p.fetch_geoloc(ip)

    # update our new player's stats, and broadcast them.
    user_data = (packets.userPresence(p) + packets.userStats(p))

    data.extend(user_data)

    # o for online, or other
    for o in glob.players:
        # enqueue us to them
        o.enqueue(user_data)

        # enqueue them to us.
        data.extend(packets.userPresence(o) + packets.userStats(o))

    data.extend(packets.mainMenuIcon() + packets.friendsList(*p.friends) +
                packets.silenceEnd(p.remaining_silence))

    # thank u osu for doing this by username rather than id
    query = ('SELECT m.`msg`, m.`time`, m.`from_id`, '
             '(SELECT name FROM users WHERE id = m.`from_id`) AS `from`, '
             '(SELECT name FROM users WHERE id = m.`to_id`) AS `to` '
             'FROM `mail` m WHERE m.`to_id` = %s AND m.`read` = 0')

    # the player may have been sent mail while offline,
    # enqueue any messages from their respective authors.
    async for msg in glob.db.iterall(query, p.id):
        msg_time = dt.fromtimestamp(msg['time'])
        msg_ts = f'[{msg_time:%Y-%m-%d %H:%M:%S}] {msg["msg"]}'

        data.extend(
Beispiel #2
0
    # update our new player's stats, and broadcast them.
    user_data = (packets.userPresence(p) + packets.userStats(p))

    data += user_data

    # o for online, or other
    for o in glob.players:
        # enqueue us to them
        o.enqueue(user_data)

        # enqueue them to us.
        data += packets.userPresence(o)
        data += packets.userStats(o)

    data += packets.mainMenuIcon()
    data += packets.friendsList(*p.friends)
    data += packets.silenceEnd(p.remaining_silence)

    # thank u osu for doing this by username rather than id
    # comment out for now
    # query = ('SELECT m.`msg`, m.`time`, m.`from_id`, '
    #          '(SELECT name FROM users WHERE id = m.`from_id`) AS `from`, '
    #          '(SELECT name FROM users WHERE id = m.`to_id`) AS `to` '
    #          'FROM `mail` m WHERE m.`to_id` = %s AND m.`read` = 0')

    # # the player may have been sent mail while offline,
    # # enqueue any messages from their respective authors.
    # async for msg in glob.db.iterall(query, [p.id]):
    #     msg_time = dt.fromtimestamp(msg['time'])
    #     msg_ts = f'[{msg_time:%a %b %d @ %H:%M%p}] {msg["msg"]}'
Beispiel #3
0
        p.fetch_geoloc(ip)

    # Update our new player's stats, and broadcast them.
    user_data = packets.userPresence(p) + packets.userStats(p)

    data.extend(user_data)

    # o for online, or other
    for o in glob.players:
        # Enqueue us to them
        o.enqueue(user_data)

        # Enqueue them to us.
        data.extend(packets.userPresence(o) + packets.userStats(o))

    data.extend(packets.mainMenuIcon())
    data.extend(packets.friendsList(*p.friends))
    data.extend(packets.silenceEnd(max(p.silence_end - time(), 0)))

    glob.players.add(p)
    printlog(f'{p} logged in.', Ansi.LIGHT_YELLOW)
    return bytes(data), p.token


# PacketID: 16
@bancho_packet(Packet.c_startSpectating)
def startSpectating(p: Player, pr: PacketReader) -> None:
    target_id = pr.read(osuTypes.i32)[0]

    if not (host := glob.players.get_by_id(target_id)):
        printlog(f'{p} tried to spectate nonexistant id {target_id}.',