diff --git a/internal/client_channel.go b/internal/client_channel.go index 8761d45..92e74b4 100644 --- a/internal/client_channel.go +++ b/internal/client_channel.go @@ -19,7 +19,7 @@ import ( func (t *TClient) Channel(ctx context.Context, channel *tg.Channel, cfg *DBChannel, onlyAddChannel bool) error { inputPeer := &tg.InputPeerChannel{ChannelID: channel.ID, AccessHash: channel.AccessHash} - limit := 20 + limit := 50 request := &tg.MessagesGetHistoryRequest{ Peer: inputPeer, Limit: limit, diff --git a/internal/cmd_channel_export.go b/internal/cmd_channel_export.go index ee05a70..a0ac319 100644 --- a/internal/cmd_channel_export.go +++ b/internal/cmd_channel_export.go @@ -37,18 +37,13 @@ func channelExportCmd(ctx context.Context) error { if pkID == 0 { return errors.New("db channel id required") } - - channel, err := client.ChannelInfoByID(ctx, pkID) + cfg, err := NewDBChannelFromDB(pkID) if err != nil { return err } - if channel.GetID() == 0 { - return errors.New("channel not found") - } - - cfg := NewDBChannel(channel.GetID(), channel.Username, channel.Title) - if err := cfg.GetOrCreate(ctx); err != nil { + channel, err := client.ChannelInfoByID(ctx, cfg.UUID) + if err != nil { return err } @@ -57,13 +52,16 @@ func channelExportCmd(ctx context.Context) error { if err := client.Channel(ctx, channel, cfg, false); err != nil { logger.Error("failed to export channel", zap.Error(err), zap.Int64("uuid", channel.GetID())) continueRetryTimes++ - sleepSeconds := math.Pow(2, float64(continueRetryTimes)) + sleepSeconds := math.Pow(2, float64(1+continueRetryTimes)) if sleepSeconds > 128 { return err } logger.Info("retry after", zap.Int("seconds", int(sleepSeconds))) time.Sleep(time.Second * time.Duration(sleepSeconds)) + continue } + + continueRetryTimes = 0 } }