From 85b68dd25993ea3cf2546b0b40739e2dffaf1f63 Mon Sep 17 00:00:00 2001 From: Dan Elkouby Date: Sun, 13 May 2018 20:42:59 +0000 Subject: [PATCH] Add aesthetics plugin --- stdplugins/aesthetics.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 stdplugins/aesthetics.py diff --git a/stdplugins/aesthetics.py b/stdplugins/aesthetics.py new file mode 100644 index 0000000..281927e --- /dev/null +++ b/stdplugins/aesthetics.py @@ -0,0 +1,29 @@ +# 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.functions.messages import EditMessageRequest + +PRINTABLE_ASCII = range(0x20, 0x7f) + + +def aesthetify(string): + for c in string: + c = ord(c) + if c in PRINTABLE_ASCII: + c += 0xFF00 - 0x20 + yield chr(c) + + +@borg.on(events.NewMessage(pattern=r'.ae (\S+)', outgoing=True)) +async def _(event): + text = event.pattern_match.group(1) + text = "".join(aesthetify(text)) + + await borg(EditMessageRequest( + peer=await event.input_chat, + id=event.message.id, + message=text, + no_webpage=not bool(event.message.media) + ))