refactor: 统一变量命名并优化代码结构

- 将函数名从 handle_admin_command 改为 admin_command_handler 以保持命名一致性
- 将变量名 comm_prefixes 改为 command_prefixes 以提高可读性
- 重命名 full_cmd 为 command_parts 和 cmd_name 为 command_name 以明确用途
- 简化 WebSocket 相关代码,移除未使用的导入
- 优化 main.py 中的初始化逻辑和变量命名
This commit is contained in:
2026-01-07 23:02:15 +08:00
parent 56b1014419
commit c3b3541694
5 changed files with 39 additions and 41 deletions

View File

@@ -12,7 +12,7 @@ from ..handlers.event_handler import MessageHandler, NoticeHandler, RequestHandl
# 从配置中获取命令前缀
comm_prefixes = global_config.bot.get("command", ("/",))
command_prefixes = global_config.bot.get("command", ("/",))
class CommandManager:
@@ -133,11 +133,11 @@ class CommandManager:
# --- 全局单例 ---
# 确保前缀配置是元组格式
if isinstance(comm_prefixes, list):
comm_prefixes = tuple(comm_prefixes)
elif isinstance(comm_prefixes, str):
comm_prefixes = (comm_prefixes,)
if isinstance(command_prefixes, list):
command_prefixes = tuple(command_prefixes)
elif isinstance(command_prefixes, str):
command_prefixes = (command_prefixes,)
# 实例化全局唯一的命令管理器
matcher = CommandManager(prefixes=comm_prefixes)
matcher = CommandManager(prefixes=command_prefixes)