Add aesthetics plugin

ninja_fix
Dan Elkouby 2018-05-13 20:42:59 +00:00
parent 8103d011dd
commit 85b68dd259
1 changed files with 29 additions and 0 deletions

29
stdplugins/aesthetics.py Normal file
View File

@ -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)
))