diff options
-rw-r--r-- | bot/exts/filtering/_filter_lists/domain.py | 6 | ||||
-rw-r--r-- | bot/exts/filtering/_ui/ui.py | 11 |
2 files changed, 13 insertions, 4 deletions
diff --git a/bot/exts/filtering/_filter_lists/domain.py b/bot/exts/filtering/_filter_lists/domain.py index 6b1a568bc..2bac19b00 100644 --- a/bot/exts/filtering/_filter_lists/domain.py +++ b/bot/exts/filtering/_filter_lists/domain.py @@ -13,7 +13,9 @@ from bot.exts.filtering._utils import clean_input if typing.TYPE_CHECKING: from bot.exts.filtering.filtering import Filtering -URL_RE = re.compile(r"https?://(\S+)", flags=re.IGNORECASE) +# Matches words that start with the http(s) protocol prefix +# Will not include, if present, the trailing closing parenthesis +URL_RE = re.compile(r"https?://(\S+)(?=\)|\b)", flags=re.IGNORECASE) class DomainsList(FilterList[DomainFilter]): @@ -56,7 +58,7 @@ class DomainsList(FilterList[DomainFilter]): triggers = await self[ListType.DENY].filter_list_result(new_ctx) ctx.notification_domain = new_ctx.notification_domain - unknown_urls = urls - {filter_.content for filter_ in triggers} + unknown_urls = urls - {filter_.content.lower() for filter_ in triggers} if unknown_urls: ctx.potential_phish[self] = unknown_urls diff --git a/bot/exts/filtering/_ui/ui.py b/bot/exts/filtering/_ui/ui.py index d5b70e944..8d96a3521 100644 --- a/bot/exts/filtering/_ui/ui.py +++ b/bot/exts/filtering/_ui/ui.py @@ -16,6 +16,7 @@ from pydis_core.site_api import ResponseCodeError from pydis_core.utils import scheduling from pydis_core.utils.logging import get_logger from pydis_core.utils.members import get_or_fetch_member +from pydis_core.utils.regex import DISCORD_INVITE import bot from bot.constants import Colours @@ -617,6 +618,10 @@ class AlertView(discord.ui.View): def __init__(self, ctx: FilterContext, triggered_filters: dict[FilterList, list[str]] | None = None): super().__init__(timeout=ALERT_VIEW_TIMEOUT) self.ctx = ctx + if "banned" in self.ctx.action_descriptions: + # If the user has already been banned, do not attempt to add phishing button since the URL or guild invite + # is probably already added as a filter + return phishing_content, target_filter_list = self._extract_potential_phish(triggered_filters) if phishing_content: self.add_item(PhishHandlingButton(ctx.author, phishing_content, target_filter_list)) @@ -681,12 +686,14 @@ class AlertView(discord.ui.View): if len(content_list) > 1: return "", None if content_list: - content = next(iter(content_list)) - if filter_list.name == "domain" and "discord" in content: # Leave invites to the invite filterlist. + current_content = next(iter(content_list)) + if filter_list.name == "domain" and re.fullmatch(DISCORD_INVITE, current_content): + # Leave invites to the invite filterlist. continue if encountered: return "", None target_filter_list = filter_list + content = current_content encountered = True if encountered: |