2017-10-06 09:49:25 +00:00
|
|
|
package telegram
|
|
|
|
|
2018-04-19 13:02:15 +00:00
|
|
|
// ForwardMessageParameters represents data for ForwardMessage method.
|
2017-10-06 09:49:25 +00:00
|
|
|
type ForwardMessageParameters struct {
|
2018-10-12 11:44:27 +00:00
|
|
|
// Unique identifier for the target chat or username of the target
|
|
|
|
// channel (in the format @channelusername)
|
2017-10-06 09:49:25 +00:00
|
|
|
ChatID int64 `json:"chat_id"`
|
|
|
|
|
2018-10-12 11:44:27 +00:00
|
|
|
// Unique identifier for the chat where the original message was sent
|
|
|
|
// (or channel username in the format @channelusername)
|
2017-10-06 09:49:25 +00:00
|
|
|
FromChatID int64 `json:"from_chat_id"`
|
|
|
|
|
2018-10-12 11:44:27 +00:00
|
|
|
// Sends the message silently. Users will receive a notification with no
|
|
|
|
// sound.
|
2017-10-06 09:49:25 +00:00
|
|
|
DisableNotification bool `json:"disable_notification,omitempty"`
|
|
|
|
|
|
|
|
// Message identifier in the chat specified in from_chat_id
|
|
|
|
MessageID int `json:"message_id"`
|
|
|
|
}
|
|
|
|
|
2018-04-19 13:02:15 +00:00
|
|
|
// NewForwardMessage creates ForwardMessageParameters only with reqired parameters.
|
2017-10-17 11:08:09 +00:00
|
|
|
func NewForwardMessage(from, to int64, messageID int) *ForwardMessageParameters {
|
|
|
|
return &ForwardMessageParameters{
|
|
|
|
FromChatID: from,
|
|
|
|
ChatID: to,
|
|
|
|
MessageID: messageID,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-06 09:49:25 +00:00
|
|
|
// ForwardMessage forward messages of any kind. On success, the sent Message is returned.
|
2019-07-26 10:09:49 +00:00
|
|
|
func (bot *Bot) ForwardMessage(params *ForwardMessageParameters) (*Message, error) {
|
2019-07-24 09:34:55 +00:00
|
|
|
dst, err := parser.Marshal(params)
|
2017-10-06 09:49:25 +00:00
|
|
|
if err != nil {
|
2019-07-26 10:09:49 +00:00
|
|
|
return nil, err
|
2017-10-06 09:49:25 +00:00
|
|
|
}
|
|
|
|
|
2018-04-12 11:58:05 +00:00
|
|
|
resp, err := bot.request(dst, MethodForwardMessage)
|
2017-10-06 09:49:25 +00:00
|
|
|
if err != nil {
|
2019-07-26 10:09:49 +00:00
|
|
|
return nil, err
|
2017-10-06 09:49:25 +00:00
|
|
|
}
|
|
|
|
|
2019-07-26 10:09:49 +00:00
|
|
|
var msg Message
|
|
|
|
err = parser.Unmarshal(resp.Result, &msg)
|
|
|
|
return &msg, err
|
2017-10-06 09:49:25 +00:00
|
|
|
}
|