Skip to content

Commit d76931c

Browse files
committed
remove @username from video url
1 parent 21673a4 commit d76931c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/main.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,24 @@ def is_bot_mentioned(message_text: str) -> bool:
109109

110110
def clean_url(message_text: str) -> str:
111111
"""
112-
Cleans the URL from the message text by removing unwanted characters.
112+
Cleans the URL from the message text by removing unwanted characters and usernames.
113113
114114
Args:
115115
message_text (str): The text of the message containing the URL.
116116
117117
Returns:
118118
str: The cleaned URL.
119119
"""
120-
return message_text.replace("**", "") if message_text.startswith("**") else message_text
120+
# Remove markdown formatting
121+
url = message_text.replace("**", "")
122+
123+
# Split by space and take the first part (the URL)
124+
url = url.split()[0]
125+
126+
# Remove any @username from the end of the URL
127+
url = url.split('@')[0]
128+
129+
return url
121130

122131

123132
def is_large_file(file_path: str, max_size_mb: int = 50) -> bool:

0 commit comments

Comments
 (0)