From 23e80cb61ae8cf8f04b621c046519cc58446bf7b Mon Sep 17 00:00:00 2001 From: liuwei Date: Wed, 12 Feb 2025 14:33:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E4=BA=86=E7=BE=A4=E7=BB=84?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E4=BD=9C=E4=B8=BA=E5=8F=82=E6=95=B0=EF=BC=8C?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=E4=B8=B2=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- message_storage/message_to_db.py | 6 +++--- robot.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/message_storage/message_to_db.py b/message_storage/message_to_db.py index 0c68734..1898088 100644 --- a/message_storage/message_to_db.py +++ b/message_storage/message_to_db.py @@ -36,7 +36,7 @@ def archive_message(group_id, timestamp_str, sender, content, message_type, atta connection.close() -def get_messages(all_contacts: dict): +def get_messages(group_id, all_contacts: dict): # 连接到数据库 connection = pymysql.connect(**db_config) @@ -53,9 +53,9 @@ def get_messages(all_contacts: dict): query = """ SELECT group_id, timestamp, sender, content FROM messages - WHERE timestamp >= %s AND message_type =1 + WHERE timestamp >= %s AND message_type =1 and group_id = %s """ - cursor.execute(query, (eight_hours_ago_str,)) + cursor.execute(query, (eight_hours_ago_str, group_id)) # 提取结果并组成带逗号的字符串 result = [] diff --git a/robot.py b/robot.py index e04c9b3..ff653ef 100644 --- a/robot.py +++ b/robot.py @@ -366,7 +366,7 @@ class Robot(Job): def message_summary_robot(self, sender: str = None): try: - content = get_messages(self.allContacts) + content = get_messages(sender, self.allContacts) summary = message_summary(content) self.sendTextMsg(summary, sender) except Exception as e: