uniborg/stdplugins/aesthetics.py

27 lines
805 B
Python
Raw Normal View History

2018-05-13 20:42:59 +00:00
# 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
2018-05-13 20:54:58 +00:00
PRINTABLE_ASCII = range(0x21, 0x7f)
2018-05-13 20:42:59 +00:00
def aesthetify(string):
for c in string:
c = ord(c)
if c in PRINTABLE_ASCII:
c += 0xFF00 - 0x20
2018-05-13 20:54:58 +00:00
elif c == ord(" "):
c = 0x3000
2018-05-13 20:42:59 +00:00
yield chr(c)
2018-06-14 18:03:14 +00:00
@borg.on(events.NewMessage(pattern=r'\.ae\s+(.+)', outgoing=True))
@borg.on(events.MessageEdited(pattern=r'\.ae\s+(.+)', outgoing=True))
2018-05-13 20:42:59 +00:00
async def _(event):
text = event.pattern_match.group(1)
text = "".join(aesthetify(text))
2018-05-13 20:54:58 +00:00
await event.edit(text=text, parse_mode=None, link_preview=False)
raise events.StopPropagation