Files
limoka/Ruslan-Isaev/modules/Надстрочка.py
2025-07-10 21:02:34 +03:00

85 lines
2.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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