This commit is contained in:
udf 2018-10-08 19:21:24 +00:00
commit 61d03d4870
2 changed files with 28 additions and 1 deletions

27
stdplugins/who.py Normal file
View File

@ -0,0 +1,27 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from telethon import events
from telethon import utils
from telethon.tl import types
@borg.on(events.NewMessage(pattern=r"\.who", outgoing=True))
async def _(event):
if not event.message.is_reply:
who = await event.get_chat()
else:
msg = await event.message.get_reply_message()
if msg.forward:
who = await borg.get_entity(
msg.forward.from_id or msg.forward.channel_id)
else:
who = await msg.get_sender()
who_string = 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(who_string)

View File

@ -31,7 +31,7 @@ async def load_reload(event):
await event.respond(f"Failed to (re)load plugin {shortname}: {e}")
@borg.on(util.admin_cmd(r"^\.(?:unload|remove) (?P<shortname>\w+)$"))
@borg.on(util.admin_cmd(r"^\.(?:unload|disable|remove) (?P<shortname>\w+)$"))
async def remove(event):
await event.delete()
shortname = event.pattern_match["shortname"]