mirror of
https://github.com/A-Minos/nonebot-plugin-tetris-stats.git
synced 2026-03-05 05:36:54 +08:00
✨ 全部适配
This commit is contained in:
@@ -6,11 +6,13 @@ from yarl import URL
|
||||
|
||||
from ....utils.exception import FallbackError
|
||||
from ....utils.host import HostPage, get_self_netloc
|
||||
from ....utils.lang import get_lang
|
||||
from ....utils.metrics import get_metrics
|
||||
from ....utils.render import render
|
||||
from ....utils.render.schemas.base import Avatar
|
||||
from ....utils.render.schemas.tetrio.user.info_v2 import (
|
||||
from ....utils.render.schemas.v2.tetrio.user.info import (
|
||||
Badge,
|
||||
Best,
|
||||
Blitz,
|
||||
Info,
|
||||
Sprint,
|
||||
@@ -18,7 +20,9 @@ from ....utils.render.schemas.tetrio.user.info_v2 import (
|
||||
TetraLeague,
|
||||
TetraLeagueStatistic,
|
||||
User,
|
||||
Week,
|
||||
Zen,
|
||||
Zenith,
|
||||
)
|
||||
from ....utils.screenshot import screenshot
|
||||
from ..api import Player
|
||||
@@ -29,10 +33,23 @@ from .tools import flow_to_history, handling_special_value
|
||||
async def make_query_image_v2(player: Player) -> bytes:
|
||||
(
|
||||
(user, user_info, league, sprint, blitz, zen),
|
||||
(avatar_revision, banner_revision, leagueflow),
|
||||
(avatar_revision, banner_revision, leagueflow, zenith, zenithex),
|
||||
) = await gather(
|
||||
gather(player.user, player.get_info(), player.league, player.sprint, player.blitz, player.zen),
|
||||
gather(player.avatar_revision, player.banner_revision, player.get_leagueflow()),
|
||||
gather(
|
||||
player.user,
|
||||
player.get_info(),
|
||||
player.league,
|
||||
player.sprint,
|
||||
player.blitz,
|
||||
player.zen,
|
||||
),
|
||||
gather(
|
||||
player.avatar_revision,
|
||||
player.banner_revision,
|
||||
player.get_leagueflow(),
|
||||
player.get_summaries('zenith'),
|
||||
player.get_summaries('zenithex'),
|
||||
),
|
||||
)
|
||||
if sprint.data.record is not None:
|
||||
duration = timedelta(milliseconds=sprint.data.record.results.stats.finaltime).total_seconds()
|
||||
@@ -62,12 +79,9 @@ async def make_query_image_v2(player: Player) -> bytes:
|
||||
user=User(
|
||||
id=user.ID,
|
||||
name=user.name.upper(),
|
||||
bio=user_info.data.bio,
|
||||
banner=str(
|
||||
URL(f'http://{netloc}/host/resource/tetrio/banners/{user.ID}') % {'revision': banner_revision}
|
||||
)
|
||||
if banner_revision is not None and banner_revision != 0
|
||||
else None,
|
||||
country=user_info.data.country,
|
||||
role=user_info.data.role,
|
||||
botmaster=user_info.data.botmaster,
|
||||
avatar=str(
|
||||
URL(f'http://{netloc}/host/resource/tetrio/avatars/{user.ID}') % {'revision': avatar_revision}
|
||||
)
|
||||
@@ -76,6 +90,15 @@ async def make_query_image_v2(player: Player) -> bytes:
|
||||
type='identicon',
|
||||
hash=md5(user.ID.encode()).hexdigest(), # noqa: S324
|
||||
),
|
||||
banner=str(
|
||||
URL(f'http://{netloc}/host/resource/tetrio/banners/{user.ID}') % {'revision': banner_revision}
|
||||
)
|
||||
if banner_revision is not None and banner_revision != 0
|
||||
else None,
|
||||
bio=user_info.data.bio,
|
||||
friend_count=user_info.data.friend_count,
|
||||
supporter_tier=user_info.data.supporter_tier,
|
||||
bad_standing=user_info.data.badstanding or False,
|
||||
badges=[
|
||||
Badge(
|
||||
id=i.id,
|
||||
@@ -85,12 +108,9 @@ async def make_query_image_v2(player: Player) -> bytes:
|
||||
)
|
||||
for i in user_info.data.badges
|
||||
],
|
||||
country=user_info.data.country,
|
||||
role=user_info.data.role,
|
||||
xp=user_info.data.xp,
|
||||
friend_count=user_info.data.friend_count,
|
||||
supporter_tier=user_info.data.supporter_tier,
|
||||
bad_standing=user_info.data.badstanding or False,
|
||||
ar=user_info.data.ar,
|
||||
achievements=user_info.data.achievements,
|
||||
playtime=play_time,
|
||||
join_at=user_info.data.ts,
|
||||
),
|
||||
@@ -113,6 +133,40 @@ async def make_query_image_v2(player: Player) -> bytes:
|
||||
)
|
||||
if not isinstance(league.data, NeverPlayedData | InvalidData)
|
||||
else None,
|
||||
zenith=Zenith(
|
||||
week=Week(
|
||||
altitude=zenith.data.record.results.stats.zenith.altitude,
|
||||
global_rank=zenith.data.rank,
|
||||
country_rank=zenith.data.rank_local,
|
||||
play_at=zenith.data.record.ts,
|
||||
)
|
||||
if zenith.data.record is not None
|
||||
else None,
|
||||
best=Best(
|
||||
altitude=zenith.data.best.record.results.stats.zenith.altitude,
|
||||
global_rank=zenith.data.best.rank,
|
||||
play_at=zenith.data.best.record.ts,
|
||||
)
|
||||
if zenith.data.best.record is not None
|
||||
else None,
|
||||
),
|
||||
zenithex=Zenith(
|
||||
week=Week(
|
||||
altitude=zenithex.data.record.results.stats.zenith.altitude,
|
||||
global_rank=zenithex.data.rank,
|
||||
country_rank=zenithex.data.rank_local,
|
||||
play_at=zenithex.data.record.ts,
|
||||
)
|
||||
if zenithex.data.record is not None
|
||||
else None,
|
||||
best=Best(
|
||||
altitude=zenithex.data.best.record.results.stats.zenith.altitude,
|
||||
global_rank=zenithex.data.best.rank,
|
||||
play_at=zenithex.data.best.record.ts,
|
||||
)
|
||||
if zenithex.data.best.record is not None
|
||||
else None,
|
||||
),
|
||||
statistic=Statistic(
|
||||
total=handling_special_value(user_info.data.gamesplayed),
|
||||
wins=handling_special_value(user_info.data.gameswon),
|
||||
@@ -120,6 +174,7 @@ async def make_query_image_v2(player: Player) -> bytes:
|
||||
sprint=Sprint(
|
||||
time=sprint_value,
|
||||
global_rank=sprint.data.rank,
|
||||
country_rank=sprint.data.rank_local,
|
||||
play_at=sprint.data.record.ts,
|
||||
)
|
||||
if sprint.data.record is not None
|
||||
@@ -127,11 +182,13 @@ async def make_query_image_v2(player: Player) -> bytes:
|
||||
blitz=Blitz(
|
||||
score=blitz.data.record.results.stats.score,
|
||||
global_rank=blitz.data.rank,
|
||||
country_rank=blitz.data.rank_local,
|
||||
play_at=blitz.data.record.ts,
|
||||
)
|
||||
if blitz.data.record is not None
|
||||
else None,
|
||||
zen=Zen(level=zen.data.level, score=zen.data.score),
|
||||
_lang=get_lang(),
|
||||
),
|
||||
),
|
||||
) as page_hash:
|
||||
|
||||
Reference in New Issue
Block a user