Implement URL-based title generation

This commit is contained in:
vvzvlad
2025-04-08 18:38:13 +03:00
parent ee56ac41f2
commit 2a8326be06
2 changed files with 27 additions and 5 deletions
+7
View File
@@ -145,6 +145,13 @@ class PostParser:
# If there was a YouTube link
if re.search(r'(?:youtube\.com|youtu\.be)', text_stripped.lower()):
return "🎥 YouTube Link"
# Check if we have a web_page with title and text is basically just a URL
if message.web_page and message.web_page.title:
# Проверяем, что текст - это по сути только URL
url_match = re.match(r'^(https?://[^\s<>"\']+)$', text_stripped)
if url_match:
return f"🔗 {message.web_page.title}"
# Otherwise, it's a normal web link
return "🔗 Web link"