mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2025-07-28 08:00:56 +00:00
⚡ 使用webp背景图压缩资源包大小
This commit is contained in:
33
liteyuki/plugins/liteyuki_statistics/stat_api.py
Normal file
33
liteyuki/plugins/liteyuki_statistics/stat_api.py
Normal file
@ -0,0 +1,33 @@
|
||||
import time
|
||||
from typing import Any
|
||||
from .common import MessageEventModel, msg_db
|
||||
|
||||
|
||||
def get_stat_msg_data(duration, period) -> tuple[list[int,], list[int,]]:
|
||||
"""
|
||||
获取统计消息
|
||||
Args:
|
||||
duration: 统计时间,单位秒
|
||||
period: 统计周期,单位秒
|
||||
|
||||
Returns:
|
||||
tuple: [int,], [int,] 两个列表,分别为周期中心时间戳和消息数量
|
||||
"""
|
||||
now = int(time.time())
|
||||
msg_rows = msg_db.where_all(
|
||||
MessageEventModel(),
|
||||
"time > ?",
|
||||
now - duration
|
||||
)
|
||||
timestamps = []
|
||||
msg_count = []
|
||||
msg_rows.sort(key=lambda x: x.time)
|
||||
for msg_row in msg_rows:
|
||||
period_center_time = msg_row.time - msg_row.time % period + period // 2
|
||||
|
||||
# if not timestamps or period_start_time != timestamps[-1]:
|
||||
# timestamps.append(period_start_time)
|
||||
# msg_count.append(1)
|
||||
# else:
|
||||
# msg_count[-1] += 1
|
||||
#
|
Reference in New Issue
Block a user