diff --git a/nanobot/channels/discord.py b/nanobot/channels/discord.py index 9a75da1e..60ca0698 100644 --- a/nanobot/channels/discord.py +++ b/nanobot/channels/discord.py @@ -53,6 +53,7 @@ class DiscordConfig(Base): enabled: bool = False token: str = "" allow_from: list[str] = Field(default_factory=list) + allow_channels: list[str] = Field(default_factory=list) # Allowed channel IDs (empty = all) intents: int = 37377 group_policy: Literal["mention", "open"] = "mention" read_receipt_emoji: str = "👀" @@ -533,6 +534,12 @@ class DiscordChannel(BaseChannel): """Check if inbound Discord message should be processed.""" if not self.is_allowed(sender_id): return False + # Channel-based filtering: only respond in allowed channels + allow_channels = self.config.allow_channels + if allow_channels: + channel_id = self._channel_key(message.channel) + if channel_id not in allow_channels: + return False if message.guild is not None and not self._should_respond_in_group(message, content): return False return True