[PR #6952] feat(tgbot): port Get one, the links header and setup guides to the screen bot #6536

Open
opened 2026-11-02 04:09:28 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6952
Author: @pcxzs
Created: 10/26/2026
Status: 🔄 Open

Base: main ← Head: feat/tgbot-customer-port


📝 Commits (3)

  • 2dbda6b feat(tgbot): let customers get one link, see what is left, and read setup guides
  • a420bcc docs: document the bot's Get one, setup guides and links header
  • 7dba6dd fix(tgbot): name VMess links in Get one by their remark

📊 Changes

29 files changed (+997 additions, -67 deletions)

View changed files

📝 docs/content/docs/en/operations/telegram-bot.mdx (+4 -2)
📝 docs/content/docs/fa/operations/telegram-bot.mdx (+4 -2)
📝 docs/content/docs/ru/operations/telegram-bot.mdx (+4 -2)
📝 docs/content/docs/zh/operations/telegram-bot.mdx (+4 -2)
➕ internal/web/service/tgbot/screen_client_guide.go (+63 -0)
➕ internal/web/service/tgbot/screen_client_guide_test.go (+82 -0)
➕ internal/web/service/tgbot/screen_client_header.go (+52 -0)
➕ internal/web/service/tgbot/screen_client_header_test.go (+88 -0)
➕ internal/web/service/tgbot/screen_client_one_link.go (+133 -0)
➕ internal/web/service/tgbot/screen_client_one_link_test.go (+204 -0)
📝 internal/web/service/tgbot/screen_client_views.go (+8 -2)
📝 internal/web/service/tgbot/screen_views.go (+11 -4)
📝 internal/web/service/tgbot/screens_art.go (+1 -1)
📝 internal/web/service/tgbot/tgbot_client_links_authz_test.go (+23 -0)
📝 internal/web/service/tgbot/tgbot_router.go (+50 -10)
📝 internal/web/translation/ar-EG.json (+19 -3)
📝 internal/web/translation/en-US.json (+19 -3)
📝 internal/web/translation/es-ES.json (+19 -3)
📝 internal/web/translation/fa-IR.json (+19 -3)
📝 internal/web/translation/id-ID.json (+19 -3)

...and 9 more files

📄 Description

Summary

Ports the three customer screens #6760 did not have, as invited when #6697 was closed, rebuilt on the screen model: Get one, an expiry and traffic-left header on the link pages, and per-platform setup guides.

This PR first also carried two fixes: customers could not page long screens, and a dead client-card button. #7033 landed the same fixes, so they are dropped here and the branch is rebased onto it.

Why

  • Get one. A config attached to several inbounds shows customers a wall of links. The QR sheet holds four codes, so on a config with more, some links had no QR at all.
  • Header. The link pages named only the email, so a customer holding several configs could not tell which one a page was for, or how much of it was left.
  • Guides. Customers ask the operator how to import a link into their app.

What changes

Three commits, meant to be read one at a time:

  1. feat(tgbot): Get one, header and guides.
    • Get one sits on the links page, and on the home screen of a customer with one config. It lists the config's links by the remark the customer's app will show. The chosen link opens alone, with its own QR as the screen's picture.
    • The individual-links and Get one pages open with the config's expiry date and the traffic it has left. "Unlimited" is shown where there is no limit, rather than 0. The subscription page already shows its owner's usage since #7033, so it is left as it is and gains only the Get one button.
    • The guides are reached from the customer's home and cover iOS, Android, Windows, macOS and Linux. They are text only, because Telegram link buttons accept only http, https and tg://.
  2. docs: the Telegram bot page, in en, fa, ru and zh.
  3. fix(tgbot): VMess links in Get one, from the review below. A VMess link keeps its remark as ps inside its base64 body, with no #fragment, so the picker listed every VMess inbound as "1. VMESS", "2. VMESS". It now reads that remark through the panel's own link.ParseLink.

The code changes stay inside internal/web/service/tgbot/. The only other files are the 14 locale files (16 new keys, all translated, Slovak included) and the four docs pages.

Security

  • client_one_link and link_one name a client, so they go through the existing per-client branch and its clientOwnedByTgUser check. link_one carries the link's index after the email. The index is split off before the check, so it is never read as part of the client name. TestEveryClientLinkActionRefusesAForeignClient covers all five link actions.
  • Guide callbacks look up a fixed platform table, so callback data never reaches the localizer as a key.
  • Strangers still get only /start and /id, and groups are still ignored.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

  • Customer screens:
    • screen_client_one_link_test.go drives Get one through real share links from the subscription provider: the picker, the chosen link and its QR, the single-link shortcut, a stale index, and VMess links named by their remark.
    • screen_client_header_test.go covers the header: a dated config, an overspent one, an unlimited one, one that counts from first use, and an email escaped exactly once (I18nBot escapes its parameters since fac90093).
    • screen_client_guide_test.go covers the guides.
  • Mutation checks: each test was run against a build with its behaviour removed (the ownership check, the index split, the VMess remark, the single escape, and others), and each one failed.
  • Suites: go test -shuffle=on ./... (with -race on the bot package), golangci-lint v2.15.0 (the CI pin) and the i18n dead-keys test all pass. The one exception is TestNextWeeklyRenewal_RepeatedMidnight in internal/web/service, a DST case that fails the same way on main in my time zone. Every commit builds and passes on its own.
  • Live: not run against a real bot yet.

Screenshots / recordings

Breaking changes

None.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6952 **Author:** [@pcxzs](https://github.com/pcxzs) **Created:** 10/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/tgbot-customer-port` --- ### 📝 Commits (3) - [`2dbda6b`](https://github.com/MHSanaei/3x-ui/commit/2dbda6b3812f2ccc837671b458b11fcb7bb449d7) feat(tgbot): let customers get one link, see what is left, and read setup guides - [`a420bcc`](https://github.com/MHSanaei/3x-ui/commit/a420bcca832410647d865cb55822a00084766584) docs: document the bot's Get one, setup guides and links header - [`7dba6dd`](https://github.com/MHSanaei/3x-ui/commit/7dba6dda582f5847501616e2250e1a4eaa2cebd8) fix(tgbot): name VMess links in Get one by their remark ### 📊 Changes **29 files changed** (+997 additions, -67 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/en/operations/telegram-bot.mdx` (+4 -2) 📝 `docs/content/docs/fa/operations/telegram-bot.mdx` (+4 -2) 📝 `docs/content/docs/ru/operations/telegram-bot.mdx` (+4 -2) 📝 `docs/content/docs/zh/operations/telegram-bot.mdx` (+4 -2) ➕ `internal/web/service/tgbot/screen_client_guide.go` (+63 -0) ➕ `internal/web/service/tgbot/screen_client_guide_test.go` (+82 -0) ➕ `internal/web/service/tgbot/screen_client_header.go` (+52 -0) ➕ `internal/web/service/tgbot/screen_client_header_test.go` (+88 -0) ➕ `internal/web/service/tgbot/screen_client_one_link.go` (+133 -0) ➕ `internal/web/service/tgbot/screen_client_one_link_test.go` (+204 -0) 📝 `internal/web/service/tgbot/screen_client_views.go` (+8 -2) 📝 `internal/web/service/tgbot/screen_views.go` (+11 -4) 📝 `internal/web/service/tgbot/screens_art.go` (+1 -1) 📝 `internal/web/service/tgbot/tgbot_client_links_authz_test.go` (+23 -0) 📝 `internal/web/service/tgbot/tgbot_router.go` (+50 -10) 📝 `internal/web/translation/ar-EG.json` (+19 -3) 📝 `internal/web/translation/en-US.json` (+19 -3) 📝 `internal/web/translation/es-ES.json` (+19 -3) 📝 `internal/web/translation/fa-IR.json` (+19 -3) 📝 `internal/web/translation/id-ID.json` (+19 -3) _...and 9 more files_ </details> ### 📄 Description ## Summary Ports the three customer screens #6760 did not have, as invited when #6697 was closed, rebuilt on the screen model: **Get one**, an expiry and traffic-left header on the link pages, and per-platform **setup guides**. This PR first also carried two fixes: customers could not page long screens, and a dead client-card button. #7033 landed the same fixes, so they are dropped here and the branch is rebased onto it. ## Why - **Get one.** A config attached to several inbounds shows customers a wall of links. The QR sheet holds four codes, so on a config with more, some links had no QR at all. - **Header.** The link pages named only the email, so a customer holding several configs could not tell which one a page was for, or how much of it was left. - **Guides.** Customers ask the operator how to import a link into their app. ## What changes Three commits, meant to be read one at a time: 1. **`feat(tgbot)`: Get one, header and guides.** - **Get one** sits on the links page, and on the home screen of a customer with one config. It lists the config's links by the remark the customer's app will show. The chosen link opens alone, with its own QR as the screen's picture. - The individual-links and Get one pages open with the config's expiry date and the traffic it has left. "Unlimited" is shown where there is no limit, rather than 0. The subscription page already shows its owner's usage since #7033, so it is left as it is and gains only the Get one button. - The guides are reached from the customer's home and cover iOS, Android, Windows, macOS and Linux. They are text only, because Telegram link buttons accept only `http`, `https` and `tg://`. 2. **`docs`:** the Telegram bot page, in en, fa, ru and zh. 3. **`fix(tgbot)`: VMess links in Get one**, from the review below. A VMess link keeps its remark as `ps` inside its base64 body, with no `#fragment`, so the picker listed every VMess inbound as "1. VMESS", "2. VMESS". It now reads that remark through the panel's own `link.ParseLink`. The code changes stay inside `internal/web/service/tgbot/`. The only other files are the 14 locale files (16 new keys, all translated, Slovak included) and the four docs pages. ## Security - `client_one_link` and `link_one` name a client, so they go through the existing per-client branch and its `clientOwnedByTgUser` check. `link_one` carries the link's index after the email. The index is split off before the check, so it is never read as part of the client name. `TestEveryClientLinkActionRefusesAForeignClient` covers all five link actions. - Guide callbacks look up a fixed platform table, so callback data never reaches the localizer as a key. - Strangers still get only `/start` and `/id`, and groups are still ignored. ## Type of change - [ ] Bug fix - [x] New feature - [ ] Refactoring (no behavior change) - [x] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [ ] Frontend (UI / panel pages) - [ ] Backend (API endpoints, login, settings) - [ ] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [x] Telegram bot ## How was this tested? - **Customer screens:** - `screen_client_one_link_test.go` drives Get one through real share links from the subscription provider: the picker, the chosen link and its QR, the single-link shortcut, a stale index, and VMess links named by their remark. - `screen_client_header_test.go` covers the header: a dated config, an overspent one, an unlimited one, one that counts from first use, and an email escaped exactly once (`I18nBot` escapes its parameters since `fac90093`). - `screen_client_guide_test.go` covers the guides. - **Mutation checks:** each test was run against a build with its behaviour removed (the ownership check, the index split, the VMess remark, the single escape, and others), and each one failed. - **Suites:** `go test -shuffle=on ./...` (with `-race` on the bot package), `golangci-lint` v2.15.0 (the CI pin) and the i18n dead-keys test all pass. The one exception is `TestNextWeeklyRenewal_RepeatedMidnight` in `internal/web/service`, a DST case that fails the same way on `main` in my time zone. Every commit builds and passes on its own. - **Live:** not run against a real bot yet. ## Screenshots / recordings <!-- Telegram screenshots: Get one picker, one link with QR, links header, guide. --> ## Breaking changes None. ## Checklist - [ ] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [x] `go build ./...` and the test suite pass locally. - [ ] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [x] I updated the Wiki / README / API docs if user-facing behavior changed. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
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
MHSanaei/3x-ui#6536
No description provided.