code-review-fixes #6

Merged
deco merged 8 commits from code-review-fixes into main 2026-02-18 01:40:11 +02:00
Owner
No description provided.
Implements comprehensive parameter management allowing admins to modify
configuration values (URLs, wallet addresses, pricing, thresholds) at
runtime without code changes or bot restarts.

New Features:
- ParameterService with in-memory caching and validation
- Database tables for parameters and audit history
- Admin commands: /setparam, /getparam, /listparams, /paramhistory, /exportparams
- Auto-seeding of 25+ initial parameters on first startup
- Type validation (URLs, Bitcoin addresses, numbers, JSON)
- Full audit trail (who changed what, when, why)
- Protected parameters (BOT_TOKEN, ADMIN_IDS cannot be modified)

Implementation:
- src/services/parameter.ts: ParameterService class with CRUD operations
- src/migrations/seedParameters.ts: Initial parameter seeding
- src/storage/sqlite.ts: Added parameters and parameter_history tables
- src/handlers/commands/admin.ts: Added 5 new admin commands
- src/bot.ts: Integrated ParameterService and auto-seeding
- docs/PARAMETER_MANAGEMENT_DESIGN.md: Comprehensive design document

Benefits:
- Update Bitcoin wallets instantly during rotation
- Change service URLs during migrations (zero downtime)
- Adjust pricing for promotions without redeployment
- Modify rate limits in response to abuse
- Export/backup parameter configurations

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implements 53 tests covering all ParameterService functionality:

Test Coverage:
- defineParameter(): Validation, type checking, protected parameters
- get(): Cache loading, type safety, defaults, error handling
- set(): Updates, history recording, validation, protected params
- getHistory(): Change tracking, ordering, limits, metadata
- listParameters(): Filtering, sorting, metadata
- exportParameters(): JSON export, category filtering
- reloadCache(): Cache invalidation and refresh
- Edge cases: Empty strings, zero values, nested JSON, special chars
- Concurrent operations: Parallel updates, race conditions
- SqliteAdapter integration: Persistence, transactions

All tests use in-memory SQLite for fast, isolated execution.

Test Results:  53/53 passing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Connect runtime-editable parameters to actual menu display, making
parameter changes immediately visible to users.

Implementation:
- src/config/menu-content.json: Replaced hardcoded values with {{parameter.key}} placeholders
  • Bitcoin addresses → {{payment.bitcoin.telegram}}
  • Service URLs → {{service.url.bulk}}, {{service.url.gold}}, etc.
  • Download codes → {{download.code.premium_tivimate}}, {{download.code.platinum}}
  • Referral links → {{referral.vpn.express}}, {{referral.vpn.proton}}
  • Contact info → {{contact.admin.primary}}

- src/utils/helpers.ts: Added replaceParams() function
  • Replaces {{key}} placeholders with actual parameter values
  • Graceful fallback if parameter not found (keeps placeholder)
  • Logs warnings for missing parameters

- src/menus/factory.ts: Integrated ParameterService into menu factory
  • Added paramService to MenuFactoryDeps interface
  • Text menus now use replaceParams() before sending content
  • Video/photo captions also support parameter replacement

- src/menus/index.ts: Updated createMenuSystem to accept ParameterService
  • Payment menu manually created items now use replaceParams()
  • All menu content is dynamically generated from parameters

- src/bot.ts: Pass ParameterService to createMenuSystem

Impact:
- Admins can now use /setparam to change URLs, wallet addresses, etc.
- Changes appear immediately in menu responses (no restart needed)
- No more hardcoded values scattered throughout menu content
- Single source of truth for all dynamic configuration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Escape special Markdown characters in parameter values to prevent
Telegram API errors when displaying URLs with underscores or other
special characters.

Error: Cannot parse entities at byte offset
Cause: URLs like utm_campaign contain underscores that break Markdown
Fix: Escape special characters with backslash before displaying

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove Markdown parse_mode from /listparams command output to prevent
Telegram entity parsing errors with special characters in URLs and values.

Changed from Markdown formatting to plain text:
- No bold/italic formatting
- No backticks around keys
- No parse_mode parameter
- More reliable, works with any character

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix Markdown parsing errors in all parameter commands
Some checks failed
CI / test (pull_request) Failing after 5s
8908fb77c4
Switch all parameter management commands (/getparam, /setparam,
/paramhistory, /exportparams) from Markdown to plain text format
to avoid Telegram API parsing errors with special characters.

Changes:
- Remove parse_mode: "Markdown" from all ctx.reply() calls
- Remove backticks, bold, and italic formatting
- Remove code blocks from value display
- Use plain text for all parameter command responses

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Merge branch 'main' into code-review-fixes
All checks were successful
CI / test (pull_request) Successful in 42s
9447077039
deco merged commit edd68617a4 into main 2026-02-18 01:40:11 +02:00
deco deleted branch code-review-fixes 2026-02-18 01:40:11 +02:00
Sign in to join this conversation.
No reviewers
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
signal-works/gladiator_telegram_bot!6
No description provided.