Messages

Forwarding & copying

Forwarding preserves the original author header and the link back to the source. Copying strips both. gogram supports either through the same Forward call.

Forwarding

msgs, err := client.Forward(toPeer, fromPeer, []int32{msgID})
msgs, err := client.Forward(toPeer, fromPeer, []int32{msgID})

Forward(toPeer, fromPeer, msgIDs, opts...) takes up to 100 message ids per call. Source and destination peers can be any of the forms described on Sending messages. The return value is a slice of NewMessage in the destination chat, in the order the messages landed.

ForwardOptions

msgs, err := client.Forward(toPeer, fromPeer, []int32{m1, m2, m3}, &telegram.ForwardOptions{
	Silent:      true,
	HideAuthor:  true,
	HideCaption: false,
	Background:  false,
})
msgs, err := client.Forward(toPeer, fromPeer, []int32{m1, m2, m3}, &telegram.ForwardOptions{
	Silent:      true,
	HideAuthor:  true,
	HideCaption: false,
	Background:  false,
})

Common fields:

Silent
Deliver without notification sound.
HideAuthor
Remove the "Forwarded from" header so the messages look like a fresh copy.
HideCaption
Remove media captions (text messages are unaffected).
Background
Mark the forward as a background operation (lowered notification priority).
Noforwards
Propagate the protected-content flag onto the new copy.
SendAs
Forward as a linked channel rather than as the current account.

Copying (dropping the header)

Copying is just forwarding with the header dropped. Set HideAuthor: true and the recipient sees the content without the source. Add HideCaption: true to scrub captions too, then edit a new one in:

msgs, err := client.Forward(toPeer, fromPeer, []int32{msgID}, &telegram.ForwardOptions{
	HideAuthor:  true,
	HideCaption: true,
})
if len(msgs) > 0 {
	msgs[0].Edit("brand-new caption")
}
msgs, err := client.Forward(toPeer, fromPeer, []int32{msgID}, &telegram.ForwardOptions{
	HideAuthor:  true,
	HideCaption: true,
})
if len(msgs) > 0 {
	msgs[0].Edit("brand-new caption")
}

From a message helper

Inside a handler, ForwardTo on a *NewMessage is shorter than spelling out the from/id pair:

client.On("message:*", func(m *telegram.NewMessage) error {
	_, err := m.ForwardTo(adminChat)
	return err
})
client.On("message:*", func(m *telegram.NewMessage) error {
	_, err := m.ForwardTo(adminChat)
	return err
})

When forwards are blocked

If the source chat has "Restrict saving content" on, or the original message was sent with NoForwards: true, the server returns CHAT_FORWARDS_RESTRICTEDand the call fails. There is no client-side override — this is a server-side guarantee for the source chat's admins.