From b01667d9a77dbf90dc25bb4e7bf5575fe7300b0a Mon Sep 17 00:00:00 2001 From: Ramil Valitov Date: Thu, 10 Sep 2026 23:37:12 +0300 Subject: [PATCH 01/10] feat(telegram): register bot command menu with setMyCommands The bot never registered its commands, so Telegram's in-app "/" menu button had nothing to show and the commands were only discoverable by reading /mp_help. Register the list with setMyCommands so commands are tappable. Lists are scoped to mirror the role model in _process_cmd rather than exposing the whole admin surface to every user: - default scope -> 5 public self-service commands - admin/superadmin chats via admins.conf -> 18 command control plane - root chat and superadmin admins -> those 18 plus the four commands gated on the superadmin role (/mp_remove, /mp_restart, /mp_update, /mp_lockdown) The command tables live once, in the manager. The generated bot daemon re-runs `mtproxymax telegram sync-commands` on boot instead of carrying its own copy, so the menu self-heals and picks up newly added admins. Syncing is best-effort throughout: a Telegram outage must never break setup or the poll loop, and revoking an admin calls deleteMyCommands so a stale admin menu is not left behind. Also add an explicit `telegram sync-commands` subcommand for manual re-sync. --- README.md | 12 ++ mtproxymax.sh | 144 +++++++++++++++++++++ tests/test_telegram_commands.sh | 221 ++++++++++++++++++++++++++++++++ 3 files changed, 377 insertions(+) create mode 100644 tests/test_telegram_commands.sh diff --git a/README.md b/README.md index d47154a..a73b1d4 100644 --- a/README.md +++ b/README.md @@ -421,6 +421,17 @@ Full proxy management from your phone. Setup takes 60 seconds: mtproxymax telegram setup ``` +The bot registers its commands with Telegram, so tapping the **`/` menu button** in +the chat lists everything you are allowed to run — no need to memorise them. The +menu is scoped to your role: everyone sees the public self-service commands, admins +see the Admin Control Plane, and superadmins additionally see `/mp_remove`, +`/mp_restart`, `/mp_update` and `/mp_lockdown`. The list is re-synced whenever the +bot service starts; to refresh it by hand use: + +```bash +mtproxymax telegram sync-commands +``` + | Command | Description | |---------|-------------| | `/mp_status` | Proxy status, uptime, connections | @@ -1503,6 +1514,7 @@ mtproxymax update # Check for script + engine updates - **Automated SSL Shield (`ssl-shield`):** Zero-touch Let's Encrypt / `openssl` certificate issuance and ACME domain management. - **Automated Cloud Backups (`backup-cloud`):** Automatic tarball offloading to Telegram admin chat (`sendDocument`) or multi-cloud storage (`rclone`/S3/R2). - **Dual-Tier Telegram Bot (`telegram`):** Public self-service tier (`/start`, `/my_status