From 33d133417475d2191ba1bbe837989ee2fd499e4e Mon Sep 17 00:00:00 2001 From: HibiKier <775757368@qq.com> Date: Sat, 21 May 2022 19:33:39 +0800 Subject: [PATCH] fix what_anime --- plugins/what_anime/__init__.py | 11 +++++++---- pyproject.toml | 1 - 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/what_anime/__init__.py b/plugins/what_anime/__init__.py index 79955442..bae70bd2 100755 --- a/plugins/what_anime/__init__.py +++ b/plugins/what_anime/__init__.py @@ -1,5 +1,6 @@ from nonebot.adapters.onebot.v11 import MessageEvent, GroupMessageEvent, Message, Bot -from nonebot.internal.params import ArgStr +from nonebot.internal.params import ArgStr, Arg +from nonebot.params import CommandArg from .data_source import get_anime from nonebot import on_command @@ -32,16 +33,18 @@ what_anime = on_command("识番", priority=5, block=True) @what_anime.handle() -async def _(bot: Bot, event: MessageEvent, state: T_State): +async def _(bot: Bot, event: MessageEvent, state: T_State, args: Message = CommandArg()): img_url = get_message_img(event.json()) if img_url: - state["img_url"] = img_url[0] + state["img_url"] = args @what_anime.got("img_url", prompt="虚空识番?来图来图GKD") -async def _(bot: Bot, event: MessageEvent, state: T_State, img_url: str = ArgStr("img_url")): +async def _(bot: Bot, event: MessageEvent, state: T_State, img_url: Message = Arg("img_url")): + img_url = get_message_img(img_url) if not img_url: await what_anime.reject_arg("img_url", "发送的必须是图片!") + img_url = img_url[0] await what_anime.send("开始识别.....") anime_data_report = await get_anime(img_url) if anime_data_report: diff --git a/pyproject.toml b/pyproject.toml index dbb98349..d7900df9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,6 @@ url = "https://mirrors.aliyun.com/pypi/simple/" python = "^3.8" nonebot2 = "^2.0.0-beta.2" nonebot-adapter-onebot = "^2.0.0-beta.1" -bilibili-api = "^9.1.0" aiofiles = "^0.8.0" aiohttp = "3.7.4.post0" beautifulsoup4 = "4.9.3"