Auto: refactor/simplify-daily-limits #20

Merged
claude-bot merged 3 commits from refactor/simplify-daily-limits into main 2026-03-01 18:22:04 -07:00
Collaborator

Automated PR for branch refactor/simplify-daily-limits.

Automated PR for branch `refactor/simplify-daily-limits`.
refactor: simplify limits to daily output message count
All checks were successful
Auto PR Review / review (push) Successful in 3m13s
8b3d52bd2e
Replace 3 overlapping limit layers (subscription tiers, daily tokens,
monthly system budget) with a single daily output message limit
(free: 10/day, premium: 30/day). Count by Telegram output messages —
a translation that splits into 2 messages counts as 2.

- Add output_messages column to api_token_usage table
- Add get_user_daily_output_messages() query function
- Simplify TranslationDeps to translate + log_error only
- Remove TokenBudgetManager, ensure_free_user_sub, quota functions
- Update all handlers and tests for new limit system (-686 lines net)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ci: switch Claude review auth from API key to Max subscription
All checks were successful
Auto PR Review / review (push) Successful in 2m45s
5e459bd3dd
Use CLAUDE_CODE_OAUTH_TOKEN instead of ANTHROPIC_API_KEY so PR reviews
use the Claude Max subscription rather than pay-per-use API billing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ci: retry docker pull to handle transient DNS failures
All checks were successful
Auto PR Review / review (push) Successful in 3m44s
e996a1e989
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
Collaborator

Approved

Clean refactoring that replaces a complex token-based quota system (reserve/refund/monthly budgets) with a simple daily output message count. The changes are consistent across handlers, database, user management, strings, and tests. Logic is sound, tests are thorough, and the simplification significantly reduces complexity. No critical or warning-level issues found.

Suggestions

  • strings.py: Dead code: DAILY_MESSAGE_LIMIT_FREE and DAILY_MESSAGE_LIMIT_PREMIUM are defined in strings.py but never imported or referenced anywhere in the codebase. The actual limit-exceeded messages use TRANSLATION_LIMIT_EXCEEDED_FREE and TRANSLATION_LIMIT_EXCEEDED_PREMIUM instead. Consider removing these unused strings or using them in place of the TRANSLATION_LIMIT_EXCEEDED_* variants.
  • database.py: get_user_daily_output_messages sums output_messages across ALL services (no is_translation_related or service_name filter). This means YouTube summaries or any other logged API calls also count toward the daily message limit. If this is intentional (unified daily cap), consider adding a brief comment to make that explicit.
  • handlers/translation.py: Usage is logged after split_message() but before the message parts are actually sent to Telegram. If sending fails partway through, the output_messages count will reflect intended parts rather than actually delivered ones. This is a very minor edge case and probably acceptable, but worth noting.
## Approved Clean refactoring that replaces a complex token-based quota system (reserve/refund/monthly budgets) with a simple daily output message count. The changes are consistent across handlers, database, user management, strings, and tests. Logic is sound, tests are thorough, and the simplification significantly reduces complexity. No critical or warning-level issues found. ### Suggestions - **strings.py**: Dead code: `DAILY_MESSAGE_LIMIT_FREE` and `DAILY_MESSAGE_LIMIT_PREMIUM` are defined in strings.py but never imported or referenced anywhere in the codebase. The actual limit-exceeded messages use `TRANSLATION_LIMIT_EXCEEDED_FREE` and `TRANSLATION_LIMIT_EXCEEDED_PREMIUM` instead. Consider removing these unused strings or using them in place of the `TRANSLATION_LIMIT_EXCEEDED_*` variants. - **database.py**: `get_user_daily_output_messages` sums `output_messages` across ALL services (no `is_translation_related` or `service_name` filter). This means YouTube summaries or any other logged API calls also count toward the daily message limit. If this is intentional (unified daily cap), consider adding a brief comment to make that explicit. - **handlers/translation.py**: Usage is logged after `split_message()` but before the message parts are actually sent to Telegram. If sending fails partway through, the `output_messages` count will reflect intended parts rather than actually delivered ones. This is a very minor edge case and probably acceptable, but worth noting.
claude-bot deleted branch refactor/simplify-daily-limits 2026-03-01 18:22:04 -07:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
bittabola/tarjimon!20
No description provided.