From f58e28412f274ae89372471372c59b59842a0fea Mon Sep 17 00:00:00 2001 From: krau <71133316+krau@users.noreply.github.com> Date: Sat, 12 Oct 2024 13:03:11 +0800 Subject: [PATCH] feat: task progress --- core/core.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/core.go b/core/core.go index a241f22..3c19dab 100644 --- a/core/core.go +++ b/core/core.go @@ -21,6 +21,7 @@ func processPendingTask(task types.Task) error { return err } logger.L.Debugf("Start downloading file: %s", task.FileName) + bot.Client.EditMessage(task.ChatID, task.ReplyMessageID, "正在下载文件...") dest, err := message.Download(&telegram.DownloadOptions{ FileName: common.GetCacheFilePath(task.FileName), // ProgressCallback: func(totalBytes, downloadedBytes int64) {}, @@ -42,9 +43,11 @@ func processPendingTask(task types.Task) error { task.StoragePath = task.FileName } + bot.Client.EditMessage(task.ChatID, task.ReplyMessageID, "下载完成, 正在转存文件...") if err := storage.Save(task.Storage, task.Ctx, dest, task.StoragePath); err != nil { return err } + return nil } @@ -71,8 +74,10 @@ func worker(queue *queue.TaskQueue, semaphore chan struct{}) { queue.AddTask(task) case types.Succeeded: logger.L.Infof("Task succeeded: %s", task.String()) + bot.Client.EditMessage(task.ChatID, task.ReplyMessageID, "文件保存成功") case types.Failed: logger.L.Errorf("Task failed: %s", task.String()) + bot.Client.EditMessage(task.ChatID, task.ReplyMessageID, "文件保存失败") case types.Canceled: logger.L.Infof("Task canceled: %s", task.String()) default: