Fix .who in private and reoder admin title

This commit is contained in:
Lonami 2019-10-08 17:41:00 +02:00
parent 95d95701ea
commit b6a67cf5f2
1 changed files with 8 additions and 6 deletions

View File

@ -10,10 +10,10 @@ from telethon.tl import types, functions
def get_who_string(who, rank=None): def get_who_string(who, rank=None):
who_string = html.escape(utils.get_display_name(who)) who_string = html.escape(utils.get_display_name(who))
if isinstance(who, (types.User, types.Channel)) and who.username:
who_string += f" <i>(@{who.username})</i>"
if rank is not None: if rank is not None:
who_string += f' <i>"{html.escape(rank)}"</i>' who_string += f' <i>"{html.escape(rank)}"</i>'
if isinstance(who, (types.User, types.Channel)) and who.username:
who_string += f" <i>(@{who.username})</i>"
who_string += f", <a href='tg://user?id={who.id}'>#{who.id}</a>" who_string += f", <a href='tg://user?id={who.id}'>#{who.id}</a>"
return who_string return who_string
@ -31,10 +31,12 @@ async def _(event):
msg.forward.from_id or msg.forward.channel_id) msg.forward.from_id or msg.forward.channel_id)
else: else:
who = await msg.get_sender() who = await msg.get_sender()
rank = getattr((await borg(functions.channels.GetParticipantRequest( ic = await event.get_input_chat()
await event.get_input_chat(), if isinstance(ic, types.InputPeerChannel):
who rank = getattr((await borg(functions.channels.GetParticipantRequest(
))).participant, 'rank', None) ic,
who
))).participant, 'rank', None)
await event.edit(get_who_string(who, rank), parse_mode='html') await event.edit(get_who_string(who, rank), parse_mode='html')