From 05949bdf6761bba875838b5a4081c3c227558335 Mon Sep 17 00:00:00 2001 From: liuwei Date: Tue, 20 Jan 2026 17:05:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=BD=9C=E6=B0=B4=E6=8E=92?= =?UTF-8?q?=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/contacts_db.py | 1 + plugins/inactive_rank/main.py | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/db/contacts_db.py b/db/contacts_db.py index e8d5387..4bcc1f8 100644 --- a/db/contacts_db.py +++ b/db/contacts_db.py @@ -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)) diff --git a/plugins/inactive_rank/main.py b/plugins/inactive_rank/main.py index 2f92cbc..38805ca 100644 --- a/plugins/inactive_rank/main.py +++ b/plugins/inactive_rank/main.py @@ -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, "已发送"