aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2021-04-23 02:55:03 +0300
committerGravatar Hassan Abouelela <[email protected]>2021-04-23 02:55:03 +0300
commite858a3682ffe36675570508802f633046b39ebd8 (patch)
tree75550fb9cb180d15873a7908bcd96ea527603f3a
parentMerge 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]>
-rw-r--r--bot/utils/helpers.py8
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