td icon indicating copy to clipboard operation
td copied to clipboard

MessagesForwardMessages Error

Open TsungPao opened this issue 1 year ago • 3 comments

What version of gotd are you using?

v0.102.0

Can this issue be reproduced with the latest version?

Yes

What did you do?

I would like to ask why, when I use MessagesForwardMessages to directly forward messages, only the messages I send can be successfully forwarded. Messages sent by others always show the error 'rpcDoRequest: rpc error code 400: CHANNEL_INVALID'. I am certain that the channel can normally forward messages. Is there something wrong with the way I am using it? I've been struggling with this for quite a while.

rand.NewSource(time.Now().UnixNano())
randomID := rand.Int63() // 生成一个随机的长整数

request := &tg.MessagesForwardMessagesRequest{
	FromPeer: &tg.InputPeerChannel{ChannelID: chatID, AccessHash: chatAccessHash},
	ToPeer:   &tg.InputPeerChannel{ChannelID: targetChannelID, AccessHash: targetChannelAccessHash},
	ID:       []int{msg.GetID()},
	RandomID: []int64{randomID}, // 设置 random_id 以防止重复转发
	//DropAuthor: true,              // 不转发作者信息
}

//fmt.Printf("\nrequest: %+v\n\n", request)

// 轉發消息
_, err := api.MessagesForwardMessages(ctx, request)
if err != nil {
	fmt.Printf("轉發失敗: %s\n", err)
	return err
} else {
	fmt.Println("轉發成功")
}

What did you expect to see?

Can be forwarded successfully

What did you see instead?

'rpcDoRequest: rpc error code 400: CHANNEL_INVALID'

What Go version and environment are you using?

go v1.21

TsungPao avatar May 31 '24 03:05 TsungPao

+1

TrixiS avatar Jan 26 '25 15:01 TrixiS

+1

kyleit avatar Apr 08 '25 07:04 kyleit