fix: issues

This commit is contained in:
Rogee
2024-09-05 15:51:52 +08:00
parent 568c28d3ab
commit fac2ecdf64
2 changed files with 8 additions and 10 deletions

View File

@@ -19,7 +19,7 @@ import (
func (t *TClient) Channel(ctx context.Context, channel *tg.Channel, cfg *DBChannel, onlyAddChannel bool) error { func (t *TClient) Channel(ctx context.Context, channel *tg.Channel, cfg *DBChannel, onlyAddChannel bool) error {
inputPeer := &tg.InputPeerChannel{ChannelID: channel.ID, AccessHash: channel.AccessHash} inputPeer := &tg.InputPeerChannel{ChannelID: channel.ID, AccessHash: channel.AccessHash}
limit := 20 limit := 50
request := &tg.MessagesGetHistoryRequest{ request := &tg.MessagesGetHistoryRequest{
Peer: inputPeer, Peer: inputPeer,
Limit: limit, Limit: limit,

View File

@@ -37,18 +37,13 @@ func channelExportCmd(ctx context.Context) error {
if pkID == 0 { if pkID == 0 {
return errors.New("db channel id required") return errors.New("db channel id required")
} }
cfg, err := NewDBChannelFromDB(pkID)
channel, err := client.ChannelInfoByID(ctx, pkID)
if err != nil { if err != nil {
return err return err
} }
if channel.GetID() == 0 { channel, err := client.ChannelInfoByID(ctx, cfg.UUID)
return errors.New("channel not found") if err != nil {
}
cfg := NewDBChannel(channel.GetID(), channel.Username, channel.Title)
if err := cfg.GetOrCreate(ctx); err != nil {
return err return err
} }
@@ -57,13 +52,16 @@ func channelExportCmd(ctx context.Context) error {
if err := client.Channel(ctx, channel, cfg, false); err != nil { if err := client.Channel(ctx, channel, cfg, false); err != nil {
logger.Error("failed to export channel", zap.Error(err), zap.Int64("uuid", channel.GetID())) logger.Error("failed to export channel", zap.Error(err), zap.Int64("uuid", channel.GetID()))
continueRetryTimes++ continueRetryTimes++
sleepSeconds := math.Pow(2, float64(continueRetryTimes)) sleepSeconds := math.Pow(2, float64(1+continueRetryTimes))
if sleepSeconds > 128 { if sleepSeconds > 128 {
return err return err
} }
logger.Info("retry after", zap.Int("seconds", int(sleepSeconds))) logger.Info("retry after", zap.Int("seconds", int(sleepSeconds)))
time.Sleep(time.Second * time.Duration(sleepSeconds)) time.Sleep(time.Second * time.Duration(sleepSeconds))
continue
} }
continueRetryTimes = 0
} }
} }