mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-06-05 23:51:57 +08:00
feat: update download task message to include detailed progress information
This commit is contained in:
19
core/core.go
19
core/core.go
@@ -31,12 +31,6 @@ func processPendingTask(task *types.Task) error {
|
|||||||
return fmt.Errorf("failed to create directory: %w", err)
|
return fmt.Errorf("failed to create directory: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := task.Ctx.(*ext.Context)
|
|
||||||
ctx.EditMessage(task.ChatID, &tg.MessagesEditMessageRequest{
|
|
||||||
Message: "正在下载: " + task.FileName(),
|
|
||||||
ID: task.ReplyMessageID,
|
|
||||||
})
|
|
||||||
|
|
||||||
if task.StoragePath == "" {
|
if task.StoragePath == "" {
|
||||||
task.StoragePath = task.File.FileName
|
task.StoragePath = task.File.FileName
|
||||||
}
|
}
|
||||||
@@ -53,6 +47,8 @@ func processPendingTask(task *types.Task) error {
|
|||||||
return processPhoto(task, cacheDestPath)
|
return processPhoto(task, cacheDestPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx := task.Ctx.(*ext.Context)
|
||||||
|
|
||||||
barTotalCount := calculateBarTotalCount(task.File.FileSize)
|
barTotalCount := calculateBarTotalCount(task.File.FileSize)
|
||||||
|
|
||||||
progressCallback := func(bytesRead, contentLength int64) {
|
progressCallback := func(bytesRead, contentLength int64) {
|
||||||
@@ -74,6 +70,17 @@ func processPendingTask(task *types.Task) error {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.EditMessage(task.ChatID, &tg.MessagesEditMessageRequest{
|
||||||
|
Message: fmt.Sprintf("正在处理下载任务\n文件名: %s\n保存路径: %s\n平均速度: %s\n当前进度: [%s] %.2f%%",
|
||||||
|
task.FileName(),
|
||||||
|
fmt.Sprintf("[%s]:%s", task.Storage, task.StoragePath),
|
||||||
|
"0B/s",
|
||||||
|
getProgressBar(0, barTotalCount),
|
||||||
|
0.0,
|
||||||
|
),
|
||||||
|
ID: task.ReplyMessageID,
|
||||||
|
})
|
||||||
|
|
||||||
readCloser, err := NewTelegramReader(task.Ctx, bot.Client, &task.File.Location,
|
readCloser, err := NewTelegramReader(task.Ctx, bot.Client, &task.File.Location,
|
||||||
0, task.File.FileSize-1, task.File.FileSize,
|
0, task.File.FileSize-1, task.File.FileSize,
|
||||||
progressCallback, task.File.FileSize/100)
|
progressCallback, task.File.FileSize/100)
|
||||||
|
|||||||
Reference in New Issue
Block a user