add row builder (da krutoi)
This commit is contained in:
1 parent
b5c986f784
commit
631fabf30d
2 files changed
+66
-26
No files matched your search
+49
-17
@@ -26,7 +26,10 @@ async def select_provider_callback(callback: CallbackQuery):
|
|||||||
|
|
||||||
buttons = []
|
buttons = []
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
|
||||||
for model in MODELS.get(provider):
|
for model in MODELS.get(provider):
|
||||||
|
i += 1
|
||||||
if f"{provider}*{model}" == user_model:
|
if f"{provider}*{model}" == user_model:
|
||||||
text = f"{model} ✅"
|
text = f"{model} ✅"
|
||||||
else:
|
else:
|
||||||
@@ -34,14 +37,21 @@ async def select_provider_callback(callback: CallbackQuery):
|
|||||||
|
|
||||||
if MODELS[provider][model].get("alias"):
|
if MODELS[provider][model].get("alias"):
|
||||||
model = MODELS[provider][model].get("alias")
|
model = MODELS[provider][model].get("alias")
|
||||||
|
|
||||||
buttons.append(
|
if not i % 2:
|
||||||
[
|
buttons[len(buttons)-1] +=[
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text=text, callback_data=f"set_model%{user_id}%{provider}*{model}"
|
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:
|
if not buttons:
|
||||||
buttons = [
|
buttons = [
|
||||||
@@ -53,7 +63,7 @@ async def select_provider_callback(callback: CallbackQuery):
|
|||||||
]
|
]
|
||||||
|
|
||||||
buttons.append(
|
buttons.append(
|
||||||
[InlineKeyboardButton(text="назад", callback_data=f"models%{user_id}")]
|
[InlineKeyboardButton(text="⬅️ назад", callback_data=f"models%{user_id}")]
|
||||||
)
|
)
|
||||||
|
|
||||||
await callback.message.edit_text(
|
await callback.message.edit_text(
|
||||||
@@ -72,16 +82,27 @@ async def models_callback(callback: CallbackQuery):
|
|||||||
config = get_user_config(user_id)
|
config = get_user_config(user_id)
|
||||||
|
|
||||||
buttons = []
|
buttons = []
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
|
||||||
for provider in MODELS:
|
for provider in MODELS:
|
||||||
buttons.append(
|
i += 1
|
||||||
[
|
if not i % 2:
|
||||||
|
buttons[len(buttons)-1] +=[
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text=PROVIDERS.get(provider).get("name"),
|
text=PROVIDERS.get(provider).get("name"),
|
||||||
callback_data=f"prov%{user_id}%{provider}",
|
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:
|
if not buttons:
|
||||||
buttons.append(
|
buttons.append(
|
||||||
@@ -93,7 +114,7 @@ async def models_callback(callback: CallbackQuery):
|
|||||||
)
|
)
|
||||||
|
|
||||||
buttons.append(
|
buttons.append(
|
||||||
[InlineKeyboardButton(text="назад", callback_data=f"settings%{user_id}")]
|
[InlineKeyboardButton(text="⬅️ назад", callback_data=f"settings%{user_id}")]
|
||||||
)
|
)
|
||||||
|
|
||||||
await callback.message.edit_text(
|
await callback.message.edit_text(
|
||||||
@@ -147,19 +168,30 @@ async def prompts_callback(callback: CallbackQuery):
|
|||||||
prompt = config.get("prompt")
|
prompt = config.get("prompt")
|
||||||
|
|
||||||
buttons = []
|
buttons = []
|
||||||
|
i = 0
|
||||||
|
|
||||||
for name in SYSTEM_PROMPTS:
|
for name in SYSTEM_PROMPTS:
|
||||||
|
i += 1
|
||||||
text = name
|
text = name
|
||||||
if prompt == name:
|
if prompt == name:
|
||||||
text += " ✅"
|
text += " ✅"
|
||||||
buttons.append(
|
|
||||||
[
|
if not i % 2:
|
||||||
|
buttons[len(buttons)-1] +=[
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text=text,
|
text=text,
|
||||||
callback_data=f"set_prompt%{user_id}%{name}",
|
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:
|
if not buttons:
|
||||||
buttons.append(
|
buttons.append(
|
||||||
@@ -171,7 +203,7 @@ async def prompts_callback(callback: CallbackQuery):
|
|||||||
)
|
)
|
||||||
|
|
||||||
buttons.append(
|
buttons.append(
|
||||||
[InlineKeyboardButton(text="назад", callback_data=f"settings%{user_id}")]
|
[InlineKeyboardButton(text="⬅️ назад", callback_data=f"settings%{user_id}")]
|
||||||
)
|
)
|
||||||
|
|
||||||
await callback.message.edit_text(
|
await callback.message.edit_text(
|
||||||
|
|||||||
+17
-9
@@ -341,14 +341,19 @@ async def settings_handler(event: Union[Message, CallbackQuery]):
|
|||||||
notify_status = "net"
|
notify_status = "net"
|
||||||
notify_cb = "da"
|
notify_cb = "da"
|
||||||
|
|
||||||
|
if config["markdown"] == "new":
|
||||||
|
markdown_status = "новый"
|
||||||
|
markdown_cb = "old"
|
||||||
|
else:
|
||||||
|
markdown_status = "старый"
|
||||||
|
markdown_cb = "new"
|
||||||
|
|
||||||
keyboard = InlineKeyboardMarkup(
|
keyboard = InlineKeyboardMarkup(
|
||||||
inline_keyboard=[
|
inline_keyboard=[
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text=f"модели ({models_count})", callback_data=f"models%{user_id}"
|
text=f"модели ({models_count})", callback_data=f"models%{user_id}"
|
||||||
)
|
),
|
||||||
],
|
|
||||||
[
|
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text=f"промпты ({prompts_count})", callback_data=f"prompts%{user_id}"
|
text=f"промпты ({prompts_count})", callback_data=f"prompts%{user_id}"
|
||||||
)
|
)
|
||||||
@@ -357,9 +362,7 @@ async def settings_handler(event: Union[Message, CallbackQuery]):
|
|||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text=f"стрим: {stream_status}",
|
text=f"стрим: {stream_status}",
|
||||||
callback_data=f"set_stream%{user_id}%{stream_cb}",
|
callback_data=f"set_stream%{user_id}%{stream_cb}",
|
||||||
)
|
),
|
||||||
],
|
|
||||||
[
|
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text=f"отклик: {call_status}",
|
text=f"отклик: {call_status}",
|
||||||
callback_data=f"set_call%{user_id}%{call_cb}",
|
callback_data=f"set_call%{user_id}%{call_cb}",
|
||||||
@@ -369,10 +372,15 @@ async def settings_handler(event: Union[Message, CallbackQuery]):
|
|||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text=f"рассылка: {notify_status}",
|
text=f"рассылка: {notify_status}",
|
||||||
callback_data=f"set_notify%{user_id}%{notify_cb}",
|
callback_data=f"set_notify%{user_id}%{notify_cb}",
|
||||||
)
|
),
|
||||||
|
InlineKeyboardButton(
|
||||||
|
text=f"маркдаун: {markdown_status}",
|
||||||
|
callback_data=f"set_markdown%{user_id}%{markdown_cb}",
|
||||||
|
),
|
||||||
|
|
||||||
],
|
],
|
||||||
[InlineKeyboardButton(text="донат", callback_data=f"donate%{user_id}")],
|
[InlineKeyboardButton(text="💸 донат", callback_data=f"donate%{user_id}")],
|
||||||
[InlineKeyboardButton(text="о боте", callback_data=f"about%{user_id}")],
|
[InlineKeyboardButton(text="🤖 о боте", callback_data=f"about%{user_id}")],
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user