mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-16 03:55:26 +00:00
🐛 Fix relic not exists raise AttributeError
Co-authored-by: 洛水居室 <luoshuijs@outlook.com>
This commit is contained in:
parent
904d9537d3
commit
6a7d2fff19
@ -96,13 +96,13 @@ class PublicCookiesService(BaseService):
|
||||
raise RuntimeError("account_id not found")
|
||||
record_cards = await client.get_record_cards()
|
||||
for record_card in record_cards:
|
||||
if record_card.game == Game.GENSHIN:
|
||||
if record_card.game == Game.STARRAIL:
|
||||
await client.get_starrail_user(record_card.uid)
|
||||
break
|
||||
else:
|
||||
accounts = await client.get_game_accounts()
|
||||
for account in accounts:
|
||||
if account.game == Game.GENSHIN:
|
||||
if account.game == Game.STARRAIL:
|
||||
await client.get_starrail_user(account.uid)
|
||||
break
|
||||
except InvalidCookies as exc:
|
||||
|
@ -1,7 +1,7 @@
|
||||
from typing import List, Dict, Optional
|
||||
|
||||
from modules.wiki.base import WikiModel
|
||||
from modules.wiki.models.avatar import Avatar
|
||||
from modules.wiki.models.avatar import YattaAvatar
|
||||
|
||||
|
||||
class Character(WikiModel):
|
||||
@ -10,9 +10,9 @@ class Character(WikiModel):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.all_avatars: List[Avatar] = []
|
||||
self.all_avatars_map: Dict[int, Avatar] = {}
|
||||
self.all_avatars_name: Dict[str, Avatar] = {}
|
||||
self.all_avatars: List[YattaAvatar] = []
|
||||
self.all_avatars_map: Dict[int, YattaAvatar] = {}
|
||||
self.all_avatars_name: Dict[str, YattaAvatar] = {}
|
||||
|
||||
def clear_class_data(self) -> None:
|
||||
self.all_avatars.clear()
|
||||
@ -31,15 +31,15 @@ class Character(WikiModel):
|
||||
datas = await WikiModel.read(self.avatar_path)
|
||||
self.clear_class_data()
|
||||
for data in datas:
|
||||
m = Avatar(**data)
|
||||
m = YattaAvatar(**data)
|
||||
self.all_avatars.append(m)
|
||||
self.all_avatars_map[m.id] = m
|
||||
self.all_avatars_name[m.name] = m
|
||||
|
||||
def get_by_id(self, cid: int) -> Optional[Avatar]:
|
||||
def get_by_id(self, cid: int) -> Optional[YattaAvatar]:
|
||||
return self.all_avatars_map.get(cid)
|
||||
|
||||
def get_by_name(self, name: str) -> Optional[Avatar]:
|
||||
def get_by_name(self, name: str) -> Optional[YattaAvatar]:
|
||||
return self.all_avatars_name.get(name)
|
||||
|
||||
def get_name_list(self) -> List[str]:
|
||||
|
@ -1,60 +1,68 @@
|
||||
from typing import List
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
from .enums import Quality, Destiny, Element
|
||||
from .material import Material
|
||||
|
||||
from .enums import Destiny, Element
|
||||
|
||||
|
||||
class AvatarInfo(BaseModel):
|
||||
occupation: str = ""
|
||||
"""所属"""
|
||||
faction: str = ""
|
||||
"""派系"""
|
||||
class YattaAvatarPath(BaseModel):
|
||||
id: str
|
||||
name: str
|
||||
|
||||
|
||||
class AvatarItem(BaseModel):
|
||||
item: Material
|
||||
"""物品"""
|
||||
count: int
|
||||
"""数量"""
|
||||
class YattaAvatarTypes(BaseModel):
|
||||
pathType: YattaAvatarPath
|
||||
combatType: YattaAvatarPath
|
||||
|
||||
|
||||
class AvatarPromote(BaseModel):
|
||||
required_level: int
|
||||
"""突破所需等级"""
|
||||
promote_level: int = 0
|
||||
"""突破等级"""
|
||||
max_level: int
|
||||
"""解锁的等级上限"""
|
||||
|
||||
coin: int = 0
|
||||
"""信用点"""
|
||||
items: List[AvatarItem]
|
||||
"""突破所需材料"""
|
||||
class YattaAvatarCV(BaseModel):
|
||||
CV_CN: str
|
||||
CV_JP: str
|
||||
CV_KR: str
|
||||
CV_EN: str
|
||||
|
||||
|
||||
class AvatarSoul(BaseModel):
|
||||
class YattaAvatarFetter(BaseModel):
|
||||
faction: Optional[str]
|
||||
description: Optional[str]
|
||||
cv: Optional[YattaAvatarCV]
|
||||
|
||||
|
||||
class YattaAvatarEidolon(BaseModel):
|
||||
id: int
|
||||
rank: int
|
||||
name: Optional[str]
|
||||
description: Optional[str]
|
||||
icon: str
|
||||
|
||||
@property
|
||||
def icon_url(self) -> str:
|
||||
return f"https://api.yatta.top/hsr/assets/UI/skill/{self.icon}.png"
|
||||
|
||||
|
||||
class YattaAvatar(BaseModel):
|
||||
id: int
|
||||
""" 角色ID """
|
||||
name: str
|
||||
""" 名称 """
|
||||
desc: str
|
||||
""" 介绍 """
|
||||
|
||||
|
||||
class Avatar(BaseModel):
|
||||
id: int
|
||||
"""角色ID"""
|
||||
name: str
|
||||
"""名称"""
|
||||
rank: int
|
||||
""" 星级 """
|
||||
types: YattaAvatarTypes
|
||||
""" 角色类型 """
|
||||
icon: str
|
||||
"""图标"""
|
||||
quality: Quality
|
||||
"""品质"""
|
||||
destiny: Destiny
|
||||
"""命途"""
|
||||
element: Element
|
||||
"""属性"""
|
||||
information: AvatarInfo
|
||||
"""角色信息"""
|
||||
promote: List[AvatarPromote]
|
||||
"""角色突破数据"""
|
||||
soul: List[AvatarSoul]
|
||||
"""角色星魂数据"""
|
||||
""" 图标 """
|
||||
release: int
|
||||
""" 上线时间 """
|
||||
route: str
|
||||
fetter: YattaAvatarFetter
|
||||
eidolons: List[YattaAvatarEidolon]
|
||||
|
||||
@property
|
||||
def destiny(self) -> Destiny:
|
||||
"""命途"""
|
||||
return Destiny(self.types.pathType.name)
|
||||
|
||||
@property
|
||||
def element(self) -> Element:
|
||||
"""属性"""
|
||||
return Element(self.types.combatType.name)
|
||||
|
@ -12,7 +12,6 @@ class AvatarConfig(BaseModel):
|
||||
AvatarID: int
|
||||
AvatarName: AvatarName
|
||||
AvatarVOTag: str
|
||||
Release: bool
|
||||
|
||||
|
||||
class AvatarIcon(BaseModel):
|
||||
|
@ -550,4 +550,5 @@ class RenderTemplate:
|
||||
substat_scores=[substat_score(s) for s in self.client.get_affix(e, False)],
|
||||
)
|
||||
for e in relic_list
|
||||
if self.client.get_affix_by_id(e.tid) is not None
|
||||
]
|
||||
|
@ -1,6 +1,7 @@
|
||||
from typing import Tuple, Optional
|
||||
|
||||
from simnet import Region
|
||||
from simnet.client.cookies import Cookies
|
||||
from simnet.errors import BadRequest as SIMNetBadRequest
|
||||
|
||||
from core.basemodel import RegionEnum
|
||||
@ -104,7 +105,7 @@ class ChallengeSystem(Plugin):
|
||||
_, challenge = await self.get_challenge(player.player_id)
|
||||
if challenge is None:
|
||||
raise ChallengeSystemException("验证失效 请求已经过期")
|
||||
verify = Verify(cookies=cookie_model.data)
|
||||
verify = Verify(cookies=Cookies(cookie_model.data))
|
||||
try:
|
||||
await verify.verify(challenge=challenge, validate=validate)
|
||||
except ResponseException as exc:
|
||||
|
Loading…
Reference in New Issue
Block a user