modules/Надстрочка.py

85 lines
2.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import random
from telethon import functions
from telethon.tl.types import Message
from .. import loader, utils
def replace_text(input_text):
# Задаем соответствия для замен
upper_mapping = {
'Q': '', 'W': '', 'E': '', 'R': 'ᴿ', 'T': '',
'Y': 'ʸ', 'U': '', 'I': '', 'O': '', 'P': '',
'A': '', 'S': 'ˢ', 'D': '', 'F': '', 'G': '',
'H': '', 'J': '', 'K': '', 'L': '', 'Z': '',
'X': 'ˣ', 'C': '', 'V': '', 'B': '', 'N': '',
'M': ''
}
lower_mapping = {
'q': '', 'w': 'ʷ', 'e': '', 'r': 'ʳ', 't': '',
'y': 'ʸ', 'u': '', 'i': '', 'o': '', 'p': '',
'a': '', 's': 'ˢ', 'd': '', 'f': '', 'g': '',
'h': 'ʰ', 'j': 'ʲ', 'k': '', 'l': 'ˡ', 'z': '',
'x': 'ˣ', 'c': '', 'v': '', 'b': '', 'n': '',
'm': ''
}
digit_mapping = {
'0': '',
'1': '¹',
'2': '²',
'3': '³',
'4': '',
'5': '',
'6': '',
'7': '',
'8': '',
'9': ''
}
special_mapping = {
'+': '',
'=': '',
'!': '',
'(' : '',
')' : '',
'-' : '',
' ' : ' '
}
# Инициализируем переменную для результата
result = ""
# Проходим по каждому символу входного текста
for char in input_text:
if char in upper_mapping:
result += upper_mapping[char]
elif char in lower_mapping:
result += lower_mapping[char]
elif char in digit_mapping:
result += digit_mapping[char]
elif char in special_mapping:
result += special_mapping[char]
# Проверяем, не пустой ли результат
if not result:
return "Ошибка!"
return result
@loader.tds
class НадстрочкаMod(loader.Module):
"""Делает надстрочный текст"""
strings = {
"name": "Надстрочка",
}
def init(self):
self.name = self.strings["name"]
@loader.command()
async def upcmd(self, message: Message):
"""<text> - сделать верхний шрифт"""
mt = message.text[4:]
mt = replace_text(mt)
await utils.answer(message, f"<code>{mt}</code>")