mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-30 04:00:31 +08:00
✨ 支持导出抽卡记录
和导入抽卡记录
This commit is contained in:
parent
6cb4817827
commit
08f78df595
@ -6,14 +6,12 @@ from pathlib import Path
|
|||||||
from typing import Any, Dict, List, Tuple, Union, Optional
|
from typing import Any, Dict, List, Tuple, Union, Optional
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
import hoshino
|
||||||
|
from hoshino import Service
|
||||||
from nonebot.log import logger
|
from nonebot.log import logger
|
||||||
from aiohttp import ClientConnectorError
|
from aiohttp import ClientConnectorError
|
||||||
from aiocqhttp.exceptions import ActionFailed
|
from aiocqhttp.exceptions import ActionFailed
|
||||||
from nonebot import MessageSegment, get_bot # type: ignore
|
from nonebot import MessageSegment, get_bot # type: ignore
|
||||||
|
|
||||||
import hoshino
|
|
||||||
from hoshino import Service
|
|
||||||
from hoshino.typing import CQEvent, HoshinoBot, CommandSession # type: ignore
|
|
||||||
from hoshino.util import (
|
from hoshino.util import (
|
||||||
FreqLimiter,
|
FreqLimiter,
|
||||||
pic2b64,
|
pic2b64,
|
||||||
@ -21,6 +19,12 @@ from hoshino.util import (
|
|||||||
concat_pic,
|
concat_pic,
|
||||||
filt_message,
|
filt_message,
|
||||||
)
|
)
|
||||||
|
from hoshino.typing import ( # type: ignore
|
||||||
|
CQEvent,
|
||||||
|
HoshinoBot,
|
||||||
|
NoticeSession,
|
||||||
|
CommandSession,
|
||||||
|
)
|
||||||
|
|
||||||
from .utils.db_operation.db_operation import select_db
|
from .utils.db_operation.db_operation import select_db
|
||||||
from .utils.message.get_image_and_at import ImageAndAt
|
from .utils.message.get_image_and_at import ImageAndAt
|
||||||
|
@ -4,7 +4,51 @@ from .draw_gachalogs import draw_gachalogs_img
|
|||||||
from ..utils.db_operation.db_operation import select_db
|
from ..utils.db_operation.db_operation import select_db
|
||||||
from ..utils.message.get_image_and_at import ImageAndAt
|
from ..utils.message.get_image_and_at import ImageAndAt
|
||||||
from ..utils.message.error_reply import * # noqa: F403,F401
|
from ..utils.message.error_reply import * # noqa: F403,F401
|
||||||
from ..utils.mhy_api.get_mhy_data import get_gacha_log_by_authkey
|
from .export_and_import import export_gachalogs, import_gachalogs
|
||||||
|
|
||||||
|
|
||||||
|
@sv.on_notice()
|
||||||
|
async def import_gacha_log_info(session: NoticeSession):
|
||||||
|
ev = session.event
|
||||||
|
if ev['notice_type'] != 'offline_file':
|
||||||
|
return
|
||||||
|
url = ev['file']['url']
|
||||||
|
name: str = ev['file']['name']
|
||||||
|
if not name.endswith('.json'):
|
||||||
|
return
|
||||||
|
qid = ev['user_id']
|
||||||
|
uid = await select_db(qid, mode='uid')
|
||||||
|
if not isinstance(uid, str) or '未找到绑定的UID' in uid:
|
||||||
|
await session.send(UID_HINT)
|
||||||
|
return
|
||||||
|
logger.info('开始执行[导入抽卡记录]')
|
||||||
|
im = await import_gachalogs(url, uid)
|
||||||
|
await session.send(im, at_sender=True)
|
||||||
|
|
||||||
|
|
||||||
|
@sv.on_fullmatch('导出抽卡记录')
|
||||||
|
async def export_gacha_log_info(bot: HoshinoBot, ev: CQEvent):
|
||||||
|
logger.info('开始执行[导出抽卡记录]')
|
||||||
|
qid = int(ev.sender['user_id'])
|
||||||
|
gid = int(ev.group_id)
|
||||||
|
uid = await select_db(qid, mode='uid')
|
||||||
|
bot = get_bot()
|
||||||
|
if not isinstance(uid, str) or '未找到绑定的UID' in uid:
|
||||||
|
await bot.send(ev, UID_HINT)
|
||||||
|
return
|
||||||
|
raw_data = await export_gachalogs(uid)
|
||||||
|
if raw_data['retcode'] == 'ok':
|
||||||
|
await bot.call_action(
|
||||||
|
action='upload_group_file',
|
||||||
|
group_id=gid,
|
||||||
|
name=raw_data['name'],
|
||||||
|
file=raw_data['url'],
|
||||||
|
)
|
||||||
|
logger.info(f'[导出抽卡记录] UID{uid}成功!')
|
||||||
|
await bot.send(ev, '上传成功!')
|
||||||
|
else:
|
||||||
|
logger.warning(f'[导出抽卡记录] UID{uid}失败!')
|
||||||
|
await bot.send(ev, '导出抽卡记录失败!')
|
||||||
|
|
||||||
|
|
||||||
@sv.on_fullmatch('抽卡记录')
|
@sv.on_fullmatch('抽卡记录')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user