ир
This commit is contained in:
@@ -9,7 +9,11 @@ PLAIN_LINK_RE = re.compile(r"(?P<label>[^\n<>()]+?) \((?P<url>https?://[^\s)]+)\
|
||||
|
||||
|
||||
def build_hidden_link(config: dict) -> str:
|
||||
return ""
|
||||
url = config.get("hidden_link_url", "").strip()
|
||||
if not url:
|
||||
return ""
|
||||
char = config.get("hidden_link_char", "​") or "​"
|
||||
return f'<a href="{escape(url, quote=True)}">{char}</a>'
|
||||
|
||||
|
||||
def convert_plain_links_to_html(template: str) -> str:
|
||||
@@ -101,13 +105,16 @@ def build_default_template(config: dict) -> str:
|
||||
return "\n\n".join(blocks)
|
||||
|
||||
|
||||
def build_channel_text(config: dict, state: dict) -> str:
|
||||
def build_channel_text(config: dict, state: dict, *, include_hidden_link: bool = False) -> str:
|
||||
template = state.get("template", {}).get("text") or config.get("template_text") or build_default_template(config)
|
||||
template = convert_plain_links_to_html(template)
|
||||
template, used_keys = replace_actor_placeholders(template, config, state)
|
||||
actors_block = build_actor_lines(config, state, skip_keys=used_keys)
|
||||
|
||||
text = template.replace("{{actors}}", actors_block)
|
||||
hidden_link = build_hidden_link(config) if include_hidden_link else ""
|
||||
text = text.replace("{{hidden_link}}", "")
|
||||
if include_hidden_link and hidden_link:
|
||||
text = f"{hidden_link}{text}"
|
||||
|
||||
return text
|
||||
|
||||
Reference in New Issue
Block a user