fix(chatter): 修复因消息无ID导致的处理错误
在处理消息映射时,增加了一项检查。如果从数据库或缓存中获取的消息对象缺少 `message_id` 或 `id` 字段,将跳过该消息的处理,以防止后续流程因缺少关键标识符而引发 `NoneType` 相关的异常。(实现了plan_filiter.py的basic模式下的类型错误清零)
This commit is contained in:
@@ -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