diff options
| author | huker667 <huker@tuta.io> | 2026-07-14 20:45:25 +0300 |
|---|---|---|
| committer | huker667 <huker@tuta.io> | 2026-07-14 20:45:25 +0300 |
| commit | 631fabf30dec054aa0c7561dbbbf862527096b71 (patch) | |
| tree | 7982f475ec2309b423d2191f0da4aec26e94f0cc /callbacks.py | |
| parent | b5c986f78462eb3d8415e1874a2e957e6392a602 (diff) | |
| download | uzbekgpt-631fabf30dec054aa0c7561dbbbf862527096b71.tar.gz uzbekgpt-631fabf30dec054aa0c7561dbbbf862527096b71.tar.bz2 uzbekgpt-631fabf30dec054aa0c7561dbbbf862527096b71.zip | |
add row builder (da krutoi)
Diffstat (limited to 'callbacks.py')
| -rw-r--r-- | callbacks.py | 66 |
1 files changed, 49 insertions, 17 deletions
diff --git a/callbacks.py b/callbacks.py index c411d75..432c0af 100644 --- a/callbacks.py +++ b/callbacks.py @@ -26,7 +26,10 @@ async def select_provider_callback(callback: CallbackQuery): buttons = [] + i = 0 + for model in MODELS.get(provider): + i += 1 if f"{provider}*{model}" == user_model: text = f"{model} ✅" else: @@ -34,14 +37,21 @@ async def select_provider_callback(callback: CallbackQuery): if MODELS[provider][model].get("alias"): model = MODELS[provider][model].get("alias") - - buttons.append( - [ + + if not i % 2: + buttons[len(buttons)-1] +=[ InlineKeyboardButton( text=text, callback_data=f"set_model%{user_id}%{provider}*{model}" ) ] - ) + else: + buttons.append( + [ + InlineKeyboardButton( + text=text, callback_data=f"set_model%{user_id}%{provider}*{model}" + ) + ] + ) if not buttons: buttons = [ @@ -53,7 +63,7 @@ async def select_provider_callback(callback: CallbackQuery): ] buttons.append( - [InlineKeyboardButton(text="назад", callback_data=f"models%{user_id}")] + [InlineKeyboardButton(text="⬅️ назад", callback_data=f"models%{user_id}")] ) await callback.message.edit_text( @@ -72,16 +82,27 @@ async def models_callback(callback: CallbackQuery): config = get_user_config(user_id) buttons = [] + + i = 0 for provider in MODELS: - buttons.append( - [ + i += 1 + if not i % 2: + buttons[len(buttons)-1] +=[ InlineKeyboardButton( - text=PROVIDERS.get(provider).get("name"), - callback_data=f"prov%{user_id}%{provider}", + text=PROVIDERS.get(provider).get("name"), + callback_data=f"prov%{user_id}%{provider}" ) ] - ) + else: + buttons.append( + [ + InlineKeyboardButton( + text=PROVIDERS.get(provider).get("name"), + callback_data=f"prov%{user_id}%{provider}", + ) + ] + ) if not buttons: buttons.append( @@ -93,7 +114,7 @@ async def models_callback(callback: CallbackQuery): ) buttons.append( - [InlineKeyboardButton(text="назад", callback_data=f"settings%{user_id}")] + [InlineKeyboardButton(text="⬅️ назад", callback_data=f"settings%{user_id}")] ) await callback.message.edit_text( @@ -147,19 +168,30 @@ async def prompts_callback(callback: CallbackQuery): prompt = config.get("prompt") buttons = [] + i = 0 for name in SYSTEM_PROMPTS: + i += 1 text = name if prompt == name: text += " ✅" - buttons.append( - [ + + if not i % 2: + buttons[len(buttons)-1] +=[ InlineKeyboardButton( - text=text, - callback_data=f"set_prompt%{user_id}%{name}", + text=text, + callback_data=f"set_prompt%{user_id}%{name}" ) ] - ) + else: + buttons.append( + [ + InlineKeyboardButton( + text=text, + callback_data=f"set_prompt%{user_id}%{name}", + ) + ] + ) if not buttons: buttons.append( @@ -171,7 +203,7 @@ async def prompts_callback(callback: CallbackQuery): ) buttons.append( - [InlineKeyboardButton(text="назад", callback_data=f"settings%{user_id}")] + [InlineKeyboardButton(text="⬅️ назад", callback_data=f"settings%{user_id}")] ) await callback.message.edit_text( |