|
16 | 16 | from pydis_core.utils import scheduling
|
17 | 17 | from pydis_core.utils.logging import get_logger
|
18 | 18 | from pydis_core.utils.members import get_or_fetch_member
|
| 19 | +from pydis_core.utils.regex import DISCORD_INVITE |
19 | 20 |
|
20 | 21 | import bot
|
21 | 22 | from bot.constants import Colours
|
@@ -617,6 +618,10 @@ class AlertView(discord.ui.View):
|
617 | 618 | def __init__(self, ctx: FilterContext, triggered_filters: dict[FilterList, list[str]] | None = None):
|
618 | 619 | super().__init__(timeout=ALERT_VIEW_TIMEOUT)
|
619 | 620 | self.ctx = ctx
|
| 621 | + if "banned" in self.ctx.action_descriptions: |
| 622 | + # If the user has already been banned, do not attempt to add phishing button since the URL or guild invite |
| 623 | + # is probably already added as a filter |
| 624 | + return |
620 | 625 | phishing_content, target_filter_list = self._extract_potential_phish(triggered_filters)
|
621 | 626 | if phishing_content:
|
622 | 627 | self.add_item(PhishHandlingButton(ctx.author, phishing_content, target_filter_list))
|
@@ -681,12 +686,14 @@ def _extract_potential_phish(
|
681 | 686 | if len(content_list) > 1:
|
682 | 687 | return "", None
|
683 | 688 | if content_list:
|
684 |
| - content = next(iter(content_list)) |
685 |
| - if filter_list.name == "domain" and "discord" in content: # Leave invites to the invite filterlist. |
| 689 | + current_content = next(iter(content_list)) |
| 690 | + if filter_list.name == "domain" and re.fullmatch(DISCORD_INVITE, current_content): |
| 691 | + # Leave invites to the invite filterlist. |
686 | 692 | continue
|
687 | 693 | if encountered:
|
688 | 694 | return "", None
|
689 | 695 | target_filter_list = filter_list
|
| 696 | + content = current_content |
690 | 697 | encountered = True
|
691 | 698 |
|
692 | 699 | if encountered:
|
|
0 commit comments