From afc96c89d93d41a0a73639a045ef3e7e423a0935 Mon Sep 17 00:00:00 2001 From: Dan Elkouby Date: Sat, 25 Aug 2018 11:51:50 +0300 Subject: [PATCH 1/4] =?UTF-8?q?s/[[sed]]/=E3=80=8Csed=E3=80=8D/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stdplugins/sed.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdplugins/sed.py b/stdplugins/sed.py index 02422ef..04f7320 100644 --- a/stdplugins/sed.py +++ b/stdplugins/sed.py @@ -5,7 +5,7 @@ import regex from telethon import events, utils from telethon.tl import types, functions -HEADER = "[[sed]]\n" +HEADER = "「sed」\n" KNOWN_RE_BOTS = re.compile( r'(regex|moku|BananaButler_|rgx|l4mR)bot', flags=re.IGNORECASE From caead8435edb230af17aed2e720f0b99a3e2ed1c Mon Sep 17 00:00:00 2001 From: Dan Elkouby Date: Tue, 28 Aug 2018 08:44:33 +0000 Subject: [PATCH 2/4] Add whois plugin --- stdplugins/who.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 stdplugins/who.py diff --git a/stdplugins/who.py b/stdplugins/who.py new file mode 100644 index 0000000..0e1ebc3 --- /dev/null +++ b/stdplugins/who.py @@ -0,0 +1,31 @@ +# 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.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 borg.get_entity(msg.from_id) + + if isinstance(who, types.User): + who_string = who.first_name + if who.last_name: + who_string += f" {who.last_name}" + else: + who_string = who.title + 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) From 9f5eee1420433479978968ddf65194ae5cfa925e Mon Sep 17 00:00:00 2001 From: Dan Elkouby Date: Tue, 28 Aug 2018 10:16:17 +0000 Subject: [PATCH 3/4] @Lonami scolded me --- stdplugins/who.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/stdplugins/who.py b/stdplugins/who.py index 0e1ebc3..309008f 100644 --- a/stdplugins/who.py +++ b/stdplugins/who.py @@ -3,6 +3,7 @@ # 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 @@ -16,14 +17,9 @@ async def _(event): who = await borg.get_entity( msg.forward.from_id or msg.forward.channel_id) else: - who = await borg.get_entity(msg.from_id) + who = await msg.get_sender() - if isinstance(who, types.User): - who_string = who.first_name - if who.last_name: - who_string += f" {who.last_name}" - else: - who_string = who.title + 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}" From ddcb347527988919e2c92259893532e4c6bf21c8 Mon Sep 17 00:00:00 2001 From: Lonami Date: Mon, 17 Sep 2018 19:14:39 +0200 Subject: [PATCH 4/4] Alias remove as "disable" too We're bad at remembering names. --- uniborg/_core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uniborg/_core.py b/uniborg/_core.py index 77d105b..4679ec3 100644 --- a/uniborg/_core.py +++ b/uniborg/_core.py @@ -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\w+)$")) +@borg.on(util.admin_cmd(r"^\.(?:unload|disable|remove) (?P\w+)$")) async def remove(event): await event.delete() shortname = event.pattern_match["shortname"]