新增潜水排行
This commit is contained in:
@@ -724,6 +724,7 @@ class ContactsDBOperator(BaseDBOperator):
|
||||
WHEN latest_active_time IS NULL THEN 999999
|
||||
ELSE TIMESTAMPDIFF(DAY, latest_active_time, NOW())
|
||||
END AS inactivity_days
|
||||
, CASE WHEN latest_active_time IS NULL THEN 1 ELSE 0 END AS never_spoken
|
||||
FROM t_chatroom_member
|
||||
WHERE chatroom_id = %s
|
||||
AND (latest_active_time IS NULL OR latest_active_time <= DATE_SUB(NOW(), INTERVAL %s DAY))
|
||||
|
||||
@@ -112,12 +112,22 @@ class InactiveRankPlugin(MessagePluginInterface):
|
||||
await bot.send_text_message(roomid, f"📉 {days}天内暂无潜水成员", sender)
|
||||
return True, "暂无数据"
|
||||
|
||||
lines = [f"📉 {days}天潜水排行,取前{limit}名"]
|
||||
lines = [f"(≥{days}天 未发言,前{limit}名)"]
|
||||
for i, r in enumerate(rows, 1):
|
||||
name = r.get("nick_name") or r.get("wxid")
|
||||
name = (r.get("nick_name") or r.get("wxid") or "").strip()
|
||||
inactivity = int(r.get("inactivity_days", 0))
|
||||
last = r.get("latest_active_time") or "未知"
|
||||
lines.append(f"{i}. {name} | 潜水{inactivity}天 | 上次活跃: {last}")
|
||||
last = r.get("latest_active_time")
|
||||
never = int(r.get("never_spoken", 0))
|
||||
status = "从未发言" if (never == 1 or inactivity >= 999999 or not last) else f"{inactivity}天未发言"
|
||||
if i == 1:
|
||||
prefix = "🥇 "
|
||||
elif i == 2:
|
||||
prefix = "🥈 "
|
||||
elif i == 3:
|
||||
prefix = "🥉 "
|
||||
else:
|
||||
prefix = f" {i}. "
|
||||
lines.append(f"{prefix}{name} -> {status}")
|
||||
msg = "\n".join(lines)
|
||||
await bot.send_text_message(roomid, msg, sender)
|
||||
return True, "已发送"
|
||||
|
||||
Reference in New Issue
Block a user