diff options
-rw-r--r-- | ATRI/plugins/help/__init__.py | 21 | ||||
-rw-r--r-- | ATRI/plugins/help/data_source.py | 5 | ||||
-rw-r--r-- | ATRI/plugins/saucenao/data_source.py | 10 |
3 files changed, 20 insertions, 16 deletions
diff --git a/ATRI/plugins/help/__init__.py b/ATRI/plugins/help/__init__.py index cac7038..74cb00d 100644 --- a/ATRI/plugins/help/__init__.py +++ b/ATRI/plugins/help/__init__.py @@ -1,10 +1,9 @@ from nonebot.adapters.onebot.v11 import MessageEvent -from ATRI.rule import to_bot from .data_source import Helper -main_help = Helper().on_command("菜单", "获取食用bot的方法", rule=to_bot(), aliases={"menu"}) +main_help = Helper().on_command("菜单", "获取食用bot的方法", aliases={"menu"}) @main_help.handle() @@ -13,7 +12,7 @@ async def _main_help(): await main_help.finish(repo) -about_me = Helper().on_command("关于", "获取关于bot的信息", rule=to_bot(), aliases={"about"}) +about_me = Helper().on_command("关于", "获取关于bot的信息", aliases={"about"}) @about_me.handle() @@ -22,7 +21,7 @@ async def _about_me(): await about_me.finish(repo) -service_list = Helper().on_command("服务列表", "查看所有可用服务", rule=to_bot(), aliases={"功能列表"}) +service_list = Helper().on_command("服务列表", "查看所有可用服务", aliases={"功能列表"}) @service_list.handle() @@ -31,22 +30,26 @@ async def _service_list(): await service_list.finish(repo) -service_info = Helper().on_command("帮助", "获取服务详细帮助", aliases={"help"}, rule=to_bot()) +service_info = Helper().on_command("帮助", "获取服务详细帮助", aliases={"help"}) @service_info.handle() async def _ready_service_info(event: MessageEvent): msg = str(event.get_message()).split(" ") - service = msg[0] + try: + service = msg[1] + except: + service = "idk" + try: cmd = msg[2] - except BaseException: - cmd = str() + except Exception: + cmd = None if not cmd: repo = Helper().service_info(service) await service_info.finish(repo) - + repo = Helper().cmd_info(service, cmd) await service_info.finish(repo) diff --git a/ATRI/plugins/help/data_source.py b/ATRI/plugins/help/data_source.py index 42b8184..de07678 100644 --- a/ATRI/plugins/help/data_source.py +++ b/ATRI/plugins/help/data_source.py @@ -1,6 +1,7 @@ import os from ATRI import __version__ +from ATRI.rule import to_bot from ATRI.service import Service, SERVICES_DIR, ServiceTools from ATRI.config import BotSelfConfig from ATRI.exceptions import ReadFileError @@ -25,7 +26,7 @@ COMMAND_INFO_FORMAT = """ class Helper(Service): def __init__(self): - Service.__init__(self, "帮助", "bot的食用指南~") + Service.__init__(self, "帮助", "bot的食用指南~", rule=to_bot()) @staticmethod def menu() -> str: @@ -69,7 +70,7 @@ class Helper(Service): try: data = ServiceTools().load_service(service) except ReadFileError: - return "请检查是否输入错误呢..." + return "请检查是否输入错误呢...@bot 帮助 [服务]" service_name = data.get("service", "error") service_docs = data.get("docs", "error") diff --git a/ATRI/plugins/saucenao/data_source.py b/ATRI/plugins/saucenao/data_source.py index ebd4779..08ba64e 100644 --- a/ATRI/plugins/saucenao/data_source.py +++ b/ATRI/plugins/saucenao/data_source.py @@ -44,7 +44,10 @@ class SaouceNao(Service): async def search(self, url: str) -> str: data = await self._request(url) - res = data["results"] + try: + res = data["result"] + except: + return "没有相似的结果呢..." result = list() for i in range(3): @@ -67,7 +70,4 @@ class SaouceNao(Service): f"URL: {i['url'].replace('https://', '')}" ) - if not result: - return "没有相似的结果呢..." - else: - return msg0 + return msg0 |