调整图片下载逻辑,定时任务5分钟一次进行图片消息下载存档。
This commit is contained in:
@@ -257,3 +257,27 @@ class MessageStorageDB(BaseDBOperator):
|
||||
"""
|
||||
|
||||
return self.execute_query(sql, tuple(params)) or []
|
||||
|
||||
def get_pending_image_messages(self, minutes_ago: int = 10, limit: int = 50) -> List[Dict]:
|
||||
"""获取最近N分钟内未处理图片的消息(image_path IS NULL)
|
||||
|
||||
Args:
|
||||
minutes_ago: 查询最近多少分钟的消息,默认10分钟
|
||||
limit: 每次最多处理多少条,默认50条
|
||||
|
||||
Returns:
|
||||
包含消息ID、群ID、消息XML等信息的列表
|
||||
"""
|
||||
sql = """
|
||||
SELECT message_id, group_id, message_xml, timestamp
|
||||
FROM messages
|
||||
WHERE message_type = '3'
|
||||
AND image_path IS NULL
|
||||
AND timestamp >= DATE_SUB(NOW(), INTERVAL %s MINUTE)
|
||||
AND message_xml IS NOT NULL
|
||||
AND message_xml != ''
|
||||
ORDER BY timestamp ASC
|
||||
LIMIT %s
|
||||
"""
|
||||
params = (minutes_ago, limit)
|
||||
return self.execute_query(sql, params) or []
|
||||
|
||||
Reference in New Issue
Block a user