groupindex fix a bug

This commit is contained in:
xtaodada 2021-08-02 23:49:38 +08:00
parent 6b1514bc51
commit 74d3d03129
No known key found for this signature in database
GPG Key ID: EE4DC37B55E24736
2 changed files with 11 additions and 8 deletions

View File

@ -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)

View File

@ -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"