42авфаыв
Some checks failed
CI / Lint (ruff + mypy) (push) Failing after 32s
CI / Run tests (push) Has been skipped
CI / Docker build test (push) Successful in 11s

This commit is contained in:
2026-04-02 22:41:38 +07:00
parent fd45c1864e
commit 94afa86920
3 changed files with 115 additions and 6 deletions

View File

@@ -16,6 +16,7 @@ from aiogram.types import CallbackQuery, LinkPreviewOptions, Message
from aiogram.utils.keyboard import InlineKeyboardBuilder
from session_bot.config import load_actor_config, load_settings
from session_bot.html_entities import html_to_text_entities
from session_bot.render import build_channel_text
from session_bot.storage import JsonStateStorage
@@ -220,13 +221,14 @@ async def update_channel_post(bot: Bot, app_config: dict, state_storage: JsonSta
show_above_text=True,
)
text = build_channel_text(app_config, state)
html_text = build_channel_text(app_config, state)
text, entities = html_to_text_entities(html_text)
try:
await bot.edit_message_text(
chat_id=settings.channel_id,
message_id=settings.channel_message_id,
text=text,
parse_mode=ParseMode.HTML,
entities=entities,
link_preview_options=link_preview_options,
)
except TelegramBadRequest as exc:
@@ -241,12 +243,13 @@ async def update_channel_post(bot: Bot, app_config: dict, state_storage: JsonSta
fallback_state = dict(state)
fallback_state["template"] = {"text": sanitize_template_html(template)}
fallback_text = build_channel_text(app_config, fallback_state)
fallback_html = build_channel_text(app_config, fallback_state)
fallback_text, fallback_entities = html_to_text_entities(fallback_html)
await bot.edit_message_text(
chat_id=settings.channel_id,
message_id=settings.channel_message_id,
text=fallback_text,
parse_mode=ParseMode.HTML,
entities=fallback_entities,
link_preview_options=link_preview_options,
)
@@ -285,7 +288,8 @@ async def send_test_post(bot: Bot, chat_id: int, app_config: dict, state_storage
if normalized_template != state["template"]["text"]:
state["template"]["text"] = normalized_template
state_storage.save(state)
text = build_channel_text(app_config, state)
html_text = build_channel_text(app_config, state)
text, entities = html_to_text_entities(html_text)
link_preview_options = None
if app_config.get("hidden_link_url", "").strip():
link_preview_options = LinkPreviewOptions(
@@ -296,7 +300,7 @@ async def send_test_post(bot: Bot, chat_id: int, app_config: dict, state_storage
await bot.send_message(
chat_id=chat_id,
text=text,
parse_mode=ParseMode.HTML,
entities=entities,
link_preview_options=link_preview_options,
)