Repository navigation
Admin-only by default, /usage, /alerts open in groups, checked button entry point - #37
Merged
Merged
Conversation
…pen in groups, one checked entry point for every button - Only the admins of the groups the bot is in (plus ADMIN_CHAT_IDS) can use it; anyone else gets a short refusal when they address it. - /alerts may be opened by anyone in a group; its buttons and '/alerts on|off' stay admin-only. - /usage is the Help & Alerts button. - Every button press comes in through one handler that believes it only if its data is short, plain text and is one of the buttons its message really carries, then dispatches by prefix (an unknown prefix is refused). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WBwHofjb1g9onaYRdLZMbf
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WBwHofjb1g9onaYRdLZMbf
…art with) and on Subscribe/Unsubscribe to all Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WBwHofjb1g9onaYRdLZMbf
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WBwHofjb1g9onaYRdLZMbf
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
ADMIN_ONLY(on by default): the bot answers only the admins and creators of the groups it is in, in private chats and groups alike. Anyone else gets "Sorry, only group admins can use this bot." when they address it (a toast for a button); ordinary group talk is ignored, and a stranger's private chat is never remembered as an alert chat. Telegram's admin lists are cached for 10 minutes.ADMIN_ONLY=offanswers everyone, as before.ADMIN_CHAT_IDS: more ids allowed besides those admins, added to them and never replacing them. A user id works before the bot is in any group; a negative group id adds that group's admins and admits its anonymous admins (those who post "as the group"). A startup warning says when nobody can use the bot yet./alertsin groups: anyone may open it; its buttons and/alerts on|offstay admin-only. In a private chat it is gated like the rest./usage: the same as the Help & Alerts button (one shared helper).Test plan
python -m pytest -q: 725 passed (newtests/test_admin_only.py: config parsing, the admin lookup and its cache, the gate in private chats and groups,/alertsand/usage, a coverage test over every keyboard the bot draws, forged and malformed presses, a 3,000-string fuzz run; checked that disabling the keyboard check makes five of them fail)python scripts/eval_prompts.py: 87 of 87 passADMIN_ONLY=on, check that an admin of a known group can use the bot and a non-admin gets the refusal🤖 Generated with Claude Code
https://claude.ai/code/session_01WBwHofjb1g9onaYRdLZMbf
Generated by Claude Code