From ad4542bf6dd380c4d73ce7b0666f5e1bda1dd330 Mon Sep 17 00:00:00 2001 From: barteq Date: Sat, 25 Apr 2026 21:00:50 +0000 Subject: [PATCH] fix(gateway): allow free_response_channels to override DISCORD_IGNORE_NO_MENTION When DISCORD_IGNORE_NO_MENTION is true (default), the bot ignores messages without @mention. However, this check ran before evaluating free_response_channels, so messages in free-response channels were wrongly dropped unless they contained a mention. This change adds a carve-out: if the message lands in a channel that is configured as a free response channel (or its parent category is), the ignore-no-mention rule is skipped. Also removes the unconditional skip_thread for free response channels so that auto_thread still creates threads there unless explicitly disabled via DISCORD_NO_THREAD_CHANNELS. --- gateway/platforms/discord.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/gateway/platforms/discord.py b/gateway/platforms/discord.py index 243e81d3e8..ecfa38c723 100644 --- a/gateway/platforms/discord.py +++ b/gateway/platforms/discord.py @@ -720,11 +720,22 @@ class DiscordAdapter(BasePlatformAdapter): return # If humans are mentioned but we're not → not for us # (preserves old DISCORD_IGNORE_NO_MENTION=true behavior) + # EXCEPT in free-response channels where the bot should + # answer regardless of who is mentioned. _ignore_no_mention = os.getenv( "DISCORD_IGNORE_NO_MENTION", "true" ).lower() in ("true", "1", "yes") if _ignore_no_mention and not _self_mentioned and not _other_bots_mentioned: - return + _channel_id = str(message.channel.id) + _parent_id = None + if hasattr(message.channel, "parent_id") and message.channel.parent_id: + _parent_id = str(message.channel.parent_id) + _free_channels = adapter_self._discord_free_response_channels() + _channel_ids = {_channel_id} + if _parent_id: + _channel_ids.add(_parent_id) + if "*" not in _free_channels and not (_channel_ids & _free_channels): + return await self._handle_message(message) @@ -3797,7 +3808,7 @@ class DiscordAdapter(BasePlatformAdapter): if not is_thread and not isinstance(message.channel, discord.DMChannel): no_thread_channels_raw = os.getenv("DISCORD_NO_THREAD_CHANNELS", "") no_thread_channels = {ch.strip() for ch in no_thread_channels_raw.split(",") if ch.strip()} - skip_thread = bool(channel_ids & no_thread_channels) or is_free_channel + skip_thread = bool(channel_ids & no_thread_channels) auto_thread = os.getenv("DISCORD_AUTO_THREAD", "true").lower() in ("true", "1", "yes") is_reply_message = getattr(message, "type", None) == discord.MessageType.reply if auto_thread and not skip_thread and not is_voice_linked_channel and not is_reply_message: