add exporter offset
This commit is contained in:
@@ -22,6 +22,8 @@ type TClient struct {
|
|||||||
logger *zap.Logger
|
logger *zap.Logger
|
||||||
api *tg.Client
|
api *tg.Client
|
||||||
|
|
||||||
|
downloadMedia bool
|
||||||
|
|
||||||
waitLogin chan error
|
waitLogin chan error
|
||||||
block chan struct{}
|
block chan struct{}
|
||||||
}
|
}
|
||||||
@@ -45,6 +47,11 @@ func NewClient(config *config.Config) *TClient {
|
|||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *TClient) WithMedia() *TClient {
|
||||||
|
t.downloadMedia = true
|
||||||
|
return t
|
||||||
|
}
|
||||||
|
|
||||||
// func (t *TClient) Run(ctx context.Context) {
|
// func (t *TClient) Run(ctx context.Context) {
|
||||||
// err := t.Client.Run(ctx, func(ctx context.Context) error {
|
// err := t.Client.Run(ctx, func(ctx context.Context) error {
|
||||||
// flow := auth.NewFlow(Terminal{PhoneNumber: t.Config.Phone}, auth.SendCodeOptions{})
|
// flow := auth.NewFlow(Terminal{PhoneNumber: t.Config.Phone}, auth.SendCodeOptions{})
|
||||||
@@ -135,6 +142,10 @@ func (t *TClient) Channel(ctx context.Context, channel *tg.Channel, offset int)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !t.downloadMedia {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if mediaClass, ok := msg.GetMedia(); ok {
|
if mediaClass, ok := msg.GetMedia(); ok {
|
||||||
if photoClass, ok := mediaClass.(*tg.MessageMediaPhoto).GetPhoto(); ok {
|
if photoClass, ok := mediaClass.(*tg.MessageMediaPhoto).GetPhoto(); ok {
|
||||||
photo := photoClass.(*tg.Photo)
|
photo := photoClass.(*tg.Photo)
|
||||||
@@ -161,10 +172,6 @@ func (t *TClient) Channel(ctx context.Context, channel *tg.Channel, offset int)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("")
|
|
||||||
fmt.Println("------------------------------------------------------------------------------------------------------")
|
|
||||||
fmt.Println("")
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
package internal
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/gotd/td/tg"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (t *TClient) PrintChannels(ctx context.Context) error {
|
|
||||||
channels, err := t.Client.API().ChannelsGetChannels(context.Background(), []tg.InputChannelClass{
|
|
||||||
&tg.InputChannelEmpty{},
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return errors.Wrap(err, "failed to get channels")
|
|
||||||
}
|
|
||||||
_ = channels
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -9,8 +9,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
channelID int64
|
channelID int64
|
||||||
channelAlias string
|
offsetID int
|
||||||
|
channelAlias string
|
||||||
|
downloadMedia bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func ExportCmd() *cobra.Command {
|
func ExportCmd() *cobra.Command {
|
||||||
@@ -35,12 +37,19 @@ func ExportCmd() *cobra.Command {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return client.Channel(ctx, channel, 0)
|
|
||||||
|
if downloadMedia {
|
||||||
|
client.WithMedia()
|
||||||
|
}
|
||||||
|
|
||||||
|
return client.Channel(ctx, channel, offsetID)
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().Int64Var(&channelID, "channel", 0, "channel id")
|
cmd.Flags().Int64Var(&channelID, "channel", 0, "channel id")
|
||||||
|
cmd.Flags().IntVar(&offsetID, "offset", 0, "offset id")
|
||||||
cmd.Flags().StringVar(&channelAlias, "alias", "", "channel alias")
|
cmd.Flags().StringVar(&channelAlias, "alias", "", "channel alias")
|
||||||
|
cmd.Flags().BoolVar(&downloadMedia, "media", false, "download media")
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user