diff --git a/stdplugins/who.py b/stdplugins/who.py
index 3982344..bc621f9 100644
--- a/stdplugins/who.py
+++ b/stdplugins/who.py
@@ -5,19 +5,22 @@ import html
from telethon import events
from telethon import utils
-from telethon.tl import types
+from telethon.tl import types, functions
-def get_who_string(who):
+def get_who_string(who, rank=None):
who_string = html.escape(utils.get_display_name(who))
if isinstance(who, (types.User, types.Channel)) and who.username:
who_string += f" (@{who.username})"
+ if rank is not None:
+ who_string += f' "{html.escape(rank)}"'
who_string += f", #{who.id}"
return who_string
@borg.on(events.NewMessage(pattern=r"\.who", outgoing=True))
async def _(event):
+ rank = None
if not event.message.is_reply:
who = await event.get_chat()
else:
@@ -28,8 +31,12 @@ async def _(event):
msg.forward.from_id or msg.forward.channel_id)
else:
who = await msg.get_sender()
+ rank = getattr((await borg(functions.channels.GetParticipantRequest(
+ await event.get_input_chat(),
+ who
+ ))).participant, 'rank', None)
- await event.edit(get_who_string(who), parse_mode='html')
+ await event.edit(get_who_string(who, rank), parse_mode='html')
@borg.on(events.NewMessage(pattern=r"\.members", outgoing=True))