chore: 恢复PR改动并适配官方最新版本
在官方更新到4936a6d后,选择性恢复PR中的功能改动: Maizone插件修复(6个文件): - 优化成功/失败反馈机制(直接反馈,不使用AI生成) - 实现QQ空间Cookie失效自动重试机制 - 修复评论回复被分割导致标点符号丢失的问题 - 修复QQ空间转发内容提取错误 - 改进maizone图片识别模型配置,支持自动fallback - 优化maizone说说生成规则 适配器响应处理(bot.py): - 添加adapter_response消息处理逻辑 - 适配新的DatabaseMessages架构 - 在message_process早期阶段优先处理adapter_response Web搜索引擎扩展: - 添加Serper搜索引擎支持 LLM成本计算修复: - 修复LLM使用统计中成本计算错误的bug - 调整LLM相关日志级别为DEBUG 其他优化: - 优化NapCat adapter响应处理 - 优化person_info关系推理逻辑 注:本次恢复已跳过与官方冲突的部分,保留官方的新架构改进 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -301,6 +301,28 @@ class ChatBot:
|
||||
logger.error(f"处理命令时出错: {e}")
|
||||
return False, None, True # 出错时继续处理消息
|
||||
|
||||
|
||||
async def _handle_adapter_response_from_dict(self, seg_data: dict | None):
|
||||
"""处理适配器命令响应(从字典数据)"""
|
||||
try:
|
||||
from src.plugin_system.apis.send_api import put_adapter_response
|
||||
|
||||
if isinstance(seg_data, dict):
|
||||
request_id = seg_data.get("request_id")
|
||||
response_data = seg_data.get("response")
|
||||
else:
|
||||
request_id = None
|
||||
response_data = None
|
||||
|
||||
if request_id and response_data:
|
||||
logger.info(f"[DEBUG bot.py] 收到适配器响应,request_id={request_id}")
|
||||
put_adapter_response(request_id, response_data)
|
||||
else:
|
||||
logger.warning(f"适配器响应消息格式不正确: request_id={request_id}, response_data={response_data}")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"处理适配器响应时出错: {e}")
|
||||
|
||||
async def message_process(self, message_data: dict[str, Any]) -> None:
|
||||
"""处理转化后的统一格式消息"""
|
||||
try:
|
||||
@@ -351,6 +373,14 @@ class ChatBot:
|
||||
await MessageStorage.update_message(message_data)
|
||||
return
|
||||
|
||||
# 优先处理adapter_response消息(在创建DatabaseMessages之前)
|
||||
message_segment = message_data.get("message_segment")
|
||||
if message_segment and isinstance(message_segment, dict):
|
||||
if message_segment.get("type") == "adapter_response":
|
||||
logger.info(f"[DEBUG bot.py message_process] 检测到adapter_response,立即处理")
|
||||
await self._handle_adapter_response_from_dict(message_segment.get("data"))
|
||||
return
|
||||
|
||||
group_info = temp_message_info.group_info
|
||||
user_info = temp_message_info.user_info
|
||||
|
||||
|
||||
Reference in New Issue
Block a user