Skip to content

🐛 修复被 ban 的爆炸 #510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,9 @@ class RatedData(BaseData):
percentile_rank: str


class InvalidData(BaseModel):
"""I don't know what osk is doing, but the return value is an empty dictionary"""


class LeagueSuccessModel(SuccessModel):
data: NeverPlayedData | NeverRatedData | RatedData
data: NeverPlayedData | NeverRatedData | RatedData | InvalidData
4 changes: 3 additions & 1 deletion nonebot_plugin_tetris_stats/games/tetrio/query/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ....utils.exception import FallbackError
from ....utils.render.schemas.tetrio.user.base import TetraLeagueHistoryData
from ..api.schemas.labs.leagueflow import Empty, LeagueFlowSuccess
from ..api.schemas.summaries.league import LeagueSuccessModel, NeverPlayedData, NeverRatedData, RatedData
from ..api.schemas.summaries.league import InvalidData, LeagueSuccessModel, NeverPlayedData, NeverRatedData, RatedData


def flow_to_history(
Expand Down Expand Up @@ -47,6 +47,8 @@ def get_league_data(
user_info: LeagueSuccessModel, league_type: type[L] | None = None
) -> L | NeverPlayedData | NeverRatedData | RatedData:
league = user_info.data
if isinstance(league, InvalidData):
raise FallbackError
if league_type is None:
return league
if isinstance(league, league_type):
Expand Down
4 changes: 2 additions & 2 deletions nonebot_plugin_tetris_stats/games/tetrio/query/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
)
from ....utils.screenshot import screenshot
from ..api import Player
from ..api.schemas.summaries.league import NeverPlayedData, NeverRatedData
from ..api.schemas.summaries.league import InvalidData, NeverPlayedData, NeverRatedData
from .tools import flow_to_history, handling_special_value


Expand Down Expand Up @@ -111,7 +111,7 @@ async def make_query_image_v2(player: Player) -> bytes:
decaying=league.data.decaying,
history=history,
)
if not isinstance(league.data, NeverPlayedData)
if not isinstance(league.data, NeverPlayedData | InvalidData)
else None,
statistic=Statistic(
total=handling_special_value(user_info.data.gamesplayed),
Expand Down