aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/exts/filters/filtering.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/bot/exts/filters/filtering.py b/bot/exts/filters/filtering.py
index e4df0b1fd..db13df9b2 100644
--- a/bot/exts/filters/filtering.py
+++ b/bot/exts/filters/filtering.py
@@ -23,10 +23,12 @@ from bot.constants import Bot as BotConfig, Channels, Colours, Filter, Guild, Ic
from bot.exts.events.code_jams._channels import CATEGORY_NAME as JAM_CATEGORY_NAME
from bot.exts.moderation.modlog import ModLog
from bot.log import get_logger
+from bot.utils.helpers import remove_subdomain_from_url
from bot.utils.messages import format_user
log = get_logger(__name__)
+
# Regular expressions
CODE_BLOCK_RE = re.compile(
r"(?P<delim>``?)[^`]+?(?P=delim)(?!`+)" # Inline codeblock
@@ -583,7 +585,7 @@ class Filtering(Cog):
"""
text = self.clean_input(text)
- # Remove backslashes to prevent escape character aroundfuckery like
+ # Remove backslashes to prevent escape character around fuckery like
# discord\.gg/gdudes-pony-farm
text = text.replace("\\", "")
@@ -648,7 +650,12 @@ class Filtering(Cog):
if msg.embeds:
for embed in msg.embeds:
if embed.type == "rich":
- urls = URL_RE.findall(msg.content)
+ urls = set(URL_RE.findall(msg.content))
+ # This is due to way discord renders relative urls in Embdes
+ # if we send the following url: https://mobile.twitter.com/something
+ # Discord renders it as https://twitter.com/something
+ for url in urls:
+ urls.add(remove_subdomain_from_url(url))
if not embed.url or embed.url not in urls:
# If `embed.url` does not exist or if `embed.url` is not part of the content
# of the message, it's unlikely to be an auto-generated embed by Discord.