Count messages and sort by top posters

This commit is contained in:
Dan Elkouby 2019-09-07 08:08:07 +00:00
parent 40c398833d
commit 9fe2e80742
1 changed files with 14 additions and 3 deletions

View File

@ -34,8 +34,19 @@ async def _(event):
@borg.on(events.NewMessage(pattern=r"\.members", outgoing=True)) @borg.on(events.NewMessage(pattern=r"\.members", outgoing=True))
async def _(event): async def _(event):
members = [ members = []
get_who_string(m) async for m in borg.iter_participants(event.chat_id) async for member in borg.iter_participants(event.chat_id):
] messages = await borg.get_messages(
event.chat_id,
from_user=member,
limit=0
)
members.append((
messages.total,
f"{messages.total} - {get_who_string(member)}"
))
members = (
m[1] for m in sorted(members, key=lambda m: m[0], reverse=True)
)
await event.edit("\n".join(members), parse_mode='html') await event.edit("\n".join(members), parse_mode='html')