fix: add channel
This commit is contained in:
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
@@ -12,8 +12,8 @@
|
|||||||
"program": "${workspaceFolder}/main.go",
|
"program": "${workspaceFolder}/main.go",
|
||||||
"args": [
|
"args": [
|
||||||
"channel",
|
"channel",
|
||||||
"export",
|
"add",
|
||||||
"--pk=3"
|
"--alias=chiguamaopao"
|
||||||
// https://t.me/yunpanshare/26640
|
// https://t.me/yunpanshare/26640
|
||||||
// "--alias", "yunpanshare",
|
// "--alias", "yunpanshare",
|
||||||
// https://t.me/Aliyun_4K_Movies/26640
|
// https://t.me/Aliyun_4K_Movies/26640
|
||||||
|
|||||||
@@ -20,14 +20,16 @@ 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 := 50
|
|
||||||
request := &tg.MessagesGetHistoryRequest{
|
request := &tg.MessagesGetHistoryRequest{
|
||||||
Peer: inputPeer,
|
Peer: inputPeer,
|
||||||
Limit: limit,
|
Limit: 10,
|
||||||
}
|
}
|
||||||
|
|
||||||
request.OffsetID = cfg.MinID + limit
|
if !onlyAddChannel {
|
||||||
request.MinID = cfg.MinID
|
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))
|
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)
|
history, err := t.Client.API().MessagesGetHistory(ctx, request)
|
||||||
|
|||||||
@@ -27,9 +27,7 @@ func ChannelAddCmd() *cobra.Command {
|
|||||||
defer log.Println("init client done")
|
defer log.Println("init client done")
|
||||||
return InitClient(config.C)
|
return InitClient(config.C)
|
||||||
},
|
},
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: wrapE(channelAddCmd),
|
||||||
return channelAddCmd(context.Background())
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
cmd.Flags().Int64Var(&channelID, "channel", 0, "channel id")
|
cmd.Flags().Int64Var(&channelID, "channel", 0, "channel id")
|
||||||
cmd.Flags().StringVar(&channelAlias, "alias", "", "channel alias")
|
cmd.Flags().StringVar(&channelAlias, "alias", "", "channel alias")
|
||||||
|
|||||||
Reference in New Issue
Block a user