feat(telegram): channel whitelist + auto-leave with message#101
Open
asdigitos wants to merge 1 commit intoPleasePrompto:mainfrom
Open
feat(telegram): channel whitelist + auto-leave with message#101asdigitos wants to merge 1 commit intoPleasePrompto:mainfrom
asdigitos wants to merge 1 commit intoPleasePrompto:mainfrom
Conversation
Adds `allowed_channel_ids` config field so Telegram channels can be explicitly whitelisted, separate from `allowed_group_ids`. When the bot is added to a non-whitelisted channel it now sends "This channel is not whitelisted, I am out." before leaving, instead of silently leaving or reusing the group rejection message. Changes: - config.py: `allowed_channel_ids: list[int]` field (default []) - app.py _on_bot_added: branch on chat.type == "channel" to pick the right allowlist and i18n key; logs use "channel"/"group" correctly - app.py audit_groups: channels are checked against allowed_channel_ids so whitelisted channels are not evicted during periodic audits - app.py _on_auth_hot_reload: hot-reload support for allowed_channel_ids - i18n/en/chat.toml: new `telegram.channel_not_whitelisted` string - tests: 14 new tests covering config, _on_bot_added, audit_groups, and hot-reload for the channel whitelist feature Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
allowed_channel_ids: list[int]config field so Telegram channels can be explicitly whitelisted, separate fromallowed_group_ids(which covers groups/supergroups)audit_groupsnow correctly exempts whitelisted channels from periodic evictionallowed_channel_idsis hot-reloadable (editconfig.json, takes effect within seconds, no restart needed)Changed files
ductor_bot/config.pyallowed_channel_idsfieldductor_bot/messenger/telegram/app.py_on_bot_addedonchat.type == "channel"; fixaudit_groups; hot-reloadductor_bot/i18n/en/chat.tomltelegram.channel_not_whitelistedstringtests/messenger/telegram/test_channel_whitelist.pyTest plan
pytest tests/messenger/telegram/test_channel_whitelist.py— 14/14 passpytest tests/messenger/— 780/780 pass, no regressionsruff format+ruff check— cleanallowed_channel_ids→ bot stays and sends join notificationConfig example
{ "allowed_group_ids": [-100123456789], "allowed_channel_ids": [-100987654321] }🤖 Generated with Claude Code