mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
feat(discord): add allowed_channels whitelist config
Add DISCORD_ALLOWED_CHANNELS (env var) / discord.allowed_channels (config.yaml) support to restrict the bot to only respond in specified channels. When set, messages from any channel NOT in the allowed list are silently ignored — even if the bot is @mentioned. This provides a secure default- deny posture vs the existing ignored_channels which is default-allow. This is especially useful when bots in other channels may create new channels dynamically (e.g., project bots) — a blacklist requires constant maintenance while a whitelist is set-and-forget. Follows the same config pattern as ignored_channels and free_response_channels: - Env var: DISCORD_ALLOWED_CHANNELS (comma-separated channel IDs) - Config: discord.allowed_channels (string or list of channel IDs) - Env var takes precedence over config.yaml - Empty/unset = no restriction (backward compatible) Files changed: - gateway/platforms/discord.py: check allowed_channels before ignored_channels - gateway/config.py: map discord.allowed_channels → DISCORD_ALLOWED_CHANNELS - hermes_cli/config.py: add allowed_channels to DEFAULT_CONFIG
This commit is contained in:
parent
b39ea46488
commit
5b22e61cfa
3 changed files with 20 additions and 3 deletions
|
|
@ -581,6 +581,12 @@ def load_gateway_config() -> GatewayConfig:
|
|||
if isinstance(ic, list):
|
||||
ic = ",".join(str(v) for v in ic)
|
||||
os.environ["DISCORD_IGNORED_CHANNELS"] = str(ic)
|
||||
# allowed_channels: if set, bot ONLY responds in these channels (whitelist)
|
||||
ac = discord_cfg.get("allowed_channels")
|
||||
if ac is not None and not os.getenv("DISCORD_ALLOWED_CHANNELS"):
|
||||
if isinstance(ac, list):
|
||||
ac = ",".join(str(v) for v in ac)
|
||||
os.environ["DISCORD_ALLOWED_CHANNELS"] = str(ac)
|
||||
# no_thread_channels: channels where bot responds directly without creating thread
|
||||
ntc = discord_cfg.get("no_thread_channels")
|
||||
if ntc is not None and not os.getenv("DISCORD_NO_THREAD_CHANNELS"):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue