use latest group image for xiaoniu image followups
This commit is contained in:
@@ -43,6 +43,24 @@ class MessageStorageDB(BaseDBOperator):
|
||||
params = (hours_ago, group_id, min_content_length)
|
||||
return self.execute_query(sql, params) or []
|
||||
|
||||
def get_latest_image_message(self, group_id: str, before_timestamp: str = "", hours_ago: int = 8) -> Optional[Dict]:
|
||||
"""获取指定群最近一条已落盘图片消息"""
|
||||
sql = """
|
||||
SELECT timestamp, sender, content, message_type, image_path
|
||||
FROM messages
|
||||
WHERE timestamp >= DATE_SUB(NOW(), INTERVAL %s HOUR)
|
||||
AND group_id = %s
|
||||
AND message_type = 3
|
||||
AND image_path IS NOT NULL
|
||||
AND image_path <> ''
|
||||
"""
|
||||
params: List = [hours_ago, group_id]
|
||||
if before_timestamp:
|
||||
sql += " AND timestamp <= %s"
|
||||
params.append(before_timestamp)
|
||||
sql += " ORDER BY timestamp DESC LIMIT 1"
|
||||
return self.execute_query(sql, tuple(params), fetch_one=True)
|
||||
|
||||
def get_member_recent_messages(self, group_id: str, wxid: str, days: int = 30,
|
||||
limit: int = 200, include_today: bool = True) -> List[Dict]:
|
||||
"""获取指定群成员近期消息"""
|
||||
|
||||
Reference in New Issue
Block a user