mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-19 11:34:59 +03:00
fix(tgbot): keep backup files in the chat and the menu below them (#7092)
Every bot notice carries a Hide button, which deletes the message it sits on. On a backup that message is the file itself: one tap, with no confirmation, could remove the admin's only copy of the database. Backup files (the .db and config.json, from the backup button, the scheduled job and the panel's backup-to-Telegram endpoint) are now sent without a keyboard; other notices, including the ban log file, keep Hide. The backup button also left the menu above the files it sent, out of view at the bottom of the chat. It now sends the Maintenance menu again below them and removes the old one. A scheduled backup leaves the menu where it is.
This commit is contained in:
@@ -266,11 +266,11 @@ func (t *Tgbot) sendBackupScreen(chatID int64) {
|
||||
// carries the backup and what it is for.
|
||||
body := summary + "\n\n" + t.depleteReport()
|
||||
caption := trimCaption(body, botCaptionLimit)
|
||||
if t.sendDocumentWithCaption(chatID, dbData, t.serverService.BackupFilename(""), caption) {
|
||||
if t.sendBackupFile(chatID, dbData, t.serverService.BackupFilename(""), caption) {
|
||||
// The generated config travels with the DB on both backup paths: an
|
||||
// operator restoring from the file would otherwise lose it silently.
|
||||
if config, err := os.ReadFile(xray.GetConfigPath()); err == nil {
|
||||
t.sendDocumentWithCaption(chatID, config, "config.json", "")
|
||||
t.sendBackupFile(chatID, config, "config.json", "")
|
||||
}
|
||||
if rest := strings.TrimSpace(strings.TrimPrefix(body, caption)); rest != "" {
|
||||
// Rare: the summary outgrew a caption. The file already landed.
|
||||
|
||||
Reference in New Issue
Block a user