а
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 10s

This commit is contained in:
2026-04-02 22:30:55 +07:00
parent 3871fd554b
commit fd45c1864e

View File

@@ -122,6 +122,8 @@ def extract_template_text(message: Message) -> str | None:
def normalize_template_placeholders(template: str) -> str:
normalized = template
normalized = re.sub(r"<tg-emoji(\s+[^>]*?)emoji_id=", r"<tg-emoji\1emoji-id=", normalized, flags=re.IGNORECASE)
normalized = re.sub(r"<tg-emoji\s+emoji_id=", "<tg-emoji emoji-id=", normalized, flags=re.IGNORECASE)
normalized = re.sub(r"\\\{\\\{\s*actors\s*\\\}\\\}", "{{actors}}", normalized, flags=re.IGNORECASE)
normalized = re.sub(r"\{\{\s*actors\s*\}\}", "{{actors}}", normalized, flags=re.IGNORECASE)
normalized = re.sub(
@@ -205,6 +207,12 @@ async def show_actor_status_menu(callback: CallbackQuery, actor: dict[str, Any],
async def update_channel_post(bot: Bot, app_config: dict, state_storage: JsonStateStorage, settings) -> None:
state = state_storage.load()
if "template" in state and "text" in state["template"]:
normalized_template = normalize_template_placeholders(state["template"]["text"])
if normalized_template != state["template"]["text"]:
state["template"]["text"] = normalized_template
state_storage.save(state)
link_preview_options = None
if app_config.get("hidden_link_url", "").strip():
link_preview_options = LinkPreviewOptions(
@@ -272,6 +280,11 @@ def save_post_template(state_storage: JsonStateStorage, template: str) -> None:
async def send_test_post(bot: Bot, chat_id: int, app_config: dict, state_storage: JsonStateStorage) -> None:
state = state_storage.load()
if "template" in state and "text" in state["template"]:
normalized_template = normalize_template_placeholders(state["template"]["text"])
if normalized_template != state["template"]["text"]:
state["template"]["text"] = normalized_template
state_storage.save(state)
text = build_channel_text(app_config, state)
link_preview_options = None
if app_config.get("hidden_link_url", "").strip():