feat: login
This commit is contained in:
@@ -19,31 +19,7 @@ func ExportCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "export",
|
||||
Short: "export channels",
|
||||
RunE: wrapE(func(ctx context.Context) error {
|
||||
if channelID == 0 && channelAlias == "" {
|
||||
return errors.New("channel id or alias is required")
|
||||
}
|
||||
|
||||
var channel *tg.Channel
|
||||
var err error
|
||||
if channelAlias != "" {
|
||||
channel, err = client.ChannelInfoByAlias(ctx, channelAlias)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
channel, err = client.ChannelInfoByID(ctx, channelID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if downloadMedia {
|
||||
client.WithMedia()
|
||||
}
|
||||
|
||||
return client.Channel(ctx, channel, offsetID)
|
||||
}),
|
||||
RunE: wrapE(exportCmd),
|
||||
}
|
||||
|
||||
cmd.Flags().Int64Var(&channelID, "channel", 0, "channel id")
|
||||
@@ -53,3 +29,35 @@ func ExportCmd() *cobra.Command {
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func exportCmd(ctx context.Context) error {
|
||||
if channelID == 0 && channelAlias == "" {
|
||||
return errors.New("channel id or alias is required")
|
||||
}
|
||||
|
||||
var channel *tg.Channel
|
||||
var err error
|
||||
if channelAlias != "" {
|
||||
channel, err = client.ChannelInfoByAlias(ctx, channelAlias)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
channel, err = client.ChannelInfoByID(ctx, channelID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if downloadMedia {
|
||||
client.WithMedia()
|
||||
}
|
||||
|
||||
cfg, err := client.SaveChannelConfig(ctx, channel.ID, offsetID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
return client.Channel(ctx, channel, cfg.Offset)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user