mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-25 18:04:10 +00:00
🔧 修复 get_genshin_client
判断逻辑和引用类成员错误问题
This commit is contained in:
parent
3601ccdb4c
commit
1fdf3c9e7c
@ -1,6 +1,6 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
import os
|
import os
|
||||||
from typing import Union
|
from typing import Union, Optional
|
||||||
|
|
||||||
import aiofiles
|
import aiofiles
|
||||||
import genshin
|
import genshin
|
||||||
@ -61,17 +61,17 @@ async def url_to_file(url: str, prefix: str = "file://") -> str:
|
|||||||
|
|
||||||
|
|
||||||
async def get_genshin_client(user_id: int, user_service: UserService, cookies_service: CookiesService,
|
async def get_genshin_client(user_id: int, user_service: UserService, cookies_service: CookiesService,
|
||||||
region: RegionEnum = RegionEnum.NULL) -> Client:
|
region: Optional[RegionEnum] = None) -> Client:
|
||||||
user = await user_service.get_user_by_id(user_id)
|
user = await user_service.get_user_by_id(user_id)
|
||||||
cookies = await cookies_service.get_cookies(user_id, region)
|
|
||||||
if region is None:
|
if region is None:
|
||||||
region = user.region
|
region = user.region
|
||||||
|
cookies = await cookies_service.get_cookies(user_id, region)
|
||||||
if region == RegionEnum.HYPERION:
|
if region == RegionEnum.HYPERION:
|
||||||
uid = user.yuanshen_uid
|
uid = user.yuanshen_uid
|
||||||
client = genshin.Client(cookies=cookies, game=types.Game.GENSHIN, region=types.Region.CHINESE, uid=uid)
|
client = genshin.Client(cookies=cookies.cookies, game=types.Game.GENSHIN, region=types.Region.CHINESE, uid=uid)
|
||||||
elif region == RegionEnum.HOYOLAB:
|
elif region == RegionEnum.HOYOLAB:
|
||||||
uid = user.genshin_uid
|
uid = user.genshin_uid
|
||||||
client = genshin.Client(cookies=cookies,
|
client = genshin.Client(cookies=cookies.cookies,
|
||||||
game=types.Game.GENSHIN, region=types.Region.OVERSEAS, lang="zh-cn", uid=uid)
|
game=types.Game.GENSHIN, region=types.Region.OVERSEAS, lang="zh-cn", uid=uid)
|
||||||
else:
|
else:
|
||||||
raise TypeError(f"region is not RegionEnum.NULL")
|
raise TypeError(f"region is not RegionEnum.NULL")
|
||||||
|
Loading…
Reference in New Issue
Block a user