mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6879] [MERGED] feat(tgbot): route admin notifications to a forum topic #6495
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#6495
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/6879
Author: @gr219
Created: 10/20/2026
Status: ✅ Merged
Merged: 10/24/2026
Merged by: @MHSanaei
Base:
main← Head:feat/tgbot-forum-topics📝 Commits (8)
32d98c2feat(tgbot): route admin notifications to a forum topic21e7bf9fix(tgbot): treat topic 1 as the General topic7d2ad7cfix(tgbot): align docs helper with panel topic rules, drop dead broadcast hunk8f6a15fMerge remote-tracking branch 'origin/main' into pr/6879a18bb37Merge remote-tracking branch 'origin/main' into pr/687924e39f0test(tgbot): keep the admin-topic tests in tgbot_test.go86dbb72fix(i18n): mention forum topics in every Telegram chat ID hint3720a84docs(telegram): describe forum-topic chat IDs in the fa, ru and zh guides📊 Changes
25 files changed (+245 additions, -53 deletions)
View changed files
📝
docs/components/tools/telegram-setup-helper.tsx(+1 -1)📝
docs/content/docs/en/operations/telegram-bot.mdx(+6 -1)📝
docs/content/docs/fa/operations/telegram-bot.mdx(+6 -1)📝
docs/content/docs/ru/operations/telegram-bot.mdx(+6 -1)📝
docs/content/docs/zh/operations/telegram-bot.mdx(+5 -1)📝
docs/lib/xray/telegram.test.ts(+40 -2)📝
docs/lib/xray/telegram.ts(+22 -9)📝
internal/web/service/tgbot/tgbot.go(+63 -11)📝
internal/web/service/tgbot/tgbot_client.go(+3 -3)📝
internal/web/service/tgbot/tgbot_report.go(+4 -4)📝
internal/web/service/tgbot/tgbot_send.go(+8 -6)📝
internal/web/service/tgbot/tgbot_test.go(+68 -0)📝
internal/web/translation/ar-EG.json(+1 -1)📝
internal/web/translation/en-US.json(+1 -1)📝
internal/web/translation/es-ES.json(+1 -1)📝
internal/web/translation/fa-IR.json(+1 -1)📝
internal/web/translation/id-ID.json(+1 -1)📝
internal/web/translation/ja-JP.json(+1 -1)📝
internal/web/translation/pt-BR.json(+1 -1)📝
internal/web/translation/ru-RU.json(+1 -1)...and 5 more files
📄 Description
Summary
Lets the Telegram Admin Chat ID setting target a forum topic: write an entry as
chatId:topicId(e.g.-1001234567890:42) and every bot message to that chat is sent withmessage_thread_id, so it lands in the chosen topic instead of "General".Why
In forum-enabled supergroups the bot currently posts everything (reports, login alerts, backups, command replies) into the General topic, because only a bare chat ID can be configured. Admins who split a group into topics have no way to route panel notifications to the right one.
Type of change
Areas affected
Details:
tgbot.go: newparseAdminChatsreplaces the inline loop. It acceptschatId[:topicId]entries, trims spaces, de-duplicates chats, and rejects a non-positive or conflicting topic for the same chat. Topics are kept inadminTopicsnext toadminIdsundertgBotMutex.adminIds, and thereforecheckAdmin, still holds plain chat IDs.SendMsgToTgbot,SendMsgToTgbotDeleteAfterand everySendDocument(backups, config.json, ban logs, QR codes) now setMessageThreadIDfor chats that have a topic configured. Broadcasts are untouched because they never go to admin chats.chatId:1is treated as a barechatId. General is thread 1 inside Telegram, but the Bot API rejectsmessage_thread_id=1and reaches General only when the field is left out. telego tags the fieldomitempty, so chats without a topic send no thread ID.en-USsetting description anddocs/.../telegram-bot.mdxexplain the syntax. The docs setup helper (docs/lib/xray/telegram.ts) follows the same rules as the Go parser: it keeps the suffix, merges repeated chats, and marks a second, different topic for the same chat as invalid.How was this tested?
tgbot_admin_topic_test.go: parsing table (plain, topic, spaces, duplicates), invalid inputs (123:,123:0,123:-5,123:abc, conflicting topics, trailing comma), andinAdminTopicsettingMessageThreadIDonly for configured chats. I broke the implementation on purpose and confirmed these tests fail.go test ./internal/web/service/tgbot/ ./internal/web/controller/pass (Go 1.27).gofmtis clean.golangci-lint run(v2.15.0) on the tgbot package: 0 issues.oxfmt --check,oxlintandvitestpass on the changed files, including new cases for topics, General (:1) and conflicting topics.Breaking changes
None. Plain chat IDs parse exactly as before. Settings without
:behave the same.Checklist
go build ./...and the test suite pass locally.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.