Skip to content

Commit 798150e

Browse files
committed
Filter list: send warning when autoban trigger is added
1 parent 4b44480 commit 798150e

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

bot/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ class Channels(metaclass=YAMLGetter):
444444
incidents: int
445445
incidents_archive: int
446446
mod_alerts: int
447+
mod_tools: int
447448
nominations: int
448449
nomination_voting: int
449450
organisation: int

bot/exts/filters/filter_lists.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from bot import constants
77
from bot.api import ResponseCodeError
88
from bot.bot import Bot
9+
from bot.constants import Channels
910
from bot.converters import ValidDiscordServerInvite, ValidFilterListType
1011
from bot.log import get_logger
1112
from bot.pagination import LinePaginator
@@ -100,6 +101,12 @@ async def _add_data(
100101
)
101102
raise
102103

104+
# If it is an autoban trigger we send a warning in #mod-tools
105+
if comment and "[autoban]" in comment:
106+
await self.bot.get_channel(Channels.mod_tools).send(
107+
f":warning: heads-up! The new filter `{content}` (`{comment}`) will automatically ban users."
108+
)
109+
103110
# Insert the item into the cache
104111
self.bot.insert_item_into_filter_list_cache(item)
105112
await ctx.message.add_reaction("✅")

bot/exts/filters/filtering.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ async def _filter_message(self, msg: Message, delta: Optional[int] = None) -> No
364364
await self._send_log(filter_name, _filter, msg, stats, reason)
365365

366366
# If the filter reason contains `[autoban]`, we want to indeed ban
367-
if "[autoban]" in reason.lower():
367+
if reason and "[autoban]" in reason.lower():
368368
# We create a new context from that message and make sure the staffer is the bot
369369
# and the feedback message is sent in #mod-alert
370370
context = await self.bot.get_context(msg)
@@ -400,7 +400,7 @@ async def _send_log(
400400
ping_everyone = Filter.ping_everyone and _filter.get("ping_everyone", True)
401401

402402
# If we are going to autoban, we don't want to ping
403-
if "[autoban]" in reason:
403+
if reason and "[autoban]" in reason:
404404
ping_everyone = False
405405

406406
eval_msg = "using !eval " if is_eval else ""

config-default.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ guild:
207207
incidents_archive: 720668923636351037
208208
mod_alerts: 473092532147060736
209209
mods: &MODS 305126844661760000
210+
mod_tools: 775413915391098921
210211
nominations: 822920136150745168
211212
nomination_voting: 822853512709931008
212213
organisation: &ORGANISATION 551789653284356126

0 commit comments

Comments
 (0)