[GH-ISSUE #7010] [Feature]: Consolidate Telegram bot admin workflows (Persian, quick plans/renewal, shareable exports, online users) #4618

Open
opened 2026-10-31 20:40:56 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @HamedSanaei on GitHub (Oct 28, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/7010

Summary

This is a single, coordinated Telegram-bot admin-workflow improvement covering requests #1, #2, #3, #5 and #7. The goal is to implement the overlapping bot screen/router/client changes on one feature branch (ideally one PR with logical commits), rather than creating conflicting PRs for closely related changes.

Out of scope: removing the Inbounds menu (#4), top-5 users by traffic over the last 5/15 minutes (#6), building a payment/shop bot, or adding a required external service.

Existing issues/PRs: avoid duplication

  • #6984 and open PR #6986 already cover the v3.11.0 admin regression where subscription/QR screens became unreachable. Reuse that PR's solution or rebase on it; do not create a competing restoration. The additional request here is one-tap, share-ready delivery of the subscription URL together with its QR.
  • #4778 covers identifying the actual active inbound tag/port of clients attached to multiple inbounds, including the Web UI. This request addresses the Telegram online-clients view only. Do not close #4778 just because the bot stops displaying a misleading inbound.
  • #6562 fixed an earlier hardcoded QR-caption string. This does not eliminate the remaining Persian translation issues.
  • #6298 concerns deferred/automatic renewal after depletion; the quick renewal proposed here is immediate and admin-initiated.

1. Fix remaining Persian translations and hardcoded bot text

Current: internal/web/translation/fa-IR.json contains untranslated bot labels such as Back, Find inbound…, Individual links, and Inline mode is disabled. Some existing Persian labels are unnatural. Go code also embeds user-visible English in the new-client draft (e.g. New client draft, Unlimited(Reset)).

Expected:

  • Audit the Telegram bot translation keys/strings and replace inconsistent or unnatural Persian with clear, contextual terminology (client/user, subscription, traffic, inbounds, buttons, confirmations, errors).
  • Move user-visible hardcoded English in bot screens to existing/new I18nBot keys as appropriate. Add localized strings for the new flows in this issue.
  • Keep key names, placeholders, HTML escaping, and other supported locales intact. Add tests for translation-key and interpolation-placeholder compatibility.

Relevant: internal/web/translation/fa-IR.json, internal/web/service/tgbot/tgbot_client.go, screen_view.go, screen_inline.go, screen_legacy.go.

2 + 7. One-tap subscription/QR sharing and concise TXT/config exports

Current: screenClientLinks presents the subscription URLs; screenClientQR presents QR codes separately. The generator clientSubLinks can already return individual config links. There is no unified admin export/share workflow.

Expected: Add a Share / Export action on the authorized admin's client card, with four clearly labelled modes:

  1. Client summary: name/email, status, usage, quota, expiry, attached inbounds (no unrelated users' data).
  2. Subscription URL only: directly copyable primary subscription URL; JSON URL only if enabled/relevant.
  3. Raw config TXT: a UTF-8 Telegram document named safely, e.g. client-configs.txt, containing all generated vless://, trojan://, etc. links, one per line, without truncation.
  4. Subscription URL + QR: one forwardable primary subscription QR plus the same copyable URL in the image caption, or a second immediately associated text message when the caption limit is exceeded.

Reuse existing link generation and preserve the current QR sheet/individual-links screens. No dependency on having the client visit Telegram through an invite link. Handle missing URLs and generator errors explicitly. Respect Telegram's ~1024-character photo-caption and ~4096-character text limits. Do not disclose secrets via public/group inline results. Enforce admin authorization at action execution time and preserve client self-service access only to a client's own subscription.

Relevant: screen_client_views.go, screen_client_qr.go, screen_legacy.go, tgbot_router.go, tgbot_send.go; coordinate with PR #6986.

3. Predefined plan presets and quick client creation/renewal

Goal: Admins can define reusable presets, e.g. plan A = 30 GB / 30 days / selected inbound(s), plan B = 60 GB / 90 days. Include normal reusable client settings such as traffic cap, expiry duration/mode, attached inbound IDs, IP limit, reset policy and initial enable state. Generate per-client identities/protocol secrets freshly, never by copying another user's UUID/password.

Quick creation example:

/add ali A

Populate the existing multi-inbound add-client draft using preset A and show an admin-only confirmation preview before calling the existing ClientService.Create. Also offer a private-chat button/inline-keyboard path. Validate all inbound IDs and protocol compatibility at commit time.

Quick renewal example:

/renew ali 30gb 30d

Allow a named preset alternative. Show old → new usage, quota, expiry and reset behavior before confirmation. Explicitly distinguish add quota vs set total quota, and extend expiry vs reset expiry from now. Define handling for expired/disabled clients, negative (first-use) expiry and unlimited plans; avoid implicit reset of consumed data. Preserve UUID, subId, TG binding, and multi-inbound assignments unless the admin explicitly requests otherwise. Observe existing global-aware traffic rules on multi-node setups.

An inline query @bot ... is a search/selection flow, not a safe transaction trigger. Do not mutate quotas or create clients simply when an inline query is typed or selected. Commands/callback confirmations must be admin-authorized and private-chat only. Protect against duplicate button taps, stale drafts, repeated confirmation, parallel admins and partial updates. Reuse existing client services and storage/migration conventions (SQLite + PostgreSQL). No shop/payment functionality.

Relevant: tgbot.go (clientDraft), tgbot_router.go, tgbot_client.go, ClientService.Create and existing client traffic/expiry update services.

5. Correct online clients in multi-inbound setups

Current: screenOnlines takes an email-only set from GetOnlineClients() and appends the Remark of one associated inbound via GetClientInboundByEmail(email). A client can be attached to multiple inbounds. This remark does not prove which inbound currently carries a live connection and can mislead administrators.

Expected:

  • Show unique online client identities and accurate connection status across local and node-managed traffic; preserve existing online-set semantics.
  • Only label an inbound as active when authoritative per-email/per-inbound runtime evidence exists. Otherwise, display just the email or label attached inbounds explicitly as configured/attached, not active.
  • Do not infer active inbound from client_traffics.inbound_id, the first attached inbound or the first DB result.
  • Handle moved/deleted inbounds safely and avoid a per-online-client N+1 database lookup. Leave a larger Xray per-connection attribution implementation to #4778.

Relevant: screen_views.go:screenOnlines, internal/xray/process.go:GetOnlineClients, internal/web/service/inbound_clients.go:GetClientInboundByEmail.

Acceptance criteria

  • Persian bot UI strings are natural and complete; no broken keys or template placeholders.
  • Authorized admin can share the primary subscription URL + QR together, a URL-only message, a safe UTF-8 TXT of all generated links, or a concise status summary.
  • Admin can save a preset, create a client using it, and renew an existing user with a deterministic preview/confirmation and documented traffic/expiry semantics.
  • Untrusted clients/forged callbacks cannot view or modify other users; no mutations from inline-query keystrokes or unconfirmed selections; repeated taps cannot renew twice.
  • Online-clients screen does not misidentify a configured inbound as the active one, even for attached/moved multi-inbound clients and remote nodes.
  • Regression tests cover multi-inbound clients, global traffic, expired/first-use expiry, duplicate callbacks/concurrency, restart/preset persistence, TXT/link lengths, localization, authorization, and Telegram output limits.
  • Preserve compatibility with SQLite and PostgreSQL and avoid unnecessary recurring database queries, migrations, extra dependencies, or regressions in existing bot screens.

Implementation / PR coordination

Please develop this on one feature branch with logically separated commits and shared screen/actions helpers, then submit one coordinated PR if acceptable to maintainers. Integrate or rebase onto #6986 once available instead of duplicating its button restoration. Link #4778 as related, but do not auto-close it unless the actual active-inbound attribution gap is fully solved. All five parts are scoped here for development coordination; the commits should remain separable if review requires smaller PRs.

Originally created by @HamedSanaei on GitHub (Oct 28, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/7010 ## Summary This is a **single, coordinated Telegram-bot admin-workflow improvement** covering requests **#1, #2, #3, #5 and #7**. The goal is to implement the overlapping bot screen/router/client changes on **one feature branch** (ideally one PR with logical commits), rather than creating conflicting PRs for closely related changes. **Out of scope:** removing the Inbounds menu (#4), top-5 users by traffic over the last 5/15 minutes (#6), building a payment/shop bot, or adding a required external service. ### Existing issues/PRs: avoid duplication - **#6984 and open PR #6986** already cover the v3.11.0 admin regression where subscription/QR screens became unreachable. Reuse that PR's solution or rebase on it; **do not create a competing restoration**. The *additional* request here is one-tap, share-ready delivery of the subscription URL **together with its QR**. - **#4778** covers identifying the *actual active inbound tag/port* of clients attached to multiple inbounds, including the Web UI. This request addresses the **Telegram online-clients view** only. Do not close #4778 just because the bot stops displaying a misleading inbound. - **#6562** fixed an earlier hardcoded QR-caption string. This does not eliminate the remaining Persian translation issues. - **#6298** concerns deferred/automatic renewal after depletion; the quick renewal proposed here is **immediate and admin-initiated**. ## 1. Fix remaining Persian translations and hardcoded bot text **Current:** `internal/web/translation/fa-IR.json` contains untranslated bot labels such as `Back`, `Find inbound…`, `Individual links`, and `Inline mode is disabled`. Some existing Persian labels are unnatural. Go code also embeds user-visible English in the new-client draft (e.g. `New client draft`, `Unlimited(Reset)`). **Expected:** - Audit the **Telegram bot** translation keys/strings and replace inconsistent or unnatural Persian with clear, contextual terminology (client/user, subscription, traffic, inbounds, buttons, confirmations, errors). - Move user-visible hardcoded English in bot screens to existing/new `I18nBot` keys as appropriate. Add localized strings for the new flows in this issue. - Keep key names, placeholders, HTML escaping, and other supported locales intact. Add tests for translation-key and interpolation-placeholder compatibility. Relevant: `internal/web/translation/fa-IR.json`, `internal/web/service/tgbot/tgbot_client.go`, `screen_view.go`, `screen_inline.go`, `screen_legacy.go`. ## 2 + 7. One-tap subscription/QR sharing and concise TXT/config exports **Current:** `screenClientLinks` presents the subscription URLs; `screenClientQR` presents QR codes separately. The generator `clientSubLinks` can already return individual config links. There is no unified admin export/share workflow. **Expected:** Add a **Share / Export** action on the authorized admin's client card, with four clearly labelled modes: 1. **Client summary**: name/email, status, usage, quota, expiry, attached inbounds (no unrelated users' data). 2. **Subscription URL only**: directly copyable primary subscription URL; JSON URL only if enabled/relevant. 3. **Raw config TXT**: a UTF-8 Telegram document named safely, e.g. `client-configs.txt`, containing all generated `vless://`, `trojan://`, etc. links, one per line, **without truncation**. 4. **Subscription URL + QR**: one forwardable primary subscription QR plus the *same copyable URL* in the image caption, or a second immediately associated text message when the caption limit is exceeded. Reuse existing link generation and preserve the current QR sheet/individual-links screens. No dependency on having the client visit Telegram through an invite link. Handle missing URLs and generator errors explicitly. Respect Telegram's ~1024-character photo-caption and ~4096-character text limits. Do not disclose secrets via public/group inline results. Enforce admin authorization at action execution time and preserve client self-service access only to a client's **own** subscription. Relevant: `screen_client_views.go`, `screen_client_qr.go`, `screen_legacy.go`, `tgbot_router.go`, `tgbot_send.go`; coordinate with **PR #6986**. ## 3. Predefined plan presets and quick client creation/renewal **Goal:** Admins can define reusable presets, e.g. plan `A` = **30 GB / 30 days / selected inbound(s)**, plan `B` = **60 GB / 90 days**. Include normal reusable client settings such as traffic cap, expiry duration/mode, attached inbound IDs, IP limit, reset policy and initial enable state. Generate per-client identities/protocol secrets **freshly**, never by copying another user's UUID/password. **Quick creation example:** ```text /add ali A ``` Populate the existing multi-inbound add-client draft using preset A and show an admin-only confirmation preview before calling the existing `ClientService.Create`. Also offer a private-chat button/inline-keyboard path. Validate all inbound IDs and protocol compatibility at commit time. **Quick renewal example:** ```text /renew ali 30gb 30d ``` Allow a named preset alternative. Show old → new **usage, quota, expiry and reset behavior** before confirmation. Explicitly distinguish **add quota vs set total quota**, and **extend expiry vs reset expiry from now**. Define handling for expired/disabled clients, negative (first-use) expiry and unlimited plans; avoid implicit reset of consumed data. Preserve UUID, `subId`, TG binding, and multi-inbound assignments unless the admin explicitly requests otherwise. Observe existing **global-aware traffic** rules on multi-node setups. An inline query `@bot ...` is a *search/selection* flow, **not a safe transaction trigger**. Do **not** mutate quotas or create clients simply when an inline query is typed or selected. Commands/callback confirmations must be admin-authorized and **private-chat only**. Protect against duplicate button taps, stale drafts, repeated confirmation, parallel admins and partial updates. Reuse existing client services and storage/migration conventions (SQLite + PostgreSQL). No shop/payment functionality. Relevant: `tgbot.go` (`clientDraft`), `tgbot_router.go`, `tgbot_client.go`, `ClientService.Create` and existing client traffic/expiry update services. ## 5. Correct online clients in multi-inbound setups **Current:** `screenOnlines` takes an email-only set from `GetOnlineClients()` and appends the `Remark` of **one associated inbound** via `GetClientInboundByEmail(email)`. A client can be attached to multiple inbounds. This remark does **not** prove which inbound currently carries a live connection and can mislead administrators. **Expected:** - Show unique online client identities and accurate connection status across local and node-managed traffic; preserve existing online-set semantics. - **Only label an inbound as active when authoritative per-email/per-inbound runtime evidence exists.** Otherwise, display just the email or label attached inbounds explicitly as *configured/attached*, not *active*. - Do not infer active inbound from `client_traffics.inbound_id`, the first attached inbound or the first DB result. - Handle moved/deleted inbounds safely and avoid a per-online-client N+1 database lookup. Leave a larger Xray per-connection attribution implementation to **#4778**. Relevant: `screen_views.go:screenOnlines`, `internal/xray/process.go:GetOnlineClients`, `internal/web/service/inbound_clients.go:GetClientInboundByEmail`. ## Acceptance criteria - [ ] Persian bot UI strings are natural and complete; no broken keys or template placeholders. - [ ] Authorized admin can share the **primary subscription URL + QR together**, a URL-only message, a safe UTF-8 TXT of **all** generated links, or a concise status summary. - [ ] Admin can save a preset, create a client using it, and renew an existing user with a deterministic preview/confirmation and documented traffic/expiry semantics. - [ ] Untrusted clients/forged callbacks cannot view or modify other users; no mutations from inline-query keystrokes or unconfirmed selections; repeated taps cannot renew twice. - [ ] Online-clients screen does not misidentify a configured inbound as the active one, even for attached/moved multi-inbound clients and remote nodes. - [ ] Regression tests cover multi-inbound clients, global traffic, expired/first-use expiry, duplicate callbacks/concurrency, restart/preset persistence, TXT/link lengths, localization, authorization, and Telegram output limits. - [ ] Preserve compatibility with SQLite and PostgreSQL and avoid unnecessary recurring database queries, migrations, extra dependencies, or regressions in existing bot screens. ## Implementation / PR coordination Please develop this on **one feature branch** with logically separated commits and shared screen/actions helpers, then submit **one coordinated PR** if acceptable to maintainers. Integrate or rebase onto **#6986** once available instead of duplicating its button restoration. Link **#4778** as related, but do not auto-close it unless the *actual active-inbound attribution* gap is fully solved. All five parts are scoped here for development coordination; the commits should remain separable if review requires smaller PRs.
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#4618
No description provided.