fix(chat): 修复因消息ID非字符串类型导致的模糊匹配错误

在ChatterPlanFilter的模糊匹配逻辑中,从消息对象获取的ID(orig_mid)可能为整数或None,而非预期的字符串。

当re.sub接收到非字符串类型的参数时会引发TypeError。此更改通过在处理前显式地将ID转换为字符串,并处理其为None的情况,确保了代码的健壮性,避免了潜在的运行时崩溃。
This commit is contained in:
tt-P607
2025-09-29 22:11:45 +08:00
parent 35a4ca3f50
commit 21b3346bc6

View File

@@ -765,7 +765,7 @@ class ChatterPlanFilter:
message_obj = item.get("message")
if isinstance(message_obj, dict):
orig_mid = message_obj.get("message_id") or message_obj.get("id")
orig_number = re.sub(r'[^0-9]', '', orig_mid)
orig_number = re.sub(r'[^0-9]', '', str(orig_mid)) if orig_mid else ""
if orig_number == number_part:
logger.debug(f"模糊匹配成功(消息对象): {candidate} -> {orig_mid}")
return message_obj