feat(bot): 实现 BotManager 并完善机器人注销逻辑

添加全局 BotManager 单例用于统一管理所有 Bot 实例
在 WS 关闭和 ReverseWSManager 清理时调用注销逻辑
修改广播插件使用 BotManager 获取所有活跃 Bot 实例
移除 echo 插件的权限限制并更新文档配置
This commit is contained in:
2026-03-08 12:25:13 +08:00
parent 789d4e8ac7
commit dec1a43f28
8 changed files with 120 additions and 33 deletions

16
main.py
View File

@@ -24,21 +24,6 @@ from core.services.local_file_server import start_local_file_server, stop_local_
# 尝试使用高性能事件循环
try:
if sys.platform == 'win32':
# winloop 与 Playwright 存在兼容性问题 (不支持 startupinfo),暂时禁用
# import winloop
# asyncio.set_event_loop_policy(winloop.EventLoopPolicy())
# print("已启用 winloop 高性能事件循环")
print("Windows 平台检测到 Playwright已自动禁用 winloop 以确保兼容性")
else:
import uvloop
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
print("已启用 uvloop 高性能事件循环")
except ImportError:
print("未检测到高性能事件循环库 (uvloop/winloop),将使用默认事件循环")
# 将项目根目录添加到 sys.path
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, ROOT_DIR)
@@ -233,7 +218,6 @@ if __name__ == "__main__":
asyncio.run(main())
except KeyboardInterrupt:
# 捕获 KeyboardInterrupt不做任何操作让 asyncio.run 正常结束
# 这样 main 函数中的 finally 块会被执行
pass
except Exception as e:
main_logger.exception("程序发生未处理的全局异常")