mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-08 21:15:52 +08:00
✨ 支持url和base64的导入抽卡记录
(#487)
This commit is contained in:
parent
a22a3915ce
commit
1bc7bd9609
@ -22,7 +22,10 @@ async def send_import_gacha_info(bot: Bot, ev: Event):
|
|||||||
if uid is None:
|
if uid is None:
|
||||||
return await bot.send(UID_HINT)
|
return await bot.send(UID_HINT)
|
||||||
if ev.file:
|
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:
|
else:
|
||||||
return await bot.send('导入抽卡记录异常...')
|
return await bot.send('导入抽卡记录异常...')
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import json
|
import json
|
||||||
|
import base64
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from httpx import get
|
from httpx import get
|
||||||
@ -15,8 +16,12 @@ INT_TO_TYPE = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def import_gachalogs(history_url: str, uid: str) -> str:
|
async def import_gachalogs(history_url: str, type: str, uid: str) -> str:
|
||||||
history_data: dict = json.loads(get(history_url).text)
|
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']:
|
if 'info' in history_data and 'uid' in history_data['info']:
|
||||||
data_uid = history_data['info']['uid']
|
data_uid = history_data['info']['uid']
|
||||||
if data_uid != uid:
|
if data_uid != uid:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user