From 1fdf3c9e7c2b4ed8c249205e65d5058bc058b553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Fri, 5 Aug 2022 21:22:21 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20=E4=BF=AE=E5=A4=8D=20`get=5Fgens?= =?UTF-8?q?hin=5Fclient`=20=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91=E5=92=8C?= =?UTF-8?q?=E5=BC=95=E7=94=A8=E7=B1=BB=E6=88=90=E5=91=98=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/helpers.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/helpers.py b/utils/helpers.py index 60f913c..2f401e2 100644 --- a/utils/helpers.py +++ b/utils/helpers.py @@ -1,6 +1,6 @@ import hashlib import os -from typing import Union +from typing import Union, Optional import aiofiles 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, - region: RegionEnum = RegionEnum.NULL) -> Client: + region: Optional[RegionEnum] = None) -> Client: user = await user_service.get_user_by_id(user_id) - cookies = await cookies_service.get_cookies(user_id, region) if region is None: region = user.region + cookies = await cookies_service.get_cookies(user_id, region) if region == RegionEnum.HYPERION: 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: 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) else: raise TypeError(f"region is not RegionEnum.NULL")