Skip to content

Instantly share code, notes, and snippets.

View IlmirSharifullin's full-sized avatar

Ilmir Sharifullin IlmirSharifullin

View GitHub Profile
class Singleton:
_instance = None
def __new__(cls):
if cls._instance is None:
print("Создание экземпляра")
cls._instance = super(Singleton, cls).__new__(cls)
return cls._instance
@IlmirSharifullin
IlmirSharifullin / paged_keyboard.py
Last active September 12, 2024 19:08
paged keyboard for aiogram3
COUNT_ON_PAGE = 10
COUNT_ON_LINE = 2
def get_paged_keyboard(data: list[str], page=1):
pages_count = math.ceil(len(data) / COUNT_ON_PAGE)
page = page % pages_count
cluster = data[(page - 1) * COUNT_ON_PAGE:page * COUNT_ON_PAGE]
builder = InlineKeyboardBuilder()
for i, el in enumerate(cluster):
RUS_MORSE = {'А': '.-', 'Б': '-...', 'В': '.--', 'Г': '--.', 'Д': '-..', 'Е': '.', 'Ё': '.', 'Ж': '...-',
'З': '--..', 'И': '..', 'Й': '.---', 'К': '-.-', 'Л': '.-..', 'М': '--', 'Н': '-.',
'О': '---',
'П': '.--.', 'Р': '.-.', 'С': '...', 'Т': '-', 'У': '..-', 'Ф': '..-.', 'Х': '....',
'Ц': '-.-.',
'Ч': '---.', 'Ш': '----', 'Щ': '--.-', 'Ъ': '--.--', 'Ы': '-.--', 'Ь': '-..-',
'Э': '..-..',
'Ю': '..--', 'Я': '.-.-'}