From 6990543c9fd91e042ffd6f02ac50560a031e1499 Mon Sep 17 00:00:00 2001 From: krau <71133316+krau@users.noreply.github.com> Date: Mon, 19 Jan 2026 21:20:27 +0800 Subject: [PATCH] feat: update transfer command to remove target path requirement and adjust usage instructions --- client/bot/handlers/transfer.go | 14 ++++---------- client/bot/handlers/utils/msgelem/storage.go | 1 - common/i18n/locale/en.yaml | 8 ++++---- common/i18n/locale/zh-Hans.yaml | 8 ++++---- pkg/tcbdata/data.go | 1 - 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/client/bot/handlers/transfer.go b/client/bot/handlers/transfer.go index 31e55e5..6684334 100644 --- a/client/bot/handlers/transfer.go +++ b/client/bot/handlers/transfer.go @@ -2,7 +2,6 @@ package handlers import ( "fmt" - "path" "regexp" "strings" @@ -28,7 +27,7 @@ func handleTransferCmd(ctx *ext.Context, update *ext.Update) error { logger := log.FromContext(ctx) args := strutil.ParseArgsRespectQuotes(update.EffectiveMessage.Text) - if len(args) < 3 { + if len(args) < 2 { ctx.Reply(update, ext.ReplyTextString(i18n.T(i18nk.BotMsgTransferUsage, nil)), nil) return dispatcher.EndGroups } @@ -42,9 +41,6 @@ func handleTransferCmd(ctx *ext.Context, update *ext.Update) error { sourceStorageName := sourceParts[0] sourcePath := sourceParts[1] - // Parse target path (without storage name) - targetPath := args[2] - userID := update.GetUserChat().GetID() // Get source storage @@ -94,8 +90,8 @@ func handleTransferCmd(ctx *ext.Context, update *ext.Update) error { // Optional filter var filter *regexp.Regexp - if len(args) >= 4 { - filter, err = regexp.Compile(args[3]) + if len(args) >= 3 { + filter, err = regexp.Compile(args[2]) if err != nil { ctx.EditMessage(update.EffectiveChat().GetID(), &tg.MessagesEditMessageRequest{ ID: replied.ID, @@ -139,7 +135,6 @@ func handleTransferCmd(ctx *ext.Context, update *ext.Update) error { TransferSourceStorName: sourceStorageName, TransferSourcePath: sourcePath, TransferFiles: filePaths, - TransferTargetPath: targetPath, }) if err != nil { logger.Errorf("Failed to build storage selection keyboard: %s", err) @@ -209,7 +204,6 @@ func handleTransferCallback(ctx *ext.Context, userID int64, targetStorage storag } // Build task elements for the selected files - targetPath := path.Join(dirPath, data.TransferTargetPath) elems := make([]transfer.TaskElement, 0, len(data.TransferFiles)) var totalSize int64 for _, filePath := range data.TransferFiles { @@ -218,7 +212,7 @@ func handleTransferCallback(ctx *ext.Context, userID int64, targetStorage storag logger.Warnf("File not found in source storage: %s", filePath) continue } - elem := transfer.NewTaskElement(sourceStorage, fileInfo, targetStorage, targetPath) + elem := transfer.NewTaskElement(sourceStorage, fileInfo, targetStorage, dirPath) elems = append(elems, *elem) totalSize += fileInfo.Size } diff --git a/client/bot/handlers/utils/msgelem/storage.go b/client/bot/handlers/utils/msgelem/storage.go index d408ae2..f48ade7 100644 --- a/client/bot/handlers/utils/msgelem/storage.go +++ b/client/bot/handlers/utils/msgelem/storage.go @@ -57,7 +57,6 @@ func BuildAddSelectStorageKeyboard(stors []storage.Storage, adddata tcbdata.Add) TransferSourceStorName: adddata.TransferSourceStorName, TransferSourcePath: adddata.TransferSourcePath, TransferFiles: adddata.TransferFiles, - TransferTargetPath: adddata.TransferTargetPath, } dataid := xid.New().String() err := cache.Set(dataid, data) diff --git a/common/i18n/locale/en.yaml b/common/i18n/locale/en.yaml index 6692402..b0218a7 100644 --- a/common/i18n/locale/en.yaml +++ b/common/i18n/locale/en.yaml @@ -299,11 +299,11 @@ bot: error_download_failed: "yt-dlp download failed: {{.Error}}" transfer: usage: | - Usage: /transfer :/ [filter] + Usage: /transfer :/ [filter] Examples: - /transfer local1:/downloads /backup - /transfer alist1:/media/photos /photos - /transfer webdav1:/files /archive ".*\.mp4$" + /transfer local1:/downloads + /transfer alist1:/media/photos + /transfer webdav1:/files ".*\.mp4$" error_invalid_source: "Invalid source path format, should be: storage_name:/path" error_invalid_target: "Invalid target path format, should be: storage_name:/path" error_storage_not_found: "Storage '{{.StorageName}}' not found or access denied: {{.Error}}" diff --git a/common/i18n/locale/zh-Hans.yaml b/common/i18n/locale/zh-Hans.yaml index 387dabf..e460d3d 100644 --- a/common/i18n/locale/zh-Hans.yaml +++ b/common/i18n/locale/zh-Hans.yaml @@ -300,11 +300,11 @@ bot: error_download_failed: "yt-dlp 下载失败: {{.Error}}" transfer: usage: | - 用法: /transfer :/ [filter] + 用法: /transfer :/ [filter] 示例: - /transfer local1:/downloads /backup - /transfer alist1:/media/photos /photos - /transfer webdav1:/files /archive ".*\.mp4$" + /transfer local1:/downloads + /transfer alist1:/media/photos + /transfer webdav1:/files ".*\.mp4$" error_invalid_source: "源路径格式无效,应为: storage_name:/path" error_invalid_target: "目标路径格式无效,应为: storage_name:/path" error_storage_not_found: "存储端 '{{.StorageName}}' 不存在或您无权访问: {{.Error}}" diff --git a/pkg/tcbdata/data.go b/pkg/tcbdata/data.go index 90e4794..e94ff5f 100644 --- a/pkg/tcbdata/data.go +++ b/pkg/tcbdata/data.go @@ -54,7 +54,6 @@ type Add struct { TransferSourceStorName string TransferSourcePath string TransferFiles []string // file paths relative to source storage - TransferTargetPath string } type SetDefaultStorage struct {