更新/help指令,现在会发送图片
This commit is contained in:
@@ -5,11 +5,14 @@
|
|||||||
它通过装饰器模式,为插件提供了注册消息指令、通知事件处理器和
|
它通过装饰器模式,为插件提供了注册消息指令、通知事件处理器和
|
||||||
请求事件处理器的能力。
|
请求事件处理器的能力。
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import Any, Callable, Dict, Optional, Tuple
|
from typing import Any, Callable, Dict, Optional, Tuple
|
||||||
|
|
||||||
|
from models.events.message import MessageSegment
|
||||||
|
|
||||||
from ..config_loader import global_config
|
from ..config_loader import global_config
|
||||||
from ..handlers.event_handler import MessageHandler, NoticeHandler, RequestHandler
|
from ..handlers.event_handler import MessageHandler, NoticeHandler, RequestHandler
|
||||||
|
from .help_pic import help_pic
|
||||||
|
|
||||||
# 从配置中获取命令前缀
|
# 从配置中获取命令前缀
|
||||||
_config_prefixes = global_config.bot.command
|
_config_prefixes = global_config.bot.command
|
||||||
@@ -109,7 +112,7 @@ class CommandManager:
|
|||||||
self,
|
self,
|
||||||
*names: str,
|
*names: str,
|
||||||
permission: Optional[Any] = None,
|
permission: Optional[Any] = None,
|
||||||
override_permission_check: bool = False
|
override_permission_check: bool = False,
|
||||||
) -> Callable:
|
) -> Callable:
|
||||||
"""
|
"""
|
||||||
装饰器:注册一个消息指令处理器。
|
装饰器:注册一个消息指令处理器。
|
||||||
@@ -117,7 +120,7 @@ class CommandManager:
|
|||||||
return self.message_handler.command(
|
return self.message_handler.command(
|
||||||
*names,
|
*names,
|
||||||
permission=permission,
|
permission=permission,
|
||||||
override_permission_check=override_permission_check
|
override_permission_check=override_permission_check,
|
||||||
)
|
)
|
||||||
|
|
||||||
def on_notice(self, notice_type: Optional[str] = None) -> Callable:
|
def on_notice(self, notice_type: Optional[str] = None) -> Callable:
|
||||||
@@ -140,8 +143,12 @@ class CommandManager:
|
|||||||
|
|
||||||
根据事件的 `post_type` 将其分发给对应的处理器。
|
根据事件的 `post_type` 将其分发给对应的处理器。
|
||||||
"""
|
"""
|
||||||
if event.post_type == 'message' and global_config.bot.ignore_self_message:
|
if event.post_type == "message" and global_config.bot.ignore_self_message:
|
||||||
if hasattr(event, 'user_id') and hasattr(event, 'self_id') and event.user_id == event.self_id:
|
if (
|
||||||
|
hasattr(event, "user_id")
|
||||||
|
and hasattr(event, "self_id")
|
||||||
|
and event.user_id == event.self_id
|
||||||
|
):
|
||||||
return
|
return
|
||||||
|
|
||||||
handler = self.handler_map.get(event.post_type)
|
handler = self.handler_map.get(event.post_type)
|
||||||
@@ -165,9 +172,9 @@ class CommandManager:
|
|||||||
help_text += f" 功能: {description}\n"
|
help_text += f" 功能: {description}\n"
|
||||||
help_text += f" 用法: {usage}\n"
|
help_text += f" 用法: {usage}\n"
|
||||||
|
|
||||||
await bot.send(event, help_text.strip())
|
await bot.send(event, MessageSegment.image(help_pic))
|
||||||
|
# await bot.send(event, help_text.strip())
|
||||||
|
|
||||||
|
|
||||||
# 实例化全局唯一的命令管理器
|
# 实例化全局唯一的命令管理器
|
||||||
matcher = CommandManager(prefixes=_final_prefixes)
|
matcher = CommandManager(prefixes=_final_prefixes)
|
||||||
|
|
||||||
|
|||||||
1
core/managers/help_pic.py
Normal file
1
core/managers/help_pic.py
Normal file
File diff suppressed because one or more lines are too long
BIN
plugins/resource/help.png
Normal file
BIN
plugins/resource/help.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 51 KiB |
Reference in New Issue
Block a user