Skip to content

Commit

Permalink
🐛 修复潜在的 NoneBot 插件列表读取错误
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyomotoi committed Oct 25, 2024
1 parent 23bf0c9 commit 454a8d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion nb_cli_plugin_webui/app/handlers/plugin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import json
from pathlib import Path
from typing import List, Optional
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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])}]")

0 comments on commit 454a8d2

Please sign in to comment.