mirror of
https://github.com/PaiGramTeam/MibooGram.git
synced 2024-11-25 09:37:38 +00:00
🐛 Fix token v2 parse
This commit is contained in:
parent
330b1ff1bb
commit
3295afa8f5
@ -81,6 +81,11 @@ class CookiesModel(BaseModel):
|
|||||||
if self.ltuid is None and self.ltoken:
|
if self.ltuid is None and self.ltoken:
|
||||||
self.ltuid = user_id
|
self.ltuid = user_id
|
||||||
|
|
||||||
|
def set_by_dict(self, new_cookies: dict):
|
||||||
|
for key, value in new_cookies.items():
|
||||||
|
if hasattr(self, key) and value is not None:
|
||||||
|
setattr(self, key, value)
|
||||||
|
|
||||||
def check(self) -> bool:
|
def check(self) -> bool:
|
||||||
"""检查Cookies是否完整
|
"""检查Cookies是否完整
|
||||||
:return: 成功返回 True 失败返回 False
|
:return: 成功返回 True 失败返回 False
|
||||||
|
@ -268,10 +268,7 @@ class AccountCookiesPlugin(Plugin.Conversation):
|
|||||||
logger.success("用户 %s[%s] 绑定时获取 ltoken 成功", user.full_name, user.id)
|
logger.success("用户 %s[%s] 绑定时获取 ltoken 成功", user.full_name, user.id)
|
||||||
else:
|
else:
|
||||||
cookies_model = await client.get_all_token_by_stoken(cookies.stoken, cookies.account_id)
|
cookies_model = await client.get_all_token_by_stoken(cookies.stoken, cookies.account_id)
|
||||||
cookies.stoken = cookies_model.stoken
|
cookies.set_by_dict(cookies_model.dict())
|
||||||
cookies.mid = cookies_model.mid
|
|
||||||
cookies.ltoken = cookies_model.ltoken
|
|
||||||
cookies.cookie_token = cookies_model.cookie_token
|
|
||||||
logger.success(
|
logger.success(
|
||||||
"用户 %s[%s] 绑定时获取 stoken_v2, mid, ltoken, cookie_token 成功", user.full_name, user.id
|
"用户 %s[%s] 绑定时获取 stoken_v2, mid, ltoken, cookie_token 成功", user.full_name, user.id
|
||||||
)
|
)
|
||||||
@ -398,6 +395,7 @@ class AccountCookiesPlugin(Plugin.Conversation):
|
|||||||
async def update_player(self, uid: int, genshin_account: Account, region: RegionEnum, account_id: int):
|
async def update_player(self, uid: int, genshin_account: Account, region: RegionEnum, account_id: int):
|
||||||
player = await self.players_service.get(uid, player_id=genshin_account.uid, region=region)
|
player = await self.players_service.get(uid, player_id=genshin_account.uid, region=region)
|
||||||
if player:
|
if player:
|
||||||
|
if player.account_id != account_id:
|
||||||
player.account_id = account_id
|
player.account_id = account_id
|
||||||
await self.players_service.update(player)
|
await self.players_service.update(player)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user