From 0d99b4e6cb0ddf1f018830a79465a20d2ef14410 Mon Sep 17 00:00:00 2001 From: minecraft1024a Date: Fri, 31 Oct 2025 21:39:50 +0800 Subject: [PATCH] =?UTF-8?q?fix(chatter):=20=E4=BF=AE=E5=A4=8D=E5=9B=A0?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=97=A0ID=E5=AF=BC=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E5=A4=84=E7=90=86=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在处理消息映射时,增加了一项检查。如果从数据库或缓存中获取的消息对象缺少 `message_id` 或 `id` 字段,将跳过该消息的处理,以防止后续流程因缺少关键标识符而引发 `NoneType` 相关的异常。(实现了plan_filiter.py的basic模式下的类型错误清零) --- src/plugins/built_in/affinity_flow_chatter/plan_filter.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/built_in/affinity_flow_chatter/plan_filter.py b/src/plugins/built_in/affinity_flow_chatter/plan_filter.py index 4c7c690d6..c15f5d244 100644 --- a/src/plugins/built_in/affinity_flow_chatter/plan_filter.py +++ b/src/plugins/built_in/affinity_flow_chatter/plan_filter.py @@ -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)