[PR #7092] fix(tgbot): keep backup files in the chat and the menu below them #6645

Open
opened 2026-11-07 14:34:22 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/7092
Author: @Plus98ir
Created: 11/7/2026
Status: 🔄 Open

Base: main ← Head: fix/tgbot-keep-backups


📝 Commits (2)

  • 18d2c6f fix(tgbot): keep backup files in the chat and the menu below them
  • 0fe3a42 style(tgbot): keep newScreenTgbot's comment on newScreenTgbot

📊 Changes

8 files changed (+168 additions, -15 deletions)

View changed files

➕ internal/web/service/tgbot/backup_delivery_test.go (+135 -0)
📝 internal/web/service/tgbot/notices.go (+6 -7)
📝 internal/web/service/tgbot/notices_test.go (+1 -1)
📝 internal/web/service/tgbot/screen_view.go (+2 -2)
📝 internal/web/service/tgbot/screen_views.go (+2 -2)
📝 internal/web/service/tgbot/screens_test.go (+18 -1)
📝 internal/web/service/tgbot/tgbot_report.go (+2 -2)
📝 internal/web/service/tgbot/tgbot_router.go (+2 -0)

📄 Description

Summary

Telegram backups no longer carry a Hide button, and the backup button now brings the menu back below the files it sends.

Why

Every bot notice has a Hide button, which deletes the message it sits on. That is fine for a report, but on a backup it deletes the file itself: one tap, with no confirmation, can remove the admin's only copy of the database. Both the .db file and config.json had the button, on the backup button path and on the scheduled path.

The backup button also left the menu above the files, so an admin at the bottom of the chat had no menu in view.

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

What changes for the admin

  • Backup files arrive with no keyboard. Other notices, including the ban log file, keep Hide.
  • After the backup button, the Maintenance menu is sent again below the files and the old menu is removed.
  • A scheduled backup does not move the menu, because the admin did not ask for it and may be using it.
  • Backup messages already in a chat keep their old Hide button, since this only affects new messages.

How was this tested?

New tests in internal/web/service/tgbot/backup_delivery_test.go, which run the real backup code against a recording Telegram server and a real SQLite database:

  • TestBackupFilesCarryNoHideButton covers the button and scheduled paths. It failed before the fix with the hide keyboard on both files.
  • TestBackupButtonMovesTheMenuBelowTheFiles checks the call order: two documents, then the new menu, then deleting the old one. It failed before the fix with no menu sent.
  • TestScheduledBackupLeavesTheMenuInPlace passes with or without the fix, as it guards the behaviour above. I confirmed it fails when the menu move is added to the scheduled path.

recordingServer now records multipart form fields, so tests can see an upload's reply_markup and file name.

Local results on Windows, on top of current main: go build ./..., golangci-lint run (0 issues), go test -shuffle=on ./..., go test -race for the tgbot package, npm run gen (no changes), and the frontend lint, tests and builds. make verify as a single command could not run its Go steps here because Git Bash make drops GOCACHE/GOPATH, so those steps were run directly.

Not tested against the live Telegram API.

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. (no frontend changes)
  • I updated the Wiki / README / API docs if user-facing behavior changed. (the docs do not describe this)
  • 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/7092 **Author:** [@Plus98ir](https://github.com/Plus98ir) **Created:** 11/7/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/tgbot-keep-backups` --- ### 📝 Commits (2) - [`18d2c6f`](https://github.com/MHSanaei/3x-ui/commit/18d2c6fca6af66de880458682c8b82ea64fec3b6) fix(tgbot): keep backup files in the chat and the menu below them - [`0fe3a42`](https://github.com/MHSanaei/3x-ui/commit/0fe3a42c85a5a13d9ecddbe3f304bdbd0dcbbe30) style(tgbot): keep newScreenTgbot's comment on newScreenTgbot ### 📊 Changes **8 files changed** (+168 additions, -15 deletions) <details> <summary>View changed files</summary> ➕ `internal/web/service/tgbot/backup_delivery_test.go` (+135 -0) 📝 `internal/web/service/tgbot/notices.go` (+6 -7) 📝 `internal/web/service/tgbot/notices_test.go` (+1 -1) 📝 `internal/web/service/tgbot/screen_view.go` (+2 -2) 📝 `internal/web/service/tgbot/screen_views.go` (+2 -2) 📝 `internal/web/service/tgbot/screens_test.go` (+18 -1) 📝 `internal/web/service/tgbot/tgbot_report.go` (+2 -2) 📝 `internal/web/service/tgbot/tgbot_router.go` (+2 -0) </details> ### 📄 Description ## Summary Telegram backups no longer carry a Hide button, and the backup button now brings the menu back below the files it sends. ## Why Every bot notice has a Hide button, which deletes the message it sits on. That is fine for a report, but on a backup it deletes the file itself: one tap, with no confirmation, can remove the admin's only copy of the database. Both the `.db` file and `config.json` had the button, on the backup button path and on the scheduled path. The backup button also left the menu above the files, so an admin at the bottom of the chat had no menu in view. ## Type of change - [x] 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) - [x] Telegram bot ## What changes for the admin - Backup files arrive with no keyboard. Other notices, including the ban log file, keep Hide. - After the backup button, the Maintenance menu is sent again below the files and the old menu is removed. - A scheduled backup does not move the menu, because the admin did not ask for it and may be using it. - Backup messages already in a chat keep their old Hide button, since this only affects new messages. ## How was this tested? New tests in `internal/web/service/tgbot/backup_delivery_test.go`, which run the real backup code against a recording Telegram server and a real SQLite database: - `TestBackupFilesCarryNoHideButton` covers the button and scheduled paths. It failed before the fix with the hide keyboard on both files. - `TestBackupButtonMovesTheMenuBelowTheFiles` checks the call order: two documents, then the new menu, then deleting the old one. It failed before the fix with no menu sent. - `TestScheduledBackupLeavesTheMenuInPlace` passes with or without the fix, as it guards the behaviour above. I confirmed it fails when the menu move is added to the scheduled path. `recordingServer` now records multipart form fields, so tests can see an upload's `reply_markup` and file name. Local results on Windows, on top of current `main`: `go build ./...`, `golangci-lint run` (0 issues), `go test -shuffle=on ./...`, `go test -race` for the tgbot package, `npm run gen` (no changes), and the frontend lint, tests and builds. `make verify` as a single command could not run its Go steps here because Git Bash `make` drops `GOCACHE`/`GOPATH`, so those steps were run directly. Not tested against the live Telegram API. ## Breaking changes None ## Checklist - [x] 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. (no frontend changes) - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. (the docs do not describe this) - [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#6645
No description provided.