feat: перевести навигацию справки на inline-клавиатуру
This commit is contained in:
1 parent
da0da91479
commit
a11b5aac64
7 files changed
+105
-90
No files matched your search
@@ -39,7 +39,7 @@ from raw_updates import RawUpdateMiddleware, init_raw_updates_db
|
||||
|
||||
from apinex_client import APINEX_STT_URL, POST_HISTORY_CHAR_LIMIT, POST_HISTORY_LIMIT, classify_intent, classify_prompt_injection, create_tone_profile, current_operation_id, diagnostic_operation, extract_posts_from_images, extract_transcript, generate_ideas, generate_posts, generate_posts_from_images, transcribe_audio
|
||||
from help_message import WELCOME_RICH_HTML, help_plain_view, help_view, rich_to_plain
|
||||
from keyboards import MAIN_MENU_VALUE, SUPPORT_VALUE, TRAINING_RESET_VALUE, main_menu_keyboard, mode_keyboard, resolve_button_text
|
||||
from keyboards import MAIN_MENU_VALUE, SUPPORT_VALUE, TRAINING_RESET_VALUE, help_inline_keyboard, main_menu_keyboard, mode_keyboard, resolve_button_text
|
||||
from payments import send_subscription_invoice
|
||||
import support
|
||||
from user_store import (
|
||||
@@ -174,7 +174,12 @@ async def enter_mode(message: Message, state: FSMContext, mode: str) -> None:
|
||||
await state.set_state(MODE_STATES[mode])
|
||||
title, description = MODE_COPY[mode]
|
||||
if mode == "help":
|
||||
await send_rich_message(message, help_view(None), "помощи")
|
||||
await send_rich_message(
|
||||
message,
|
||||
help_view(None),
|
||||
"помощи",
|
||||
reply_markup=help_inline_keyboard(),
|
||||
)
|
||||
await message.answer(
|
||||
f"Режим «{title}».\n{description}",
|
||||
reply_markup=mode_keyboard(mode),
|
||||
@@ -354,7 +359,11 @@ async def send_rich_message(
|
||||
return None
|
||||
|
||||
|
||||
async def edit_rich_message(message: Message, rich_html: str) -> bool:
|
||||
async def edit_rich_message(
|
||||
message: Message,
|
||||
rich_html: str,
|
||||
reply_markup: InlineKeyboardMarkup | None = None,
|
||||
) -> bool:
|
||||
bot = message.bot
|
||||
if message.message_id is None:
|
||||
return False
|
||||
@@ -363,9 +372,12 @@ async def edit_rich_message(message: Message, rich_html: str) -> bool:
|
||||
chat_id=message.chat.id,
|
||||
message_id=message.message_id,
|
||||
rich_message=InputRichMessage(html=rich_html),
|
||||
reply_markup=reply_markup,
|
||||
)
|
||||
return True
|
||||
except Exception as exc:
|
||||
if "message is not modified" in str(exc).casefold():
|
||||
return True
|
||||
logger.warning("Rich help edit failed (%s): %s", type(exc).__name__, str(exc)[:180])
|
||||
return False
|
||||
|
||||
@@ -379,7 +391,11 @@ async def help_navigation(callback: CallbackQuery, state: FSMContext) -> None:
|
||||
await callback.answer("Сначала открой режим /help.", show_alert=True)
|
||||
return
|
||||
section = (callback.data or "help:menu").split(":", 1)[1]
|
||||
if not await edit_rich_message(message, help_view(section)):
|
||||
if not await edit_rich_message(
|
||||
message,
|
||||
help_view(section),
|
||||
reply_markup=help_inline_keyboard(),
|
||||
):
|
||||
await callback.answer("Не удалось обновить справку, открой /help заново", show_alert=True)
|
||||
return
|
||||
await callback.answer()
|
||||
@@ -686,7 +702,12 @@ async def help_command(message: Message, state: FSMContext | None = None) -> Non
|
||||
if state is not None:
|
||||
await enter_mode(message, state, "help")
|
||||
return
|
||||
await send_rich_message(message, help_view(None), "помощи")
|
||||
await send_rich_message(
|
||||
message,
|
||||
help_view(None),
|
||||
"помощи",
|
||||
reply_markup=help_inline_keyboard(),
|
||||
)
|
||||
await message.answer(
|
||||
"Режим «Помощь». Выбери раздел выше или другой режим в меню.",
|
||||
reply_markup=mode_keyboard("help"),
|
||||
|
||||
Reference in new issue
Block a user