diff --git a/GenshinUID/genshinuid_gachalog/__init__.py b/GenshinUID/genshinuid_gachalog/__init__.py index f40a495a..a42623ca 100644 --- a/GenshinUID/genshinuid_gachalog/__init__.py +++ b/GenshinUID/genshinuid_gachalog/__init__.py @@ -22,7 +22,10 @@ async def send_import_gacha_info(bot: Bot, ev: Event): if uid is None: return await bot.send(UID_HINT) if ev.file: - return await bot.send(await import_gachalogs(ev.file, uid)) + await bot.send('正在尝试导入抽卡记录中,请耐心等待……') + return await bot.send( + await import_gachalogs(ev.file, ev.file_type, uid) + ) else: return await bot.send('导入抽卡记录异常...') diff --git a/GenshinUID/genshinuid_gachalog/export_and_import.py b/GenshinUID/genshinuid_gachalog/export_and_import.py index fb3796cd..c5f4efe2 100644 --- a/GenshinUID/genshinuid_gachalog/export_and_import.py +++ b/GenshinUID/genshinuid_gachalog/export_and_import.py @@ -1,4 +1,5 @@ import json +import base64 from datetime import datetime from httpx import get @@ -15,8 +16,12 @@ INT_TO_TYPE = { } -async def import_gachalogs(history_url: str, uid: str) -> str: - history_data: dict = json.loads(get(history_url).text) +async def import_gachalogs(history_url: str, type: str, uid: str) -> str: + if type == 'url': + history_data: dict = json.loads(get(history_url).text) + else: + data_bytes = base64.b64decode(history_url) + history_data = json.loads(data_bytes.decode('gbk')) if 'info' in history_data and 'uid' in history_data['info']: data_uid = history_data['info']['uid'] if data_uid != uid: