The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(discord): read the free-response auto-thread flag through a getter
kshitijk4poor0c7738dfd683
diff --git a/plugins/platforms/discord/adapter.py b/plugins/platforms/discord/adapter.pyindex d502b98628e..0ebcc36b4cb 100644--- a/plugins/platforms/discord/adapter.py+++ b/plugins/platforms/discord/adapter.py@@ -4741,6 +4741,12 @@ class DiscordAdapter(DiscordMediaMixin, BasePlatformAdapter):"""Return whether Discord channel messages require a bot mention."""return self._extra_or_env_flag("require_mention", "DISCORD_REQUIRE_MENTION", "true", truthy=False)+ def _discord_free_response_auto_thread(self) -> bool:+ """Free-response channels also auto-thread when opted in; default replies inline."""+ return self._extra_or_env_flag(+ "free_response_auto_thread", "DISCORD_FREE_RESPONSE_AUTO_THREAD", "false", truthy=True,+ )+def _discord_max_attachment_bytes(self) -> int:"""Per-attachment byte cap; 0 = unlimited (whole attachment is held in memory). Default 32 MiB."""configured = self.config.extra.get("max_attachment_bytes")@@ -5884,6 +5890,7 @@ class DiscordAdapter(DiscordMediaMixin, BasePlatformAdapter):# discord.allowed_channels: If set, bot ONLY responds in these channels (whitelist)# discord.no_thread_channels: Channel IDs where bot responds directly without creating thread# discord.auto_thread: Auto-create thread on @mention in channels (default: true)+ # discord.free_response_auto_thread: Free-response channels also auto-thread (default: false)thread_id = Noneparent_channel_id = Noneis_thread = isinstance(message.channel, discord.Thread)@@ -5948,14 +5955,9 @@ class DiscordAdapter(DiscordMediaMixin, BasePlatformAdapter):auto_threaded_channel = Noneif not is_thread and not isinstance(message.channel, discord.DMChannel):no_thread_channels = self._get_no_thread_channels()- # free_response_auto_thread: free-response channels reply inline unless the operator- # opts in; then each top-level message also gets its own thread. The voice-linked and- # reply exclusions live in the auto-thread gate below, not here.- free_response_auto_thread = self._extra_or_env_flag(- "free_response_auto_thread", "DISCORD_FREE_RESPONSE_AUTO_THREAD", "false", truthy=True,- )+ # Voice-linked and reply exclusions live in the auto-thread gate below, not in skip_thread.skip_thread = bool(channel_keys & no_thread_channels) or (- is_free_channel and not free_response_auto_thread+ is_free_channel and not self._discord_free_response_auto_thread())auto_thread = self._extra_or_env_flag("auto_thread", "DISCORD_AUTO_THREAD", "true", truthy=True)is_reply_message = getattr(message, "type", None) == discord.MessageType.reply@@ -7302,8 +7304,9 @@ def register(ctx) -> None:setup_fn=interactive_setup,# YAML→env bridge: ``discord:`` config keys → ``DISCORD_*`` env vars read via os.getenv().# YAML→env config bridge — owns the translation of ``config.yaml`` ``discord:`` keys- # (require_mention, free_response_channels, auto_thread, reactions, ignored_channels,- # allowed_channels, no_thread_channels, allow_mentions.*, reply_to_mode, thread_require_mention)+ # (require_mention, free_response_channels, auto_thread, free_response_auto_thread,+ # reactions, ignored_channels, allowed_channels, no_thread_channels, allow_mentions.*,+ # reply_to_mode, thread_require_mention)# into ``DISCORD_*`` env vars that the adapter reads via ``os.getenv()``. Replaces the hardcoded# block that used to live in ``gateway/config.py``. Hook contract: #24836.apply_yaml_config_fn=_apply_yaml_config,