From a443a5699f6bcd70165cbe53e4fa9b31e1af52a3 Mon Sep 17 00:00:00 2001 From: Mega-JC <65417594+Mega-JC@users.noreply.github.com> Date: Fri, 26 Jul 2024 13:07:44 +0200 Subject: [PATCH] Clarify and fix bug in enforcing 'message_length_threshold' in 'anti_crosspost' extension --- pcbot/exts/anti_crosspost.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pcbot/exts/anti_crosspost.py b/pcbot/exts/anti_crosspost.py index 2f1837b..89444a6 100644 --- a/pcbot/exts/anti_crosspost.py +++ b/pcbot/exts/anti_crosspost.py @@ -75,7 +75,7 @@ def __init__( bot (BotT): The bot instance. channel_ids (Collection[int]): Collection of channel IDs to monitor. crosspost_timedelta_threshold (int): Minimum time difference between messages to not be considered crossposts. - message_length_threshold (int): Minimum length of a message to be considered. + message_length_threshold (int): Minimum length of a text-only message to be considered. max_tracked_users (int): Maximum number of users to track. max_tracked_message_groups_per_user (int): Maximum number of message groups to track per user. @@ -103,8 +103,9 @@ async def on_message(self, message: discord.Message): or not self._is_valid_channel(message.channel) # type: ignore or message.type != discord.MessageType.default or ( - len(message.content) < self.message_length_threshold + message.content and not message.attachments + and len(message.content) < self.message_length_threshold ) ): return @@ -259,7 +260,7 @@ async def setup( max_tracked_users (int): Maximum number of users to track. max_tracked_message_groups_per_user (int): Maximum number of message groups to track per user. crosspost_timedelta_threshold (int): Minimum time difference between messages to not be considered crossposts. - message_length_threshold (int): Minimum length of a message to be considered. + message_length_threshold (int): Minimum length of a text-only message to be considered. theme_color (int | discord.Color): Theme color for the bot's responses. """ await bot.add_cog(