‼️fix: 修复 wecom 加载失败的问题 #659

This commit is contained in:
Soulter
2025-03-03 22:34:18 +08:00
parent 2b4f66e0cf
commit 0297a43de6
3 changed files with 18 additions and 11 deletions
+3
View File
@@ -139,6 +139,9 @@ CONFIG_METADATA_2 = {
"port": 11451,
},
"wecom(企业微信)": {
"id": "wecom",
"type": "wecom",
"enable": False,
"corpid": "",
"secret": "",
"port": 6195,
+12 -8
View File
@@ -23,7 +23,10 @@ class PlatformManager:
async def initialize(self):
"""初始化所有平台适配器"""
for platform in self.platforms_config:
await self.load_platform(platform)
try:
await self.load_platform(platform)
except Exception as e:
logger.error(f"初始化 {platform} 平台适配器失败: {e}")
# 网页聊天
webchat_inst = WebChatAdapter({}, self.settings, self.event_queue)
@@ -34,15 +37,14 @@ class PlatformManager:
async def load_platform(self, platform_config: dict):
"""实例化一个平台"""
if not platform_config["enable"]:
return
logger.info(
f"载入 {platform_config['type']}({platform_config['id']}) 平台适配器 ..."
)
# 动态导入
try:
if not platform_config["enable"]:
return
logger.info(
f"载入 {platform_config['type']}({platform_config['id']}) 平台适配器 ..."
)
match platform_config["type"]:
case "aiocqhttp":
from .sources.aiocqhttp.aiocqhttp_platform_adapter import (
@@ -64,6 +66,8 @@ class PlatformManager:
from .sources.lark.lark_adapter import LarkPlatformAdapter # noqa: F401
case "telegram":
from .sources.telegram.tg_adapter import TelegramPlatformAdapter # noqa: F401
case "wecom":
from .sources.wecom.wecom_adapter import WecomPlatformAdapter # noqa: F401
except (ImportError, ModuleNotFoundError) as e:
logger.error(
f"加载平台适配器 {platform_config['type']} 失败,原因:{e}。请检查依赖库是否安装。提示:可以在 管理面板->控制台->安装Pip库 中安装依赖库。"
+3 -3
View File
@@ -1,4 +1,5 @@
import asyncio
import traceback
from astrbot.core import logger
from astrbot.core.core_lifecycle import AstrBotCoreLifecycle
from .server import AstrBotDashboard
@@ -21,9 +22,8 @@ class AstrBotDashBoardLifecycle:
await core_lifecycle.initialize()
core_task = core_lifecycle.start()
except Exception as e:
logger.critical(f"初始化 AstrBot 失败:{e} !!!!!!!")
logger.critical(f"初始化 AstrBot 失败:{e} !!!!!!!")
logger.critical(f"初始化 AstrBot 失败:{e} !!!!!!!")
logger.critical(traceback.format_exc())
logger.critical(f"😭 初始化 AstrBot 失败:{e} !!!")
self.dashboard_server = AstrBotDashboard(core_lifecycle, self.db)
task = asyncio.gather(core_task, self.dashboard_server.run())