From c7df02581e66bf8bc91983e4f2bc6cf2276c2d85 Mon Sep 17 00:00:00 2001 From: Rogee Date: Thu, 12 Sep 2024 10:16:53 +0800 Subject: [PATCH] fix: add channel --- .vscode/launch.json | 4 ++-- internal/client_channel.go | 10 ++++++---- internal/cmd_channel_add.go | 4 +--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index f3182e8..c08583f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,8 +12,8 @@ "program": "${workspaceFolder}/main.go", "args": [ "channel", - "export", - "--pk=3" + "add", + "--alias=chiguamaopao" // https://t.me/yunpanshare/26640 // "--alias", "yunpanshare", // https://t.me/Aliyun_4K_Movies/26640 diff --git a/internal/client_channel.go b/internal/client_channel.go index c8b98c1..1043b02 100644 --- a/internal/client_channel.go +++ b/internal/client_channel.go @@ -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) diff --git a/internal/cmd_channel_add.go b/internal/cmd_channel_add.go index da127df..e24ac11 100644 --- a/internal/cmd_channel_add.go +++ b/internal/cmd_channel_add.go @@ -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")