diff --git a/BotCode/keyboards/help_kb.py b/BotCode/keyboards/help_kb.py new file mode 100644 index 0000000..ac91539 --- /dev/null +++ b/BotCode/keyboards/help_kb.py @@ -0,0 +1,41 @@ +# 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) diff --git a/BotCode/keyboards/more_kb.py b/BotCode/keyboards/more_kb.py new file mode 100644 index 0000000..a96ff7d --- /dev/null +++ b/BotCode/keyboards/more_kb.py @@ -0,0 +1,39 @@ +# BotCode/keyboards/more_kb.py +# Создания клавиатуры на команду: /more + +from aiogram import Router +from aiogram.types import KeyboardButtonPollType +from aiogram.utils.keyboard import ReplyKeyboardBuilder + +# Создание роутера и настройка экспорта модулей +__all__ = ("router", "get_more_kb", "kb_text",) +kb_text = "HelpKb" +router = Router(name="more_kb_router") + + +# Класс с названиями кнопок +class ButtonText: + More = "More" + Location = "Отправить локацию" + Contact = "Отправить контакт" + Chat = "Отправить чат???" + Poll = "Отправить опрос" + Users = "Что то с common" + + +# Функция создания клавиатуры на команду: /more +def get_more_kb() -> ReplyKeyboardBuilder: + builder = ReplyKeyboardBuilder() + # builder.add(KeyboardButton(text=ButtonText.Location, request_location=True)) + builder.button(text=ButtonText.Location, request_location=True) + builder.button(text=ButtonText.Contact, request_contact=True) + builder.button(text=ButtonText.Poll, request_poll=KeyboardButtonPollType()) + + builder.adjust(1) + return builder.as_markup(resize_keyboard=True) + + # Один из вариантов создание клавиатуры + # markup = ReplyKeyboardMarkup( + # keyboard=[] + # ) + # return markup diff --git a/BotCode/keyboards/start_kb.py b/BotCode/keyboards/start_kb.py new file mode 100644 index 0000000..5299e82 --- /dev/null +++ b/BotCode/keyboards/start_kb.py @@ -0,0 +1,34 @@ +# BotCode/keyboards/start_kb.py +# Создания клавиатуры на команду: /start + +from aiogram import Router +from aiogram.types import ReplyKeyboardMarkup, KeyboardButton +from aiogram.utils.keyboard import ReplyKeyboardBuilder + +# Создание роутера и настройка экспорта +__all__ = ("router", "get_start_kb", "kb_text", "ButtonText",) +kb_text = "StartKb" +router = Router(name="start_kb_router") + + +# Класс с названиями кнопок +class ButtonText: + Hello = "Привет!" + Help = "Помогите!" + Bye = "Пока-пока!" + + +# Функция создания клавиатуры на команду: /start +def get_start_kb() -> ReplyKeyboardBuilder: + button_hello = KeyboardButton(text=ButtonText.Hello) + button_help = KeyboardButton(text=ButtonText.Help) + button_bye = KeyboardButton(text=ButtonText.Bye) + + buttons_first_row = [button_hello, button_help] + buttons_second_row = [button_bye] + markup = ReplyKeyboardMarkup( + keyboard=[buttons_first_row, buttons_second_row], + resize_keyboard=True, + one_time_keyboard=True, + ) + return markup