From b0ee7fe6c76e619079ba021068b24bcfbdc9eb79 Mon Sep 17 00:00:00 2001 From: shoucandanghehe Date: Fri, 10 May 2024 12:20:25 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=20TETR.IO=20?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=A4=B4=E5=83=8F=E4=BC=A0=E5=8F=82=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../game_data_processor/io_data_processor/processor.py | 5 ++++- nonebot_plugin_tetris_stats/utils/render.py | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/nonebot_plugin_tetris_stats/game_data_processor/io_data_processor/processor.py b/nonebot_plugin_tetris_stats/game_data_processor/io_data_processor/processor.py index e322d03..0b1eb73 100644 --- a/nonebot_plugin_tetris_stats/game_data_processor/io_data_processor/processor.py +++ b/nonebot_plugin_tetris_stats/game_data_processor/io_data_processor/processor.py @@ -312,7 +312,10 @@ class Processor(ProcessorMeta): user=TETRIOInfo.User( avatar=f'https://tetr.io/user-content/avatars/{user_info.data.user.id}.jpg?rv={user_info.data.user.avatar_revision}' if user_info.data.user.avatar_revision is not None - else f'{{"type":"identicon","hash":"{md5(user_info.data.user.id.encode()).hexdigest()}"}}', # noqa: S324 + else TETRIOInfo.User.Avatar( + type='identicon', + hash=md5(user_info.data.user.id.encode()).hexdigest(), # noqa: S324 + ), name=user_name, bio=user_info.data.user.bio, ), diff --git a/nonebot_plugin_tetris_stats/utils/render.py b/nonebot_plugin_tetris_stats/utils/render.py index ec05e52..1447a3c 100644 --- a/nonebot_plugin_tetris_stats/utils/render.py +++ b/nonebot_plugin_tetris_stats/utils/render.py @@ -35,7 +35,11 @@ class Bind(BaseModel): class TETRIOInfo(BaseModel): class User(BaseModel): - avatar: str + class Avatar(BaseModel): + type: Literal['identicon'] + hash: str + + avatar: str | Avatar name: str bio: str | None