2022-02-19 18:20:19 +08:00
|
|
|
|
from nonebot.adapters.onebot.v11 import MessageEvent, GroupMessageEvent, Message, Bot
|
2022-05-21 19:33:39 +08:00
|
|
|
|
from nonebot.internal.params import ArgStr, Arg
|
|
|
|
|
|
from nonebot.params import CommandArg
|
2022-05-21 16:39:06 +08:00
|
|
|
|
|
2021-05-20 19:25:51 +08:00
|
|
|
|
from .data_source import get_anime
|
|
|
|
|
|
from nonebot import on_command
|
|
|
|
|
|
from nonebot.typing import T_State
|
2022-01-16 14:52:50 +08:00
|
|
|
|
from utils.utils import get_message_img
|
2021-05-20 19:25:51 +08:00
|
|
|
|
from services.log import logger
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-10-03 14:24:07 +08:00
|
|
|
|
__zx_plugin_name__ = "识番"
|
|
|
|
|
|
__plugin_usage__ = """
|
|
|
|
|
|
usage:
|
|
|
|
|
|
api.trace.moe 以图识番
|
|
|
|
|
|
指令:
|
|
|
|
|
|
识番 [图片]
|
2021-05-20 19:25:51 +08:00
|
|
|
|
""".strip()
|
2021-10-03 14:24:07 +08:00
|
|
|
|
__plugin_des__ = "以图识番"
|
|
|
|
|
|
__plugin_cmd__ = ["识番 [图片]"]
|
2021-11-04 16:11:50 +08:00
|
|
|
|
__plugin_type__ = ("一些工具",)
|
2021-10-03 14:24:07 +08:00
|
|
|
|
__plugin_version__ = 0.1
|
|
|
|
|
|
__plugin_author__ = "HibiKier"
|
|
|
|
|
|
__plugin_settings__ = {
|
|
|
|
|
|
"level": 5,
|
|
|
|
|
|
"default_status": True,
|
|
|
|
|
|
"limit_superuser": False,
|
|
|
|
|
|
"cmd": ["识番"],
|
|
|
|
|
|
}
|
2021-05-20 19:25:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
2021-07-30 21:21:51 +08:00
|
|
|
|
what_anime = on_command("识番", priority=5, block=True)
|
2021-05-20 19:25:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@what_anime.handle()
|
2022-05-21 19:33:39 +08:00
|
|
|
|
async def _(bot: Bot, event: MessageEvent, state: T_State, args: Message = CommandArg()):
|
2022-01-16 14:52:50 +08:00
|
|
|
|
img_url = get_message_img(event.json())
|
2021-05-20 19:25:51 +08:00
|
|
|
|
if img_url:
|
2022-05-21 19:33:39 +08:00
|
|
|
|
state["img_url"] = args
|
2021-05-20 19:25:51 +08:00
|
|
|
|
|
|
|
|
|
|
|
2021-07-30 21:21:51 +08:00
|
|
|
|
@what_anime.got("img_url", prompt="虚空识番?来图来图GKD")
|
2022-05-21 19:33:39 +08:00
|
|
|
|
async def _(bot: Bot, event: MessageEvent, state: T_State, img_url: Message = Arg("img_url")):
|
|
|
|
|
|
img_url = get_message_img(img_url)
|
2022-02-19 18:20:19 +08:00
|
|
|
|
if not img_url:
|
|
|
|
|
|
await what_anime.reject_arg("img_url", "发送的必须是图片!")
|
2022-05-21 19:33:39 +08:00
|
|
|
|
img_url = img_url[0]
|
2021-07-30 21:21:51 +08:00
|
|
|
|
await what_anime.send("开始识别.....")
|
2021-05-20 19:25:51 +08:00
|
|
|
|
anime_data_report = await get_anime(img_url)
|
|
|
|
|
|
if anime_data_report:
|
|
|
|
|
|
await what_anime.send(anime_data_report, at_sender=True)
|
2021-07-30 21:21:51 +08:00
|
|
|
|
logger.info(
|
|
|
|
|
|
f"USER {event.user_id} GROUP "
|
|
|
|
|
|
f"{event.group_id if isinstance(event, GroupMessageEvent) else 'private'}"
|
|
|
|
|
|
f" 识番 {img_url} --> {anime_data_report}"
|
|
|
|
|
|
)
|
2021-05-20 19:25:51 +08:00
|
|
|
|
else:
|
2021-07-30 21:21:51 +08:00
|
|
|
|
logger.info(
|
|
|
|
|
|
f"USER {event.user_id} GROUP "
|
2022-02-19 18:20:19 +08:00
|
|
|
|
f"{event.group_id if isinstance(event, GroupMessageEvent) else 'private'} 识番 {img_url} 未找到"
|
2021-07-30 21:21:51 +08:00
|
|
|
|
)
|
2021-05-20 19:25:51 +08:00
|
|
|
|
await what_anime.send(f"没有寻找到该番剧,果咩..", at_sender=True)
|