Skip to content

MessagesForwardMessages Error #1389

Closed
Closed

Description

@TsungPao

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

Activity

  1. TrixiS commented on Jan 26, 2025

    @TrixiS

    +1

  2. kyleit commented on Apr 8, 2025

    @kyleit

    +1

  3. kondratev-nikita commented on Nov 17, 2025

    @kondratev-nikita

    +1

  4. locked and limited conversation to collaborators on Jun 15, 2026
  5. converted this issue into a discussion #1789 on Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions