Merge branch 'dev' of https://github.com/MoFox-Studio/MoFox_Bot into dev
This commit is contained in:
@@ -6,6 +6,7 @@ MCP Client Manager
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
@@ -72,8 +73,19 @@ class MCPClientManager:
|
||||
Dict[str, MCPServerConfig]: 服务器名称 -> 配置对象
|
||||
"""
|
||||
if not self.config_path.exists():
|
||||
logger.warning(f"MCP 配置文件不存在: {self.config_path}")
|
||||
return {}
|
||||
# 尝试从模板创建配置文件
|
||||
template_path = Path("template/mcp.json")
|
||||
if template_path.exists():
|
||||
try:
|
||||
self.config_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copy(template_path, self.config_path)
|
||||
logger.info(f"已从模板创建 MCP 配置文件: {self.config_path}")
|
||||
except Exception as e:
|
||||
logger.error(f"从模板创建配置文件失败: {e}")
|
||||
return {}
|
||||
else:
|
||||
logger.warning(f"MCP 配置文件和模板都不存在: {self.config_path}, {template_path}")
|
||||
return {}
|
||||
|
||||
try:
|
||||
with open(self.config_path, encoding="utf-8") as f:
|
||||
|
||||
@@ -402,6 +402,9 @@ class ChatterPlanFilter:
|
||||
mapped = message_id_list[idx]
|
||||
synthetic_id = mapped.get("id")
|
||||
real_msg_id = msg.get("message_id") or msg.get("id")
|
||||
if not real_msg_id:
|
||||
continue # 如果消息没有ID,则跳过
|
||||
|
||||
msg_time = time.strftime("%H:%M:%S", time.localtime(msg.get("time", time.time())))
|
||||
user_nickname = msg.get("user_nickname", "未知用户")
|
||||
msg_content = msg.get("processed_plain_text", "")
|
||||
@@ -568,7 +571,7 @@ class ChatterPlanFilter:
|
||||
# 确保字典中有 message_id 字段
|
||||
if "message_id" not in target_message_obj and "id" in target_message_obj:
|
||||
target_message_obj["message_id"] = target_message_obj["id"]
|
||||
|
||||
|
||||
try:
|
||||
# 使用 ** 解包字典传入构造函数
|
||||
action_message_obj = DatabaseMessages(**target_message_obj)
|
||||
|
||||
Reference in New Issue
Block a user