加入了群组信息作为参数,防止串数据
This commit is contained in:
@@ -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 = []
|
||||
|
||||
Reference in New Issue
Block a user