feat: перевести навигацию справки на inline-клавиатуру

This commit is contained in:
hermes committed 2026-10-11 22:55:17 +02:00
1 parent da0da91479
commit a11b5aac64
7 files changed
+105 -90

No files matched your search

+1 -34
View File
@@ -64,38 +64,6 @@ HELP_SECTIONS: dict[str, tuple[str, str]] = {
}
HELP_SECTION_ORDER: tuple[str, ...] = tuple(HELP_SECTIONS)
HELP_BUTTON_ROW_WIDTH = 24
def _menu_buttons(current: str | None = None) -> str:
buttons: list[tuple[str, str]] = []
for section in HELP_SECTION_ORDER:
title = HELP_SECTIONS[section][0]
if section == current:
button = f'<tg-button type="disabled">{title}</tg-button>'
else:
button = (
f'<tg-button type="callback_data" data="help:{section}" style="primary">'
f"{title}</tg-button>"
)
buttons.append((title, button))
rows = []
row: list[str] = []
row_width = 0
for title, button in buttons:
button_width = len(title)
separator_width = 1 if row else 0
if row and row_width + separator_width + button_width > HELP_BUTTON_ROW_WIDTH:
rows.append(f'<tg-button-row align="left">{"".join(row)}</tg-button-row>')
row = []
row_width = 0
separator_width = 0
row.append(button)
row_width += separator_width + button_width
if row:
rows.append(f'<tg-button-row align="left">{"".join(row)}</tg-button-row>')
return "".join(rows)
def help_menu_html(current: str | None = None) -> str:
@@ -104,13 +72,12 @@ def help_menu_html(current: str | None = None) -> str:
f"<p>{HELP_MENU_INTRO}</p>"
f"<p>Я помогаю писать и редактировать посты для соцсетей. "
f"Генерирую посты только по явной просьбе.</p>"
f"{_menu_buttons(current)}"
)
def help_section_html(section: str) -> str:
title, body = HELP_SECTIONS[section]
return f"<h1>{title}</h1>{body}{_menu_buttons(section)}"
return f"<h1>{title}</h1>{body}"
def help_view(section: str | None = None) -> str: