* Initial plan * Implement parameter support for /ytdlp command Co-authored-by: krau <71133316+krau@users.noreply.github.com> * Add comprehensive tests for ytdlp parameter parsing Co-authored-by: krau <71133316+krau@users.noreply.github.com> * Improve flag parsing logic and clarify argument order Co-authored-by: krau <71133316+krau@users.noreply.github.com> * Preserve critical defaults and improve comments Co-authored-by: krau <71133316+krau@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: krau <71133316+krau@users.noreply.github.com>
57 lines
1.6 KiB
Go
57 lines
1.6 KiB
Go
package shortcut
|
|
|
|
import (
|
|
"github.com/celestix/gotgproto/dispatcher"
|
|
"github.com/celestix/gotgproto/ext"
|
|
"github.com/charmbracelet/log"
|
|
"github.com/gotd/td/tg"
|
|
"github.com/krau/SaveAny-Bot/client/bot/handlers/utils/msgelem"
|
|
"github.com/krau/SaveAny-Bot/common/i18n"
|
|
"github.com/krau/SaveAny-Bot/common/i18n/i18nk"
|
|
"github.com/krau/SaveAny-Bot/common/utils/tgutil"
|
|
"github.com/krau/SaveAny-Bot/common/utils/tphutil"
|
|
"github.com/krau/SaveAny-Bot/core"
|
|
tphtask "github.com/krau/SaveAny-Bot/core/tasks/telegraph"
|
|
"github.com/krau/SaveAny-Bot/pkg/telegraph"
|
|
"github.com/krau/SaveAny-Bot/storage"
|
|
"github.com/rs/xid"
|
|
)
|
|
|
|
func CreateAndAddtelegraphWithEdit(
|
|
ctx *ext.Context,
|
|
userID int64,
|
|
tphpage *telegraph.Page,
|
|
dirPath string, // unescaped ph path for file storage
|
|
pics []string,
|
|
stor storage.Storage,
|
|
trackMsgID int) error {
|
|
|
|
injectCtx := tgutil.ExtWithContext(ctx.Context, ctx)
|
|
task := tphtask.NewTask(xid.New().String(),
|
|
injectCtx,
|
|
tphpage.Path,
|
|
pics,
|
|
stor,
|
|
stor.JoinStoragePath(dirPath),
|
|
tphutil.DefaultClient(),
|
|
tphtask.NewProgress(trackMsgID, userID),
|
|
)
|
|
if err := core.AddTask(injectCtx, task); err != nil {
|
|
log.FromContext(ctx).Errorf("Failed to add task: %s", err)
|
|
ctx.EditMessage(userID, &tg.MessagesEditMessageRequest{
|
|
ID: trackMsgID,
|
|
Message: i18n.T(i18nk.BotMsgCommonErrorTaskAddFailed, map[string]any{
|
|
"Error": err.Error(),
|
|
}),
|
|
})
|
|
return dispatcher.EndGroups
|
|
}
|
|
text, entities := msgelem.BuildTaskAddedEntities(ctx, tphpage.Title, core.GetLength(ctx))
|
|
ctx.EditMessage(userID, &tg.MessagesEditMessageRequest{
|
|
ID: trackMsgID,
|
|
Message: text,
|
|
Entities: entities,
|
|
})
|
|
return dispatcher.EndGroups
|
|
}
|