[ZILANT] отладка до-редактирования ссылок в пост
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
+28
-2
@@ -58,6 +58,32 @@ EDIT_LINKS_MAX_ATTEMPTS = 5
|
||||
EDIT_LINKS_RETRY_INTERVAL_SEC = 2
|
||||
|
||||
|
||||
def published_message_has_links(text: str, entities=None) -> bool:
|
||||
"""
|
||||
Проверка, что в опубликованном caption/text есть кликабельные ссылки.
|
||||
|
||||
Telegram в ответе editMessage* отдаёт plain text (без href=) и entities типа text_link.
|
||||
"""
|
||||
if entities:
|
||||
for ent in entities:
|
||||
if isinstance(ent, dict):
|
||||
if ent.get("type") == "text_link" and ent.get("url"):
|
||||
return True
|
||||
elif getattr(ent, "type", None) == "text_link" and getattr(ent, "url", None):
|
||||
return True
|
||||
|
||||
if not text:
|
||||
return False
|
||||
|
||||
link_markers = (
|
||||
"Оригинал в ВК",
|
||||
"Подписка",
|
||||
"Инфо",
|
||||
"Иду",
|
||||
)
|
||||
return any(marker in text for marker in link_markers)
|
||||
|
||||
|
||||
def published_text_has_links(text: str) -> bool:
|
||||
"""В caption/text после edit должны появиться HTML-ссылки."""
|
||||
return bool(text) and "href=" in text
|
||||
"""Обратная совместимость; предпочтительно published_message_has_links."""
|
||||
return published_message_has_links(text)
|
||||
|
||||
Reference in New Issue
Block a user