diff options
author | 2021-04-23 07:07:27 +0300 | |
---|---|---|
committer | 2021-04-23 07:07:27 +0300 | |
commit | d02c79e569092dbd6823f2edb6c78ed8ab1bcae4 (patch) | |
tree | dfb295b69ab9031b4079b9fd3d4dbc44941edb13 /bot/utils/helpers.py | |
parent | Merge pull request #697 from ToxicKidz/fix_catify (diff) | |
parent | Suppresses Links In Commands (diff) |
Merge pull request #704 from python-discord/link-suppressing
Suppress Links In Certain Commands
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 |