Skip to content

Admin-only by default, /usage, /alerts open in groups, checked button entry point - #37

Merged
robdevops merged 4 commits into
mainfrom
claude/envirobot-next
Oct 9, 2026
Merged

robdevops merged 4 commits into
mainfrom
claude/envirobot-next

Conversation

@robdevops

Copy link
Copy Markdown
Owner

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=off answers 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.
  • /alerts in groups: anyone may open it; its buttons and /alerts on|off stay admin-only. In a private chat it is gated like the rest.
  • /usage: the same as the Help & Alerts button (one shared helper).
  • Button protection: every button press now comes in through one handler. A press is believed only if its data is short, plain text and is one of the buttons its message really carries (Telegram does not check callback data against the keyboard); then it is dispatched by prefix, and a prefix nobody handles is refused, so a new kind of button is dead until it is registered.

Test plan

  • python -m pytest -q: 725 passed (new tests/test_admin_only.py: config parsing, the admin lookup and its cache, the gate in private chats and groups, /alerts and /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 pass
  • CI run on this pull request
  • On the server: with the default ADMIN_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

claude added 4 commits October 8, 2026 23:35
…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
…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
@robdevops
robdevops merged commit de6b9a7 into main Oct 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants