From 40c398833d4c48054ef3e1c26b2070210b2dcb7e Mon Sep 17 00:00:00 2001 From: Dan Elkouby Date: Sat, 7 Sep 2019 07:31:43 +0000 Subject: [PATCH] Add member list command --- stdplugins/who.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/stdplugins/who.py b/stdplugins/who.py index 897ec1c..33c81b0 100644 --- a/stdplugins/who.py +++ b/stdplugins/who.py @@ -8,6 +8,14 @@ from telethon import utils from telethon.tl import types +def get_who_string(who): + who_string = html.escape(utils.get_display_name(who)) + if isinstance(who, (types.User, types.Channel)) and who.username: + who_string += f" (@{who.username})" + who_string += f", #{who.id}" + return who_string + + @borg.on(events.NewMessage(pattern=r"\.who", outgoing=True)) async def _(event): if not event.message.is_reply: @@ -21,9 +29,13 @@ async def _(event): else: who = await msg.get_sender() - who_string = html.escape(utils.get_display_name(who)) - if isinstance(who, (types.User, types.Channel)) and who.username: - who_string += f" (@{who.username})" - who_string += f", #{who.id}" + await event.edit(get_who_string(who), parse_mode='html') - await event.edit(who_string, parse_mode='html') + +@borg.on(events.NewMessage(pattern=r"\.members", outgoing=True)) +async def _(event): + members = [ + get_who_string(m) async for m in borg.iter_participants(event.chat_id) + ] + + await event.edit("\n".join(members), parse_mode='html')