feat: add task command to client and Title method to Task for tasks queue managing, #157

This commit is contained in:
krau
2025-12-15 11:29:55 +08:00
parent 51198a1e3d
commit 0ca3d97711
12 changed files with 210 additions and 24 deletions

View File

@@ -2,11 +2,13 @@ package directlinks
import (
"context"
"fmt"
"net/http"
"sync"
"sync/atomic"
"github.com/krau/SaveAny-Bot/config"
"github.com/krau/SaveAny-Bot/core"
"github.com/krau/SaveAny-Bot/pkg/enums/tasktype"
"github.com/krau/SaveAny-Bot/storage"
)
@@ -25,6 +27,8 @@ func (f *File) FileSize() int64 {
return f.Size
}
var _ core.Executable = (*Task)(nil)
type Task struct {
ID string
ctx context.Context
@@ -44,6 +48,11 @@ type Task struct {
failed map[string]error // [TODO] errors for each file
}
// Title implements core.Exectable.
func (t *Task) Title() string {
return fmt.Sprintf("[%s](%s...->%s:%s)", t.Type(), t.files[0].Name, t.Storage.Name(), t.StorPath)
}
// DownloadedBytes implements TaskInfo.
func (t *Task) DownloadedBytes() int64 {
return t.downloadedBytes.Load()