From 71ad53a1f9372ea7e8b8f2a5b2e72b402372e7e3 Mon Sep 17 00:00:00 2001 From: shoucandanghehe Date: Fri, 2 Aug 2024 22:00:40 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E9=80=82=E9=85=8D=20TETR.IO=20rank?= =?UTF-8?q?=20v1=20=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/render/__init__.py | 11 ++++++++--- .../render/schemas/tetrio/tetrio_rank_v1.py | 16 ++++++++++++++++ .../tetrio/{tetrio_rank.py => tetrio_rank_v2.py} | 0 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/tetrio_rank_v1.py rename nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/{tetrio_rank.py => tetrio_rank_v2.py} (100%) diff --git a/nonebot_plugin_tetris_stats/utils/render/__init__.py b/nonebot_plugin_tetris_stats/utils/render/__init__.py index 21ab05e..a7b236e 100644 --- a/nonebot_plugin_tetris_stats/utils/render/__init__.py +++ b/nonebot_plugin_tetris_stats/utils/render/__init__.py @@ -6,8 +6,9 @@ from nonebot.compat import PYDANTIC_V2 from ..templates import templates_dir from .schemas.bind import Bind from .schemas.tetrio.tetrio_info import Info as TETRIOInfo -from .schemas.tetrio.tetrio_rank import Data as TETRIORankData from .schemas.tetrio.tetrio_rank_detail import Data as TETRIORankDetailData +from .schemas.tetrio.tetrio_rank_v1 import Data as TETRIORankDataV1 +from .schemas.tetrio.tetrio_rank_v2 import Data as TETRIORankDataV2 from .schemas.tetrio.tetrio_record_blitz import Record as TETRIORecordBlitz from .schemas.tetrio.tetrio_record_sprint import Record as TETRIORecordSprint from .schemas.tetrio.tetrio_user_info_v2 import Info as TETRIOUserInfoV2 @@ -25,6 +26,8 @@ async def render(render_type: Literal['v1/binding'], data: Bind) -> str: ... @overload async def render(render_type: Literal['v1/tetrio/info'], data: TETRIOInfo) -> str: ... @overload +async def render(render_type: Literal['v1/tetrio/rank'], data: TETRIORankDataV1) -> str: ... +@overload async def render(render_type: Literal['v1/top/info'], data: TOPInfo) -> str: ... @overload async def render(render_type: Literal['v1/tos/info'], data: TOSInfo) -> str: ... @@ -37,7 +40,7 @@ async def render(render_type: Literal['v2/tetrio/record/40l'], data: TETRIORecor @overload async def render(render_type: Literal['v2/tetrio/record/blitz'], data: TETRIORecordBlitz) -> str: ... @overload -async def render(render_type: Literal['v2/tetrio/rank'], data: TETRIORankData) -> str: ... +async def render(render_type: Literal['v2/tetrio/rank'], data: TETRIORankDataV2) -> str: ... @overload async def render(render_type: Literal['v2/tetrio/rank/detail'], data: TETRIORankDetailData) -> str: ... @@ -46,6 +49,7 @@ async def render( render_type: Literal[ 'v1/binding', 'v1/tetrio/info', + 'v1/tetrio/rank', 'v1/top/info', 'v1/tos/info', 'v2/tetrio/user/info', @@ -57,13 +61,14 @@ async def render( ], data: Bind | TETRIOInfo + | TETRIORankDataV1 | TOPInfo | TOSInfo | TETRIOUserInfoV2 | TETRIOUserListV2 | TETRIORecordSprint | TETRIORecordBlitz - | TETRIORankData + | TETRIORankDataV2 | TETRIORankDetailData, ) -> str: if PYDANTIC_V2: diff --git a/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/tetrio_rank_v1.py b/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/tetrio_rank_v1.py new file mode 100644 index 0000000..29ea837 --- /dev/null +++ b/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/tetrio_rank_v1.py @@ -0,0 +1,16 @@ +from datetime import datetime + +from pydantic import BaseModel + +from .....games.tetrio.api.typing import ValidRank + + +class ItemData(BaseModel): + trending: float + require_tr: float + players: int + + +class Data(BaseModel): + items: dict[ValidRank, ItemData] + updated_at: datetime diff --git a/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/tetrio_rank.py b/nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/tetrio_rank_v2.py similarity index 100% rename from nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/tetrio_rank.py rename to nonebot_plugin_tetris_stats/utils/render/schemas/tetrio/tetrio_rank_v2.py