4444DAYS_BETWEEN_ALERTS = 3
4545OFFENSIVE_MSG_DELETE_TIME = timedelta (days = Filter .offensive_msg_delete_days )
4646
47+ # Autoban
48+ LINK_PASSWORD = "https://support.discord.com/hc/en-us/articles/218410947-I-forgot-my-Password-Where-can-I-set-a-new-one"
49+ LINK_2FA = "https://support.discord.com/hc/en-us/articles/219576828-Setting-up-Two-Factor-Authentication"
50+ AUTO_BAN_REASON = (
51+ "Your account has been used to send links to a phishing website. You have been automatically banned. "
52+ "If you are not aware of sending them, that means your account has been compromised.\n \n "
53+
54+ f"Here is a guide from Discord on [how to change your password]({ LINK_PASSWORD } ).\n \n "
55+
56+ f"We also highly recommend that you [enable 2 factor authentication on your account]({ LINK_2FA } ), "
57+ "for heightened security.\n \n "
58+
59+ "Once you have changed your password, feel free to follow the instructions at the bottom of "
60+ "this message to appeal your ban."
61+ )
62+ AUTO_BAN_DURATION = timedelta (days = 4 )
63+
4764FilterMatch = Union [re .Match , dict , bool , List [discord .Embed ]]
4865
4966
@@ -347,6 +364,23 @@ async def _filter_message(self, msg: Message, delta: Optional[int] = None) -> No
347364 stats = self ._add_stats (filter_name , match , msg .content )
348365 await self ._send_log (filter_name , _filter , msg , stats , reason )
349366
367+ # If the filter reason contains `[autoban]`, we want to auto-ban the user
368+ if reason and "[autoban]" in reason .lower ():
369+ # Create a new context, with the author as is the bot, and the channel as #mod-alerts.
370+ # This sends the ban confirmation directly under watchlist trigger embed, to inform
371+ # mods that the user was auto-banned for the message.
372+ context = await self .bot .get_context (msg )
373+ context .author = self .bot .get_guild (Guild .id ).get_member (self .bot .user .id )
374+ context .channel = self .bot .get_channel (Channels .mod_alerts )
375+ context .command = self .bot .get_command ("tempban" )
376+
377+ await context .invoke (
378+ context .command ,
379+ msg .author ,
380+ arrow .utcnow () + AUTO_BAN_DURATION ,
381+ reason = AUTO_BAN_REASON
382+ )
383+
350384 break # We don't want multiple filters to trigger
351385
352386 async def _send_log (
@@ -368,6 +402,10 @@ async def _send_log(
368402 # Allow specific filters to override ping_everyone
369403 ping_everyone = Filter .ping_everyone and _filter .get ("ping_everyone" , True )
370404
405+ # If we are going to autoban, we don't want to ping
406+ if reason and "[autoban]" in reason :
407+ ping_everyone = False
408+
371409 eval_msg = "using !eval " if is_eval else ""
372410 footer = f"Reason: { reason } " if reason else None
373411 message = (
0 commit comments