|
4 | 4 |
|
5 | 5 | import asyncio |
6 | 6 | import hashlib |
7 | | -import logging |
8 | 7 | import re |
9 | 8 | import struct |
10 | 9 | import time |
|
18 | 17 | from zoneinfo import ZoneInfo |
19 | 18 |
|
20 | 19 | import bcrypt |
21 | | -import databases.core |
22 | 20 | from fastapi import APIRouter |
23 | 21 | from fastapi import Response |
24 | 22 | from fastapi.param_functions import Header |
@@ -298,7 +296,7 @@ async def handle(self, player: Player) -> None: |
298 | 296 | app.state.sessions.players.enqueue(app.packets.user_stats(player)) |
299 | 297 |
|
300 | 298 |
|
301 | | -IGNORED_CHANNELS = ["#highlight", "#userlog"] |
| 299 | +IGNORED_CHANNELS: list[str] = ["#highlight", "#userlog"] |
302 | 300 |
|
303 | 301 |
|
304 | 302 | @register(ClientPackets.SEND_PUBLIC_MESSAGE) |
@@ -886,14 +884,14 @@ async def handle_osu_login_request( |
886 | 884 | if ( |
887 | 885 | not channel.auto_join |
888 | 886 | or not channel.can_read(player.priv) |
889 | | - or channel._name == "#lobby" # (can't be in mp lobby @ login) |
| 887 | + or channel.real_name == "#lobby" # (can't be in mp lobby @ login) |
890 | 888 | ): |
891 | 889 | continue |
892 | 890 |
|
893 | 891 | # send chan info to all players who can see |
894 | 892 | # the channel (to update their playercounts) |
895 | 893 | chan_info_packet = app.packets.channel_info( |
896 | | - channel._name, |
| 894 | + channel.real_name, |
897 | 895 | channel.topic, |
898 | 896 | len(channel.players), |
899 | 897 | ) |
@@ -950,29 +948,28 @@ async def handle_osu_login_request( |
950 | 948 | read=False, |
951 | 949 | ) |
952 | 950 |
|
953 | | - if mail_rows: |
954 | | - sent_to: set[int] = set() |
955 | | - |
956 | | - for msg in mail_rows: |
957 | | - # Add "Unread messages" header as the first message |
958 | | - # for any given sender, to make it clear that the |
959 | | - # messages are coming from the mail system. |
960 | | - if msg["from_id"] not in sent_to: |
961 | | - data += app.packets.send_message( |
962 | | - sender=msg["from_name"], |
963 | | - msg="Unread messages", |
964 | | - recipient=msg["to_name"], |
965 | | - sender_id=msg["from_id"], |
966 | | - ) |
967 | | - sent_to.add(msg["from_id"]) |
| 951 | + sent_to: set[int] = set() |
968 | 952 |
|
969 | | - msg_time = datetime.fromtimestamp(msg["time"]) |
| 953 | + for msg in mail_rows: |
| 954 | + # Add "Unread messages" header as the first message |
| 955 | + # for any given sender, to make it clear that the |
| 956 | + # messages are coming from the mail system. |
| 957 | + if msg["from_id"] not in sent_to: |
970 | 958 | data += app.packets.send_message( |
971 | 959 | sender=msg["from_name"], |
972 | | - msg=f'[{msg_time:%a %b %d @ %H:%M%p}] {msg["msg"]}', |
| 960 | + msg="Unread messages", |
973 | 961 | recipient=msg["to_name"], |
974 | 962 | sender_id=msg["from_id"], |
975 | 963 | ) |
| 964 | + sent_to.add(msg["from_id"]) |
| 965 | + |
| 966 | + msg_time = datetime.fromtimestamp(msg["time"]) |
| 967 | + data += app.packets.send_message( |
| 968 | + sender=msg["from_name"], |
| 969 | + msg=f'[{msg_time:%a %b %d @ %H:%M%p}] {msg["msg"]}', |
| 970 | + recipient=msg["to_name"], |
| 971 | + sender_id=msg["from_id"], |
| 972 | + ) |
976 | 973 |
|
977 | 974 | if not player.priv & Privileges.VERIFIED: |
978 | 975 | # this is the player's first login, verify their |
@@ -1025,10 +1022,10 @@ async def handle_osu_login_request( |
1025 | 1022 |
|
1026 | 1023 | if app.state.services.datadog: |
1027 | 1024 | if not player.restricted: |
1028 | | - app.state.services.datadog.increment("bancho.online_players") |
| 1025 | + app.state.services.datadog.increment("bancho.online_players") # type: ignore[no-untyped-call] |
1029 | 1026 |
|
1030 | 1027 | time_taken = time.time() - login_time |
1031 | | - app.state.services.datadog.histogram("bancho.login_time", time_taken) |
| 1028 | + app.state.services.datadog.histogram("bancho.login_time", time_taken) # type: ignore[no-untyped-call] |
1032 | 1029 |
|
1033 | 1030 | user_os = "unix (wine)" if running_under_wine else "win32" |
1034 | 1031 | country_code = player.geoloc["country"]["acronym"].upper() |
@@ -1763,7 +1760,9 @@ async def handle(self, player: Player) -> None: |
1763 | 1760 |
|
1764 | 1761 | if player.match.is_scrimming: |
1765 | 1762 | # determine winner, update match points & inform players. |
1766 | | - asyncio.create_task(player.match.update_matchpoints(was_playing)) |
| 1763 | + asyncio.create_task( # type: ignore[unused-awaitable] |
| 1764 | + player.match.update_matchpoints(was_playing), |
| 1765 | + ) |
1767 | 1766 |
|
1768 | 1767 |
|
1769 | 1768 | @register(ClientPackets.MATCH_CHANGE_MODS) |
@@ -2109,7 +2108,9 @@ def __init__(self, reader: BanchoPacketReader) -> None: |
2109 | 2108 |
|
2110 | 2109 | async def handle(self, player: Player) -> None: |
2111 | 2110 | unrestrcted_ids = [p.id for p in app.state.sessions.players.unrestricted] |
2112 | | - is_online = lambda o: o in unrestrcted_ids and o != player.id |
| 2111 | + |
| 2112 | + def is_online(o: int) -> bool: |
| 2113 | + return o in unrestrcted_ids and o != player.id |
2113 | 2114 |
|
2114 | 2115 | for online in filter(is_online, self.user_ids): |
2115 | 2116 | target = app.state.sessions.players.get(id=online) |
|
0 commit comments