а
This commit is contained in:
@@ -122,6 +122,8 @@ def extract_template_text(message: Message) -> str | None:
|
|||||||
|
|
||||||
def normalize_template_placeholders(template: str) -> str:
|
def normalize_template_placeholders(template: str) -> str:
|
||||||
normalized = template
|
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(r"\{\{\s*actors\s*\}\}", "{{actors}}", normalized, flags=re.IGNORECASE)
|
normalized = re.sub(r"\{\{\s*actors\s*\}\}", "{{actors}}", normalized, flags=re.IGNORECASE)
|
||||||
normalized = re.sub(
|
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:
|
async def update_channel_post(bot: Bot, app_config: dict, state_storage: JsonStateStorage, settings) -> None:
|
||||||
state = state_storage.load()
|
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
|
link_preview_options = None
|
||||||
if app_config.get("hidden_link_url", "").strip():
|
if app_config.get("hidden_link_url", "").strip():
|
||||||
link_preview_options = LinkPreviewOptions(
|
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:
|
async def send_test_post(bot: Bot, chat_id: int, app_config: dict, state_storage: JsonStateStorage) -> None:
|
||||||
state = state_storage.load()
|
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)
|
text = build_channel_text(app_config, state)
|
||||||
link_preview_options = None
|
link_preview_options = None
|
||||||
if app_config.get("hidden_link_url", "").strip():
|
if app_config.get("hidden_link_url", "").strip():
|
||||||
|
|||||||
Reference in New Issue
Block a user