feat: add xm,cai ranking

This commit is contained in:
草师傅 2025-07-31 13:11:58 +08:00
parent aca87ce3a0
commit e4f70dd729
2 changed files with 34 additions and 0 deletions

View file

@ -28,6 +28,16 @@ async def handle_stats_command(message: Message):
key=lambda x: x[1]['message_count'],
reverse=True
)
sorted_most_xm_users = sorted(
stats['users'].items(),
key=lambda x: x[1]['xm_count'],
reverse=True
)
sorted_most_wocai_users = sorted(
stats['users'].items(),
key=lambda x: x[1]['wocai_count'],
reverse=True
)
# 构建统计消息
text = f"📊 群组统计\n\n"
@ -38,5 +48,17 @@ async def handle_stats_command(message: Message):
for i, (user_id, user_data) in enumerate(sorted_users[:10], 1):
name = user_data['name'] or user_data['username'] or str(user_id)
text += f"{i}. {name}: {user_data['message_count']}\n"
if sorted_most_xm_users:
text += "\n💬 羡慕统计:\n"
for user_id, user_data in sorted_most_xm_users:
if user_data['xm_count'] > 0:
name = user_data['name'] or user_data['username'] or str(user_id)
text += f"{name}: {user_data['xm_count']} 次羡慕\n"
if sorted_most_wocai_users:
text += "\n🥬 卖菜统计:\n"
for user_id, user_data in sorted_most_wocai_users:
if user_data['wocai_count'] > 0:
name = user_data['name'] or user_data['username'] or str(user_id)
text += f"{name}: {user_data['wocai_count']} 次卖菜\n"
await message.reply(text)