diff options
author | 2021-04-23 02:55:03 +0300 | |
---|---|---|
committer | 2021-04-23 02:55:03 +0300 | |
commit | e858a3682ffe36675570508802f633046b39ebd8 (patch) | |
tree | 75550fb9cb180d15873a7908bcd96ea527603f3a /bot/utils/helpers.py | |
parent | Merge pull request #697 from ToxicKidz/fix_catify (diff) |
Adds Link Suppressing Helper
Adds a helper to find and escape links in a message.
Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to 'bot/utils/helpers.py')
-rw-r--r-- | bot/utils/helpers.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/bot/utils/helpers.py b/bot/utils/helpers.py new file mode 100644 index 00000000..74c2ccd0 --- /dev/null +++ b/bot/utils/helpers.py @@ -0,0 +1,8 @@ +import re + + +def suppress_links(message: str) -> str: + """Accepts a message that may contain links, suppresses them, and returns them.""" + for link in set(re.findall(r"https?://[^\s]+", message, re.IGNORECASE)): + message = message.replace(link, f"<{link}>") + return message |