From 1f8be2b569189f9a001374209fce645c1deab745 Mon Sep 17 00:00:00 2001 From: youpaishidifu Date: Tue, 1 Sep 2026 09:41:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=A8=E9=9D=A2=E9=98=B2=E5=BE=A1?= =?UTF-8?q?=E6=80=A7=E7=BC=96=E7=A8=8B=E7=A1=AE=E4=BF=9D=E6=89=80=E6=9C=89?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E8=A1=A8=E5=AD=98=E5=9C=A8=EF=BC=8C?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=A4=9A=E4=B8=AAno=20such=20table=E9=94=99?= =?UTF-8?q?=E8=AF=AF=20(Task=20#1658)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- monitor.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/monitor.py b/monitor.py index 3c6ea7d..9db7d53 100644 --- a/monitor.py +++ b/monitor.py @@ -492,6 +492,9 @@ class MessageHistory: if not content or not content.strip(): return False + # 防御性编程:确保表存在 + self._ensure_user_messages_table() + cleaned_current = self._clean_text_for_dedup(content) if len(cleaned_current) < 2: # 太短无法比对 return False @@ -661,6 +664,9 @@ class MessageHistory: user_msg_time: 用户消息的时间戳(Unix时间),如果晚于最后bot回复时间,则视为新消息不跳过 """ + # 防御性编程:确保表存在 + self._ensure_bot_messages_table() + content_hash = hashlib.md5(content.strip().encode('utf-8')).hexdigest() conn = self._get_conn() try: @@ -722,6 +728,9 @@ class MessageHistory: def last_bot_reply_time(self, platform: str) -> float: """获取该平台最近一次bot回复的时间戳(Unix时间)""" + # 防御性编程:确保表存在 + self._ensure_bot_messages_table() + conn = self._get_conn() try: cursor = conn.execute( @@ -746,6 +755,9 @@ class MessageHistory: Args: within_minutes: 只返回最近N分钟内的回复,None表示不过滤时间 """ + # 防御性编程:确保表存在 + self._ensure_bot_messages_table() + conn = self._get_conn() try: if within_minutes is not None and within_minutes > 0: @@ -821,6 +833,9 @@ class MessageHistory: def has_ocr_message_record(self, platform: str, content: str) -> bool: """检查OCR暂存表中是否已存在该消息的记录(用于时间戳新鲜度评分逻辑)""" + # 防御性编程:确保表存在 + self._ensure_ocr_staging_table() + content_hash = hashlib.md5(content.strip().encode('utf-8')).hexdigest() conn = self._get_conn() try: