From dcba11ce55b867484b2a889a1d91a7a2d60f6e3a Mon Sep 17 00:00:00 2001 From: vvzvlad Date: Mon, 24 Mar 2025 16:33:52 +0300 Subject: [PATCH] Update post_parser to conditionally add hyperlinks to short descriptions and clean up unused code --- post_parser.py | 10 +++------- pyrogram-bridge.code-workspace | 8 ++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 pyrogram-bridge.code-workspace diff --git a/post_parser.py b/post_parser.py index 81899db..42203e5 100644 --- a/post_parser.py +++ b/post_parser.py @@ -490,8 +490,9 @@ class PostParser: if description := getattr(webpage, "description", None): # Process the description to handle line breaks and possibly HTML processed_description = description.replace('\n', '
') - # Check for unlinked URLs and turn them into links - processed_description = self._add_hyperlinks_to_raw_urls(processed_description) + # Check for unlinked URLs and turn them into links only if description is short + if len(processed_description.strip()) <= 10: + processed_description = self._add_hyperlinks_to_raw_urls(processed_description) html_parts.append(f'
{processed_description}
') # Display URL for non-telegram links or when display_url is available @@ -502,11 +503,6 @@ class PostParser: html_parts.append(f'
{display_url}
') elif url: html_parts.append(f'
{url}
') - #else: - # # Show Telegram URL (more subtle than button) - # display_url = getattr(webpage, "display_url", None) - # if display_url: - # html_parts.append(f'
{display_url}
') # Add photo if available if photo := getattr(webpage, "photo", None): diff --git a/pyrogram-bridge.code-workspace b/pyrogram-bridge.code-workspace new file mode 100644 index 0000000..876a149 --- /dev/null +++ b/pyrogram-bridge.code-workspace @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": {} +} \ No newline at end of file