mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #6697] [CLOSED] feat(tgbot): let customers fetch their own configs and guides #6417
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#6417
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/6697
Author: @pcxzs
Created: 9/30/2026
Status: ❌ Closed
Base:
main← Head:feat/tgbot-customer-menu📝 Commits (7)
8dd2a13feat(tgbot): let customers fetch their own configs and guides933fd81docs(tgbot): describe the customer self-service menu6e7d20ffix(tgbot): serve main's client verbs and give the menu an entry point929d711Merge branch 'main' into feat/tgbot-customer-menu828e006Merge branch 'main' into feat/tgbot-customer-menu6318beadocs(tgbot): put the expiry and quota header where the bot shows ite7e490dtest(tgbot): check each restored client verb sends its own output📊 Changes
29 files changed (+1821 additions, -107 deletions)
View changed files
📝
docs/content/docs/en/operations/telegram-bot.mdx(+20 -0)➕
internal/web/service/tgbot/tgbot_configs.go(+109 -0)➕
internal/web/service/tgbot/tgbot_configs_test.go(+308 -0)➕
internal/web/service/tgbot/tgbot_customer.go(+94 -0)➕
internal/web/service/tgbot/tgbot_customer_fixture_test.go(+58 -0)➕
internal/web/service/tgbot/tgbot_customer_keyboard.go(+28 -0)➕
internal/web/service/tgbot/tgbot_customer_review_test.go(+217 -0)➕
internal/web/service/tgbot/tgbot_customer_test.go(+124 -0)➕
internal/web/service/tgbot/tgbot_guide.go(+64 -0)➕
internal/web/service/tgbot/tgbot_guide_menu_test.go(+62 -0)➕
internal/web/service/tgbot/tgbot_guide_test.go(+49 -0)➕
internal/web/service/tgbot/tgbot_header.go(+45 -0)📝
internal/web/service/tgbot/tgbot_router.go(+53 -68)➕
internal/web/service/tgbot/tgbot_selfaction.go(+97 -0)➕
internal/web/service/tgbot/tgbot_selfaction_test.go(+128 -0)📝
internal/web/service/tgbot/tgbot_send.go(+1 -13)📝
internal/web/translation/ar-EG.json(+28 -2)📝
internal/web/translation/en-US.json(+28 -2)📝
internal/web/translation/es-ES.json(+28 -2)📝
internal/web/translation/fa-IR.json(+28 -2)...and 9 more files
📄 Description
Summary
Part 2 of the Telegram bot split discussed in #6428, following #6518 (access
levels and
/startbinding). A bound customer can now get their own links, QRcodes and per-platform setup guide from the bot, without asking the admin.
Why
Today a customer who wants a config has to ask the operator for it, and the
operator has to find the client and paste a link into a private chat. The panel
already has the subscription URL, the share links and the QR codes, and
mainalready lets a linked customer fetch all three — but only by tapping abutton on one specific admin message, with no menu to navigate from and no
instructions for what to do with the link afterwards.
What changes
client_menu) reachable from the existing client commands,opening a keyboard of what the customer can do for themselves.
client_one_link/link_one: a picker that asks which of the client's linksto send instead of returning all of them, which matters for a client attached
to several inbounds.
clientHeader: every link page now names the config it is showing, with itsexpiry date and remaining quota, so a customer holding several can tell them
apart. A config with no quota reads as unlimited rather than as zero left.
guide_menu/guide_<platform>: plain-text setup instructions foriPhone/iPad, Android, Windows, macOS and Linux, each naming a currently
maintained app. Telegram only accepts
http,httpsandtg://in linkbuttons, so these are text and not tap-through links.
tgbot_router.gocollapse into oneclientEmailPickercall each, which drops ~60 lines of duplication.Builds on the helpers already in
mainrather than replacing them:clientSubLinks(in-process, so it does not need the subscription host toresolve here),
sendClientSubLinks,sendClientIndividualLinks,sendClientQRLinks,clientOwnedByTgUserand thechatUseractor keying.Outside
internal/web/service/tgbot/:existing
tgbot.buttonsandtgbot.messagesobjects.Not in this PR: renewal requests and reminders, per-user notification
settings, messaging the admin, the multi-bind ceiling, and the admin roster and
bulk actions. Customer self-reset (credential rotation) is deliberately absent.
A QR chooser that asks whether you want the subscription URL or a single
individual link is also not here — it changes the existing QR behavior, so it
should be reviewed on its own.
Security
ownsClient) before it acts.The email in callback data is only a claim, since the keyboard outlives the
message it was sent with.
link_onecarries an attacker-chosen index alongside the email.clientSelfTargetdrops it before the check, andsplitClientLinkIndexrefuses a negative or unparsable index rather than reading past the slice.
/startand/id, and groups are still ignored.Those paths are untouched.
pins
client_cancel,client_edit,set_bindmax,admin_settingsandbroadcast_confirmagainstisClientSelfCallback.smuggled into
link_one, and an unbound account being told how to bindrather than shown a menu whose buttons would each refuse it.
Type of change
Areas affected
How was this tested?
tgbot_selfaction_test.go(verb splitting, the index beingstripped before the check, unusable input refused),
tgbot_configs_test.go(link labels, out-of-range index, ownership both ways, header and quota
labels, the configs step naming the config first),
tgbot_customer_test.go(menu routing, admin callbacks outside the allowlist, unbound vs bound),
tgbot_guide_test.goandtgbot_guide_menu_test.go(every platformresolves, unknown tags refused).
go build ./...,go vet ./...,go test -shuffle=on -count=1 ./...,golangci-lint(0 issues),oxlint,tsc --noEmitand the i18n dead-keystest all pass locally. No frontend source changed, so no frontend build was
needed.
above are covered by unit tests only.
Screenshots / recordings
The customer menu and one of the setup guides, from a test bot:
My configs→ All links / One link / Subscription URL / QR codes /Setup guide
Breaking changes
None.
main's existingclient_sub_links,client_individual_linksandclient_qr_linkscallbacks keep their current behavior, their routing and theirclientOwnedByTgUsercheck; this branch only adds new verbs alongside them.Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.