Repository navigation
Admin access control: group admins, ADMIN_ONLY flag, and /credits consolidation - #30
Merged
Merged
Conversation
…locks DMs and Sharesight Admins are users in ADMIN_CHAT_IDS plus administrators of groups the bot has seen (cached five minutes). ADMIN_ONLY (default on) ignores DMs from non-admins and keeps Sharesight tools and data from them, including on the NEEDS_TOOLS rerun. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014k4kywyN5dAo39izUPvxbw
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
Implements admin access control based on both configured admin IDs and group administrator status, adds an
ADMIN_ONLYflag to restrict DM and portfolio access, and consolidates/creditsand/usageinto a single/creditscommand.Key Changes
Admin Access System
lib/telegram/access.pymodule:is_admin()checks if a user is inADMIN_CHAT_IDSor administers any group the bot has seenCtx.group_adminsdictADMIN_ONLY Flag
ADMIN_ONLYconfig setting (defaults toon)ADMIN_ONLYis on (viaChatMemberHandler)Command Changes
/creditsnow shows both provider balance and usage stats (tokens, cost per model for last 24h and 7 days)/usagecommand removed; functionality merged into/creditsis_admin()instead of just checkingADMIN_CHAT_IDS/creditsin their group or via DMTool Gating
ask.pyaddsadminparameter to filter servers based on user privilege level_public()helper excludes portfolio-gated serversMessage Handling
handlers.on_messagechecks admin status for private messages whenADMIN_ONLYis onpost_to_groupsflag check from message recording (groups are always tracked when needed)Implementation Details
asyncio.to_threadfor store operationstime.monotonic()for robustness against system clock changes/creditscommand gracefully handles backend failures while still showing usage datahttps://claude.ai/code/session_014k4kywyN5dAo39izUPvxbw