LiteyukiBot-TriM/src/plugins/liteyuki_plugin_npm/manager.py

23 lines
788 B
Python
Raw Normal View History

2024-03-18 18:21:56 +08:00
import nonebot.plugin
from nonebot import on_command
2024-03-19 00:27:40 +08:00
from nonebot.permission import SUPERUSER
2024-03-18 18:21:56 +08:00
from src.utils.adapter import MessageEvent
from src.utils.language import get_user_lang
list_plugins = on_command("list-plugin", aliases={"列出插件"}, priority=0)
toggle_plugin = on_command("enable-plugin", aliases={"启用插件", "禁用插件", "disable-plugin"}, priority=0)
@list_plugins.handle()
async def _(event: MessageEvent):
2024-03-19 00:27:40 +08:00
lang = get_user_lang(str(event.user_id))
reply = lang.get("npm.loaded_plugins")
2024-03-18 18:21:56 +08:00
for plugin in nonebot.get_loaded_plugins():
2024-03-19 00:27:40 +08:00
# 检查是否有 metadata 属性
if plugin.metadata:
reply += f"\n- {plugin.metadata.name}"
else:
reply += f"\n- {plugin.name}"
2024-03-18 18:21:56 +08:00
await list_plugins.finish(reply)