Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MessagesForwardMessages Error #1389

Open
TsungPao opened this issue May 31, 2024 · 0 comments
Open

MessagesForwardMessages Error #1389

TsungPao opened this issue May 31, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@TsungPao
Copy link

TsungPao commented May 31, 2024

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 TsungPao added the bug Something isn't working label May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant