diff options
author | 2021-09-06 13:36:42 +0100 | |
---|---|---|
committer | 2021-09-06 13:44:10 +0100 | |
commit | fddd34158b3fda284bd39970297c00e7d54d122a (patch) | |
tree | 5b4f8312444aff21db1e36faac0929e474e56c0c | |
parent | Only check URL-like objects against domain filters (diff) |
Refactor & simplifiy domain filter check
-rw-r--r-- | bot/exts/filters/filtering.py | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/bot/exts/filters/filtering.py b/bot/exts/filters/filtering.py index b7e91395e..7e698880f 100644 --- a/bot/exts/filters/filtering.py +++ b/bot/exts/filters/filtering.py @@ -478,17 +478,12 @@ class Filtering(Cog): Second return value is a reason of URL blacklisting (can be None). """ text = self.clean_input(text) - matches = URL_RE.findall(text) - if not matches: - return False, None domain_blacklist = self._get_filterlist_items("domain_name", allowed=False) - - for url in domain_blacklist: - for match in matches: - if url.lower() in match.lower(): + for match in URL_RE.finditer(text): + for url in domain_blacklist: + if url.lower() in match.group(1).lower(): return True, self._get_filterlist_value("domain_name", url, allowed=False)["comment"] - return False, None @staticmethod |