diff options
| author | 2022-09-28 08:39:48 +0100 | |
|---|---|---|
| committer | 2022-09-28 08:39:48 +0100 | |
| commit | ce16838adeff343156175d644b90dc68b0e88519 (patch) | |
| tree | e7df02c9f1adbccf3df09bf0e8e0c49e50a6800a | |
| parent | transform urls matched in messages (diff) | |
collect all urls in a set to avoid duplicates
| -rw-r--r-- | bot/exts/filters/filtering.py | 5 | 
1 files changed, 3 insertions, 2 deletions
| diff --git a/bot/exts/filters/filtering.py b/bot/exts/filters/filtering.py index db13df9b2..b61204f4a 100644 --- a/bot/exts/filters/filtering.py +++ b/bot/exts/filters/filtering.py @@ -650,12 +650,13 @@ class Filtering(Cog):          if msg.embeds:              for embed in msg.embeds:                  if embed.type == "rich": -                    urls = set(URL_RE.findall(msg.content)) +                    urls = URL_RE.findall(msg.content) +                    final_urls = set(urls)                      # 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)) +                        final_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. | 
