feat: 添加测试用例并优化代码结构

refactor(permission_manager): 调整初始化顺序和逻辑
fix(admin_manager): 修复初始化逻辑和目录创建问题
feat(ws): 优化Bot实例初始化条件
feat(message): 增强MessageSegment功能并添加测试
feat(events): 支持字符串格式的消息解析
test: 添加核心功能测试用例
refactor(plugin_manager): 改进插件路径处理
style: 清理无用导入和代码
chore: 更新依赖项
This commit is contained in:
2026-01-09 00:20:30 +08:00
parent 5d07a84283
commit 77348113e3
18 changed files with 754 additions and 73 deletions

View File

@@ -6,11 +6,12 @@
"""
import inspect
from abc import ABC, abstractmethod
from typing import Any, Callable, Dict, List, Optional, Tuple
from typing import Any, Callable, Dict, List, Optional, Tuple, TYPE_CHECKING
from ..bot import Bot
if TYPE_CHECKING:
from ..bot import Bot
from ..config_loader import global_config
from ..managers.permission_manager import Permission
from ..permission import Permission
from ..utils.executor import run_in_thread_pool
@@ -22,7 +23,7 @@ class BaseHandler(ABC):
self.handlers: List[Dict[str, Any]] = []
@abstractmethod
async def handle(self, bot: Bot, event: Any):
async def handle(self, bot: "Bot", event: Any):
"""
处理事件
"""
@@ -31,7 +32,7 @@ class BaseHandler(ABC):
async def _run_handler(
self,
func: Callable,
bot: Bot,
bot: "Bot",
event: Any,
args: Optional[List[str]] = None,
permission_granted: Optional[bool] = None
@@ -122,7 +123,7 @@ class MessageHandler(BaseHandler):
return func
return decorator
async def handle(self, bot: Bot, event: Any):
async def handle(self, bot: "Bot", event: Any):
"""
处理消息事件,分发给命令处理器或通用消息处理器
"""