加入了群组信息作为参数,防止串数据
This commit is contained in:
@@ -36,7 +36,7 @@ def archive_message(group_id, timestamp_str, sender, content, message_type, atta
|
|||||||
connection.close()
|
connection.close()
|
||||||
|
|
||||||
|
|
||||||
def get_messages(all_contacts: dict):
|
def get_messages(group_id, all_contacts: dict):
|
||||||
# 连接到数据库
|
# 连接到数据库
|
||||||
connection = pymysql.connect(**db_config)
|
connection = pymysql.connect(**db_config)
|
||||||
|
|
||||||
@@ -53,9 +53,9 @@ def get_messages(all_contacts: dict):
|
|||||||
query = """
|
query = """
|
||||||
SELECT group_id, timestamp, sender, content
|
SELECT group_id, timestamp, sender, content
|
||||||
FROM messages
|
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 = []
|
result = []
|
||||||
|
|||||||
2
robot.py
2
robot.py
@@ -366,7 +366,7 @@ class Robot(Job):
|
|||||||
|
|
||||||
def message_summary_robot(self, sender: str = None):
|
def message_summary_robot(self, sender: str = None):
|
||||||
try:
|
try:
|
||||||
content = get_messages(self.allContacts)
|
content = get_messages(sender, self.allContacts)
|
||||||
summary = message_summary(content)
|
summary = message_summary(content)
|
||||||
self.sendTextMsg(summary, sender)
|
self.sendTextMsg(summary, sender)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user