mirror of
https://github.com/father-bot/chatgpt_telegram_bot.git
synced 2026-08-03 13:27:16 +03:00
Lay out settings model buttons in rows of two
The settings menu put every model button in a single row. Telegram rejects rows with more than 8 inline buttons, which would break /settings now that the model list is longer. Chunk the buttons into rows of two.
This commit is contained in:
+5
-2
@@ -684,7 +684,8 @@ def get_settings_menu(user_id: int):
|
||||
|
||||
text += "\nSelect <b>model</b>:"
|
||||
|
||||
# buttons to choose models
|
||||
# buttons to choose models (chunked into rows of 2 to stay within
|
||||
# Telegram's per-row button limit as the model list grows)
|
||||
buttons = []
|
||||
for model_key in config.models["available_text_models"]:
|
||||
title = config.models["info"][model_key]["name"]
|
||||
@@ -694,7 +695,9 @@ def get_settings_menu(user_id: int):
|
||||
buttons.append(
|
||||
InlineKeyboardButton(title, callback_data=f"set_settings|{model_key}")
|
||||
)
|
||||
reply_markup = InlineKeyboardMarkup([buttons])
|
||||
|
||||
keyboard = [buttons[i:i + 2] for i in range(0, len(buttons), 2)]
|
||||
reply_markup = InlineKeyboardMarkup(keyboard)
|
||||
|
||||
return text, reply_markup
|
||||
|
||||
|
||||
Reference in New Issue
Block a user