Files
PrimoPearlBot/BotCode/keyboards/help_kb.py

42 lines
1.3 KiB
Python
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# BotCode/keyboards/help_kb.py
# Создание клавиатуры для сообщения: "Помогите!"
from aiogram import Router, F
from aiogram.types import ReplyKeyboardMarkup, KeyboardButton
from aiogram.utils.keyboard import ReplyKeyboardBuilder
# Создание роутера и настройка экспорта модулей
__all__ = ("router", "get_help_kb", "kb_text",)
kb_text = "HelpKb"
router = Router(name="help_kb_router")
# Функция создания клавиатуры на сообщение: "Помогите!"
@router.message(F.text.lower() == "помогите!")
def get_help_kb() -> ReplyKeyboardMarkup:
numbers = [
"1", "2", "3",
"4", "5", "6",
"7", "8", "9",
"0",
]
buttons_row = [KeyboardButton(text=num) for num in numbers]
# Один из способов создания клавиатур
#
# markup = ReplyKeyboardMarkup(
# keyboard=[buttons_row],
# resize_keyboard=True,
# )
# return markup
builder = ReplyKeyboardBuilder()
for num in numbers:
builder.button(text=num)
builder.adjust(3)
builder.row(buttons_row[3], buttons_row[9])
builder.add(buttons_row[-1])
return builder.as_markup(resize_keyboard=True)