fix: add channel

This commit is contained in:
Rogee
2024-09-12 10:16:53 +08:00
parent 791198a0be
commit c7df02581e
3 changed files with 9 additions and 9 deletions

View File

@@ -20,14 +20,16 @@ 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 := 50
request := &tg.MessagesGetHistoryRequest{
Peer: inputPeer,
Limit: limit,
Limit: 10,
}
request.OffsetID = cfg.MinID + limit
request.MinID = cfg.MinID
if !onlyAddChannel {
request.Limit = 50
request.OffsetID = cfg.MinID + request.Limit
request.MinID = cfg.MinID
}
logger.Info("get channel message history", zap.Int("min_id", request.MinID), zap.Int("offset", request.OffsetID), zap.Int("limit", request.Limit))
history, err := t.Client.API().MessagesGetHistory(ctx, request)

View File

@@ -27,9 +27,7 @@ func ChannelAddCmd() *cobra.Command {
defer log.Println("init client done")
return InitClient(config.C)
},
RunE: func(cmd *cobra.Command, args []string) error {
return channelAddCmd(context.Background())
},
RunE: wrapE(channelAddCmd),
}
cmd.Flags().Int64Var(&channelID, "channel", 0, "channel id")
cmd.Flags().StringVar(&channelAlias, "alias", "", "channel alias")