From a8ef0d2630710a9882a7c55fbfc6454f16397c9c Mon Sep 17 00:00:00 2001 From: Mega-JC <65417594+Mega-JC@users.noreply.github.com> Date: Sat, 20 Jul 2024 22:18:12 +0200 Subject: [PATCH] Always detect crosspost messages in threads/posts in 'anti_crosspost' extension --- pcbot/exts/anti_crosspost.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/pcbot/exts/anti_crosspost.py b/pcbot/exts/anti_crosspost.py index 7a41f63..fafb16a 100644 --- a/pcbot/exts/anti_crosspost.py +++ b/pcbot/exts/anti_crosspost.py @@ -58,10 +58,18 @@ async def on_message(self, message: discord.Message): if message.author.bot or not ( ( message.channel.id in self.channel_ids - or isinstance(message.channel, (discord.abc.GuildChannel)) - and message.channel.category_id in self.channel_ids - or isinstance(message.channel, discord.Thread) - and message.channel.parent_id in self.channel_ids + or ( + isinstance(message.channel, (discord.abc.GuildChannel)) + and message.channel.category_id in self.channel_ids + ) + or ( + isinstance(message.channel, discord.Thread) + and ( + message.channel.parent_id in self.channel_ids + or message.channel.parent + and message.channel.parent.category_id in self.channel_ids + ) + ) ) and message.type == discord.MessageType.default ): @@ -80,11 +88,10 @@ async def on_message(self, message: discord.Message): if ( len(self.crossposting_cache[message.author.id]["message_groups"]) > self.max_tracked_message_groups_per_user + and len(self.crossposting_cache[message.author.id]["message_groups"][0]) < 2 ): self.crossposting_cache[message.author.id]["message_groups"].pop(0) - # To fix the code below from sending an - for i, messages in enumerate( self.crossposting_cache[message.author.id]["message_groups"] ):