Daily build
This commit is contained in:
34
base_plugins/help.py
Normal file
34
base_plugins/help.py
Normal file
@@ -0,0 +1,34 @@
|
||||
"""
|
||||
帮助插件
|
||||
|
||||
提供 /help 指令,用于展示所有已加载插件的帮助信息。
|
||||
"""
|
||||
from core.command_manager import matcher
|
||||
from models.events.message import MessageEvent
|
||||
|
||||
__plugin_meta__ = {
|
||||
"name": "帮助",
|
||||
"description": "显示所有可用指令的帮助信息",
|
||||
"usage": "/help",
|
||||
}
|
||||
|
||||
@matcher.command("help")
|
||||
async def help_command(bot, event: MessageEvent):
|
||||
"""
|
||||
处理 /help 指令,生成并发送帮助信息
|
||||
|
||||
:param bot: Bot 实例
|
||||
:param event: 消息事件对象
|
||||
"""
|
||||
help_text = "--- 可用指令列表 ---\n"
|
||||
|
||||
for plugin_name, meta in matcher.plugins.items():
|
||||
name = meta.get("name", "未命名插件")
|
||||
description = meta.get("description", "暂无描述")
|
||||
usage = meta.get("usage", "暂无用法说明")
|
||||
|
||||
help_text += f"\n{name} ({plugin_name}):\n"
|
||||
help_text += f" 功能: {description}\n"
|
||||
help_text += f" 用法: {usage}\n"
|
||||
|
||||
await bot.send(event, help_text.strip())
|
||||
Reference in New Issue
Block a user