diff options
-rw-r--r-- | bot/exts/filters/filter_lists.py | 22 | ||||
-rw-r--r-- | bot/exts/filters/filtering.py | 10 |
2 files changed, 21 insertions, 11 deletions
diff --git a/bot/exts/filters/filter_lists.py b/bot/exts/filters/filter_lists.py index fc9cfbeca..c643f9a84 100644 --- a/bot/exts/filters/filter_lists.py +++ b/bot/exts/filters/filter_lists.py @@ -55,17 +55,22 @@ class FilterLists(Cog): """Add an item to a filterlist.""" allow_type = "whitelist" if allowed else "blacklist" - # If this is a server invite, we gotta validate it. + # If this is a guild invite, we gotta validate it. if list_type == "GUILD_INVITE": guild_data = await self._validate_guild_invite(ctx, content) content = guild_data.get("id") - # Unless the user has specified another comment, let's - # use the server name as the comment so that the list - # of guild IDs will be more easily readable when we - # display it. - if not comment: - comment = guild_data.get("name") + # Some guild invites are autoban filters, which require the mod + # to set a comment which includes [autoban]. + # Having the guild name in the comment is still useful when reviewing + # filter list, so prepend it to the set comment in case some mod forgets. + guild_name_part = f'Guild "{guild_data["name"]}"' if "name" in guild_data else None + + comment = " - ".join( + comment_part + for comment_part in (guild_name_part, comment) + if comment_part + ) # If it's a file format, let's make sure it has a leading dot. elif list_type == "FILE_FORMAT" and not content.startswith("."): @@ -115,7 +120,8 @@ class FilterLists(Cog): # If it is an autoban trigger we send a warning in #mod-meta if comment and "[autoban]" in comment: await self.bot.get_channel(Channels.mod_meta).send( - f":warning: Heads-up! The new filter `{content}` (`{comment}`) will automatically ban users." + f":warning: Heads-up! The new `{list_type}` filter " + f"`{content}` (`{comment}`) will automatically ban users." ) # Insert the item into the cache diff --git a/bot/exts/filters/filtering.py b/bot/exts/filters/filtering.py index 13035c0c8..ca6ad0064 100644 --- a/bot/exts/filters/filtering.py +++ b/bot/exts/filters/filtering.py @@ -387,9 +387,9 @@ class Filtering(Cog): log.trace(f"Offensive message {msg.id} will be deleted on {delete_date}") stats = self._add_stats(filter_name, match, msg.content) - await self._send_log(filter_name, _filter, msg, stats, reason) - # If the filter reason contains `[autoban]`, we want to auto-ban the user + # If the filter reason contains `[autoban]`, we want to auto-ban the user. + # Also pass this to _send_log so mods are not pinged filter matches that are auto-actioned autoban = reason and "[autoban]" in reason.lower() if not autoban and filter_name == "filter_invites" and isinstance(result, dict): autoban = any( @@ -397,6 +397,9 @@ class Filtering(Cog): for invite_info in result.values() if invite_info.get("reason") ) + + await self._send_log(filter_name, _filter, msg, stats, reason, autoban=autoban) + if autoban: # Create a new context, with the author as is the bot, and the channel as #mod-alerts. # This sends the ban confirmation directly under watchlist trigger embed, to inform @@ -425,6 +428,7 @@ class Filtering(Cog): reason: Optional[str] = None, *, is_eval: bool = False, + autoban: bool = False, ) -> None: """Send a mod log for a triggered filter.""" if msg.channel.type is ChannelType.private: @@ -438,7 +442,7 @@ class Filtering(Cog): content = str(msg.author.id) # quality-of-life improvement for mobile moderators # If we are going to autoban, we don't want to ping and don't need the user ID - if reason and "[autoban]" in reason: + if autoban: ping_everyone = False content = None |