Refactor keyboard layout for improved organization and add admin keyboard tests

- Updated the keyboard layout in `get_reply_keyboard` and `get_reply_keyboard_admin` functions to use `row` for better organization of buttons.
- Added unit tests for the admin keyboard to verify button arrangement and functionality.
- Ensured that each button is placed in its own row for clarity in the user interface.
This commit is contained in:
2025-08-27 20:20:53 +03:00
parent dc0e5d788c
commit 748670816f
2 changed files with 39 additions and 10 deletions

View File

@@ -18,11 +18,11 @@ def get_reply_keyboard_for_post():
def get_reply_keyboard(BotDB, user_id):
builder = ReplyKeyboardBuilder()
builder.add(types.KeyboardButton(text="📢Предложить свой пост"))
builder.add(types.KeyboardButton(text="📩Связаться с админами"))
builder.add(types.KeyboardButton(text="👋🏼Сказать пока!"))
builder.row(types.KeyboardButton(text="📢Предложить свой пост"))
builder.row(types.KeyboardButton(text="📩Связаться с админами"))
builder.row(types.KeyboardButton(text="👋🏼Сказать пока!"))
if not BotDB.get_info_about_stickers(user_id=user_id):
builder.add(types.KeyboardButton(text="🤪Хочу стикеры"))
builder.row(types.KeyboardButton(text="🤪Хочу стикеры"))
markup = builder.as_markup(resize_keyboard=True, one_time_keyboard=True)
return markup
@@ -36,12 +36,15 @@ def get_reply_keyboard_leave_chat():
def get_reply_keyboard_admin():
builder = ReplyKeyboardBuilder()
builder.add(types.KeyboardButton(text="Бан (Список)"))
builder.add(types.KeyboardButton(text="Бан по нику"))
builder.add(types.KeyboardButton(text="Бан по ID"))
builder.row()
builder.add(types.KeyboardButton(text="Разбан (список)"))
builder.add(types.KeyboardButton(text="Вернуться в бота"))
builder.row(
types.KeyboardButton(text="Бан (Список)"),
types.KeyboardButton(text="Бан по нику"),
types.KeyboardButton(text="Бан по ID")
)
builder.row(
types.KeyboardButton(text="Разбан (список)"),
types.KeyboardButton(text="Вернуться в бота")
)
markup = builder.as_markup(resize_keyboard=True, one_time_keyboard=True)
return markup