加入了群组信息作为参数,防止串数据

This commit is contained in:
liuwei
2025-02-12 14:33:38 +08:00
parent b6c6476c7a
commit 23e80cb61a
2 changed files with 4 additions and 4 deletions

View File

@@ -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 = []

View File

@@ -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: