From 454a8d26983acce02f188f405aa814932951e887 Mon Sep 17 00:00:00 2001 From: Kyomotoi Date: Fri, 25 Oct 2024 09:16:24 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E6=BD=9C=E5=9C=A8?= =?UTF-8?q?=E7=9A=84=20NoneBot=20=E6=8F=92=E4=BB=B6=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nb_cli_plugin_webui/app/handlers/plugin.py | 9 ++++++++- .../template/scripts/plugin/get_loaded_plugins.py.jinja | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/nb_cli_plugin_webui/app/handlers/plugin.py b/nb_cli_plugin_webui/app/handlers/plugin.py index 6766cd8..4de2208 100644 --- a/nb_cli_plugin_webui/app/handlers/plugin.py +++ b/nb_cli_plugin_webui/app/handlers/plugin.py @@ -1,3 +1,4 @@ +import re import json from pathlib import Path from typing import List, Optional @@ -21,7 +22,13 @@ async def get_nonebot_plugin_list( raw_content = await run_python_script( python_path, await t.render_async(toml_path=config_file), cwd ) - return raw_content.split(",") + + matches = re.findall(r"nonebot_plugins:\[(.*?)\]", raw_content) + result = list() + if matches: + result = matches[0].split(",") + + return result async def get_nonebot_plugin_config_detail( diff --git a/nb_cli_plugin_webui/app/template/scripts/plugin/get_loaded_plugins.py.jinja b/nb_cli_plugin_webui/app/template/scripts/plugin/get_loaded_plugins.py.jinja index 24671d2..b186480 100644 --- a/nb_cli_plugin_webui/app/template/scripts/plugin/get_loaded_plugins.py.jinja +++ b/nb_cli_plugin_webui/app/template/scripts/plugin/get_loaded_plugins.py.jinja @@ -13,4 +13,4 @@ def get_loaded_plugins(toml_path: str): plugins = get_loaded_plugins("{{ toml_path }}") if plugins: - print(",".join([plugin.module_name for plugin in plugins])) + print(f"nonebot_plugins:[{','.join([plugin.module_name for plugin in plugins])}]")