mirror of
https://github.com/PaiGramTeam/SIMNet.git
synced 2024-11-21 21:58:05 +00:00
✨ Support starrail user base info
This commit is contained in:
parent
88466950fe
commit
dea36a405f
@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
from typing import Optional, Mapping, Dict, Any
|
||||
|
||||
from simnet.client.components.chronicle.base import BaseChronicleClient
|
||||
@ -113,8 +114,12 @@ class StarRailBattleChronicleClient(BaseChronicleClient):
|
||||
BadRequest: If the request is invalid.
|
||||
DataNotPublic: If the requested data is not public.
|
||||
"""
|
||||
data = await self._request_starrail_record("index", player_id, lang=lang)
|
||||
return StarRailUserStats(**data)
|
||||
index_data, basic_info = await asyncio.gather(
|
||||
self._request_starrail_record("index", player_id, lang=lang),
|
||||
self._request_starrail_record("role/basicInfo", player_id, lang=lang),
|
||||
)
|
||||
index_data["info"] = basic_info
|
||||
return StarRailUserStats(**index_data)
|
||||
|
||||
async def get_starrail_characters(
|
||||
self,
|
||||
|
@ -36,5 +36,24 @@ class PartialStarRailUserStats(APIModel):
|
||||
characters: List[PartialCharacter] = Field(alias="avatar_list")
|
||||
|
||||
|
||||
class StarRailUserInfo(APIModel):
|
||||
"""
|
||||
Information of StarRail user.
|
||||
|
||||
Attributes:
|
||||
nickname (str): User's nickname.
|
||||
server (str): User's server.
|
||||
level (int): User's level.
|
||||
avatar (str): User's avatar url.
|
||||
"""
|
||||
|
||||
nickname: str
|
||||
server: str = Field(alias="region")
|
||||
level: int
|
||||
avatar: str
|
||||
|
||||
|
||||
class StarRailUserStats(PartialStarRailUserStats):
|
||||
"""Complete data of StarRail user, containing statistics and character information."""
|
||||
|
||||
info: StarRailUserInfo
|
||||
|
Loading…
Reference in New Issue
Block a user