aboutsummaryrefslogtreecommitdiffstats
path: root/bot/utils
diff options
context:
space:
mode:
authorGravatar ChrisJL <[email protected]>2021-04-23 14:20:41 +0100
committerGravatar GitHub <[email protected]>2021-04-23 14:20:41 +0100
commit993a280155cc4ebb4c64ad244dce988552bb5f58 (patch)
tree61724efbe03e5356de6bd880bae32956e8caa7d1 /bot/utils
parentFix spelling of a user facing message in reddit cog (diff)
parentMerge pull request #704 from python-discord/link-suppressing (diff)
Merge branch 'main' into fix-reddit-index-error
Diffstat (limited to 'bot/utils')
-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