From 74d3d0312958450f4fefe1898a3ef100245140d3 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Mon, 2 Aug 2021 23:49:38 +0800 Subject: [PATCH] groupindex fix a bug --- groupindex.py | 15 +++++++++------ list.json | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/groupindex.py b/groupindex.py index 973771a..52852e2 100644 --- a/groupindex.py +++ b/groupindex.py @@ -71,14 +71,17 @@ async def group_index(context): text += f'活跃人数:{member_counts} 人\n' \ f'总消息数:{msg_counts} 条\n' if admin: - text += f'加群 {join_count} 人,退群 {leave_count} 人\n' \ + text += f'加群 {join_count} 人,退群 {leave_count} 人\n' text += f'最活跃的小可爱们:\n' # 字典倒序排序 member_count = sorted(member_count.items(), key=lambda x: x[1], reverse=True) # 遍历列表 - for i in range(min(len(member_count), 5)): - # 获取用户信息 - target_user = await context.client(GetFullUserRequest(member_count[i][0])) - first_name = target_user.user.first_name.replace("\u2060", "") - text += f'{first_name} `{member_count[i][1]}`\n' + if len(member_count) == 0: + text += "没有发言用户呢 ~" + else: + for i in range(min(len(member_count), 5)): + # 获取用户信息 + target_user = await context.client(GetFullUserRequest(member_count[i][0])) + first_name = target_user.user.first_name.replace("\u2060", "") + text += f'{first_name} `{member_count[i][1]}`\n' await context.edit(text) diff --git a/list.json b/list.json index f063852..0c9635c 100644 --- a/list.json +++ b/list.json @@ -692,10 +692,10 @@ }, { "name": "groupindex", - "version": "1.1", + "version": "1.11", "section": "daily", "maintainer": "xtaodada", - "size": "3.1 kb", + "size": "3.2 kb", "supported": true, "des-short": "获取群组当日活跃数据", "des": "获取群组当日活跃数据。\n指令:-groupindex"