- Регистрация
- 13 Июн 2022
- Сообщения
- 56
- Автор темы
- #1
Данный класс упрощает создание только текстовых клавиатур.
Python:
from aiogram.types import KeyboardButton, InlineKeyboardButton
from aiogram.utils.keyboard import (
ReplyKeyboardBuilder, InlineKeyboardBuilder
)
class builder:
def reply(buttons: list[str], adjust: int = 1, pResize_keyboard: bool = False, pOne_time: bool = False) -> str:
pbuilder = ReplyKeyboardBuilder()
[
pbuilder.add(KeyboardButton(text=str(item)))
for item in buttons
]
pbuilder.adjust(adjust)
return pbuilder.as_markup(resize_keyboard = pResize_keyboard, one_time= pOne_time)
def inline(buttons: dict, adjust: int = 1, pResize_keyboard: bool = False, pOne_time: bool = False) -> str:
pbuilder = InlineKeyboardBuilder()
[
pbuilder.add(InlineKeyboardButton(text=str(item), callback_data=buttons[item]))
for item in buttons
]
pbuilder.adjust(adjust)
return pbuilder.as_markup(resize_keyboard = pResize_keyboard, one_time= pOne_time)
builder.reply(buttons: list[str], adjust: int = 1, pResize_keyboard: bool = False, pOne_time: bool = False) |
|
builder.inline(buttons: dict, adjust: int = 1, pResize_keyboard: bool = False, pOne_time: bool = False) |
|