From ea8a18c1b181ee34c6981818957df44f5aebbaff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=B5=E5=91=B5=E3=81=A7=E3=81=99?= <51957264+shoucandanghehe@users.noreply.github.com> Date: Sat, 19 Oct 2024 17:27:13 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=20=E8=8C=B6?= =?UTF-8?q?=E6=9C=8D=20api=20=E6=9F=A5=E8=AF=A2=E9=93=BE=E6=8E=A5=E6=8B=BC?= =?UTF-8?q?=E6=8E=A5=E9=94=99=E8=AF=AF=20(#480)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_tetris_stats/games/tos/api/player.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/nonebot_plugin_tetris_stats/games/tos/api/player.py b/nonebot_plugin_tetris_stats/games/tos/api/player.py index 16c0604..f3f1b1e 100644 --- a/nonebot_plugin_tetris_stats/games/tos/api/player.py +++ b/nonebot_plugin_tetris_stats/games/tos/api/player.py @@ -59,13 +59,14 @@ class Player: async def get_info(self) -> UserInfoSuccess: """获取用户信息""" if self._user_info is None: - path = str( - URL('getTeaIdInfo') % {'teaId': self.teaid} - if self.teaid is not None - else URL('getUsernameInfo') % {'username': cast(str, self.user_name)} - ) + if self.teaid is not None: + path = 'getTeaIdInfo' + query = {'teaId': self.teaid} + else: + path = 'getUsernameInfo' + query = {'username': cast(str, self.user_name)} raw_user_info = await request.failover_request( - [i / path for i in BASE_URL], failover_code=[502], failover_exc=(TimeoutException,) + [i / path % query for i in BASE_URL], failover_code=[502], failover_exc=(TimeoutException,) ) user_info: UserInfo = type_validate_json(UserInfo, raw_user_info) # type: ignore[arg-type] if not isinstance(user_info, UserInfoSuccess):