diff --git a/src/main.py b/src/main.py index e8ea689..64b858f 100644 --- a/src/main.py +++ b/src/main.py @@ -109,7 +109,7 @@ def is_bot_mentioned(message_text: str) -> bool: def clean_url(message_text: str) -> str: """ - Cleans the URL from the message text by removing unwanted characters. + Cleans the URL from the message text by removing unwanted characters and usernames. Args: message_text (str): The text of the message containing the URL. @@ -117,7 +117,16 @@ def clean_url(message_text: str) -> str: Returns: str: The cleaned URL. """ - return message_text.replace("**", "") if message_text.startswith("**") else message_text + # Remove markdown formatting + url = message_text.replace("**", "") + + # Split by space and take the first part (the URL) + url = url.split()[0] + + # Remove any @username from the end of the URL + url = url.split('@')[0] + + return url def is_large_file(file_path: str, max_size_mb: int = 50) -> bool: diff --git a/src/requirements.txt b/src/requirements.txt index 7487608..11ae7bb 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -1,5 +1,5 @@ python-telegram-bot[ext]==22.0 -python-dotenv==1.0.1 -yt-dlp==2025.3.25 -gallery-dl==1.29.2 +python-dotenv==1.1.0 +yt-dlp==2025.3.31 +gallery-dl==1.29.4 aiohttp==3.9.3