Files
limoka/trololo65/Modules/Morze.py
2025-07-10 21:02:34 +03:00

60 lines
3.8 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 asyncio
import logging
from .. import loader, utils
logger = logging.getLogger(__name__)
@loader.tds
class MorzeMod(loader.Module):
"""Конвертация текста в шифр Морзе и наоборот.
Символы использовать не советую, могут возникать ошибки!!"""
strings = {
"name": "Morze"
}
@loader.unrestricted
async def tomrzcmd(self, message):
""".tomrz [реплай или текст]"""
de = {'А': '•- ', 'Б': '-••• ', 'В': '•-- ', 'Г': '--• ', 'Д': '-•• ', 'Е': '', 'Ё': '', 'Ж': '•••- ', 'З': '--•• ', 'И': '•• ', 'Й': '•--- ', 'К': '-•- ', 'Л': '•-•• ', 'М': '-- ', 'Н': '-• ', 'О': '--- ', 'П': '•--• ', 'Р': '•-• ', 'С': '••• ', 'Т': '- ', 'У': '••- ', 'Ф': '••-• ', 'Х': '•••• ', 'Ц': '-•-• ', 'Ч': '---• ', 'Ш': '---- ', 'Щ': '--•- ', 'Ъ': '--•-- ', 'Ы': '-•-- ', 'Ь': '-••- ', 'Э': '••-•• ', 'Ю': '••-- ', 'Я': '•-•- ' ,'1': '•---- ','2':'••--- ','3':'•••-- ','4':'••••- ','5':'••••• ','6':'-•••• ','7':'--••• ','8':'---•• ','9':'----• ','0':'----- ','.':'•••••• ',',':'•-•-•- ',';':'-•-•-• ',':':'---••• ','?':'••--•• ','!':'--••-- ','-':'-••••- ','(':'-•--• ', ')':'-•--•- ', '/':'-••-• ' ,'"':'•-••-• ','+':'•-•-• ', '_':'••--•- ', '$':'•••-••- ', '@':'•--•-• ', '=':'-•••- ', '&':'•-••• ', }
reply = await message.get_reply_message()
text = utils.get_args_raw(message)
if reply and not text:
text = reply.raw_text
if not text:
return await utils.answer(message, "<code>Вы не ввели текст или не сделали реплай.</code>")
x = ''
for word in text.split():
for letter in word.upper():
x += de[letter]
x+=' '
await message.edit(x)
@loader.unrestricted
async def toabccmd(self, message):
""".toabc [реплай или текст]"""
en = {'•-': 'А', '-•••': 'Б', '•--': 'В', '--•': 'Г', '-••': 'Д', '': 'Е', '•••-': 'Ж', '--••': 'З', '••': 'И', '•---': 'Й', '-•-': 'К', '•-••': 'Л', '--': 'М', '-•': 'Н', '---': 'О', '•--•': 'П', '•-•': 'Р', '•••': 'С', '-': 'Т', '••-': 'У', '••-•': 'Ф', '••••': 'Х', '-•-•': 'Ц', '---•': 'Ч', '----': 'Ш', '--•-': 'Щ', '--•--': 'Ъ', '-•--': 'Ы', '-••-': 'Ь', '••-••': 'Э', '••--': 'Ю', '•-•-': 'Я' ,'•----': '1', '••---': '2', '•••--': '3', '••••-': '4', '•••••': '5', '-••••': '6', '--•••': '7', '---••': '8', '----•': '9', '-----': '0', '••••••': '.', '•-•-•-': ',', '-•-•-•': ';', '---•••': ':', '••--••': '?', '--••--': '!', '-••••-': '-', '-•--•-': ')', '-•--•':'(', '-••-•': '/', '•-••-•': '"', '•-•-•': '+', '••--•-': '_', '•••-••-':'$', '•--•-•':'@', '-•••-':'=', '•-•••':'&' }
reply = await message.get_reply_message()
text = utils.get_args_raw(message)
if reply and not text:
text = reply.raw_text
if not text:
return await utils.answer(message, "<code>Вы не ввели текст или не сделали реплай.</code>")
x = ''
for word in text.split(' '):
for letter in word.split():
x += en[letter].lower()
x+=' '
await message.edit(x)