Repository navigation
Per-guild channel restrictions via MATRIMONY_ALLOWED_CHANNELS - #3
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Guild ids map to lists of allowed channel ids via the MATRIMONY_ALLOWED_CHANNELS env var (inline JSON) or MATRIMONY_ALLOWED_CHANNELS_FILE (path to a JSON file; the inline var wins when both are set). - Check runs in should_process(), before command dispatch: commands in non-allowed channels are silently ignored, matching how the bot already ignores its own messages. - Guilds absent from the mapping are unrestricted, DMs are never restricted, and a guild mapped to [] accepts commands nowhere. - Malformed JSON / wrong shapes log a warning and are treated as no restriction (fail-open, so a typo can't lock every server out). Docs: README config table + new 'Channel restrictions' section and .env.example entries. Tests: tests/test_allowed_channels.py covers parsing (inline/file/precedence/bad input) and the dispatch gate. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional per-guild allow-list for command channels, configured entirely through env vars (consistent with the rest of
Config):MATRIMONY_ALLOWED_CHANNELS— inline JSON object mapping guild ids to channel id lists, e.g.{"123456789012345678": ["111222333444555666"]}MATRIMONY_ALLOWED_CHANNELS_FILE— path to a JSON file with the same mapping; used only when the inline var is unsetDispatch: the check lives in
MatrimonyBot.should_process()(matrimony/bot.py), so it runs before command parsing/dispatch. Commands sent in a non-allowed channel are silently ignored — the same pattern as the existing self-loop guard, and it means non-command chatter in a restricted guild never triggers anything.Semantics:
[]→ commands accepted in no channelmessage.guild is None) → never restrictedFail-open parsing: malformed JSON, non-object top level, non-list values, non-numeric ids, or an unreadable file all log a
matrimonywarning and yield{}(no restrictions) — a typo can't lock every server out (matrimony/config.py).Changes
matrimony/config.py—Config.allowed_channels: dict[int, frozenset[int]],_parse_allowed_channels(),_allowed_channels_from_env()matrimony/bot.py—should_process()enforces the allow-listtests/test_allowed_channels.py— 16 tests: parsing (inline/file/precedence/each failure mode with warning assertion) + dispatch gate (allowed/disallowed channel, unlisted guild, empty list, DMs, env end-to-end)README.md,.env.example— config table rows, feature bullet, and a "Channel restrictions" section with exampleruff checkclean; 86 tests pass (70 existing + 16 new).Link to Devin session: https://app.devin.ai/sessions/aa55cdd684ae490b8ecac90ebfb5fc85
Open in Devin Desktop: https://app.devin.ai/desktop/session/aa55cdd684ae490b8ecac90ebfb5fc85?variant=devin
Requested by: @CommunityPoke