mirror of
https://github.com/PaiGramTeam/SIMNet.git
synced 2024-11-22 06:17:57 +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 typing import Optional, Mapping, Dict, Any
|
||||||
|
|
||||||
from simnet.client.components.chronicle.base import BaseChronicleClient
|
from simnet.client.components.chronicle.base import BaseChronicleClient
|
||||||
@ -113,8 +114,12 @@ class StarRailBattleChronicleClient(BaseChronicleClient):
|
|||||||
BadRequest: If the request is invalid.
|
BadRequest: If the request is invalid.
|
||||||
DataNotPublic: If the requested data is not public.
|
DataNotPublic: If the requested data is not public.
|
||||||
"""
|
"""
|
||||||
data = await self._request_starrail_record("index", player_id, lang=lang)
|
index_data, basic_info = await asyncio.gather(
|
||||||
return StarRailUserStats(**data)
|
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(
|
async def get_starrail_characters(
|
||||||
self,
|
self,
|
||||||
|
@ -36,5 +36,24 @@ class PartialStarRailUserStats(APIModel):
|
|||||||
characters: List[PartialCharacter] = Field(alias="avatar_list")
|
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):
|
class StarRailUserStats(PartialStarRailUserStats):
|
||||||
"""Complete data of StarRail user, containing statistics and character information."""
|
"""Complete data of StarRail user, containing statistics and character information."""
|
||||||
|
|
||||||
|
info: StarRailUserInfo
|
||||||
|
Loading…
Reference in New Issue
Block a user