2017-12-14 07:33:44 +00:00
|
|
|
|
package telegram
|
|
|
|
|
|
2018-02-14 21:54:23 +00:00
|
|
|
|
import json "github.com/pquerna/ffjson/ffjson"
|
2017-12-14 07:33:44 +00:00
|
|
|
|
|
2018-04-19 13:02:15 +00:00
|
|
|
|
// SendMediaGroupParameters represents data for SendMediaGroup method.
|
2018-02-14 21:54:23 +00:00
|
|
|
|
type SendMediaGroupParameters struct {
|
|
|
|
|
// Unique identifier for the target chat.
|
|
|
|
|
ChatID int64 `json:"chat_id"`
|
2017-12-14 07:33:44 +00:00
|
|
|
|
|
2018-02-14 21:54:23 +00:00
|
|
|
|
// A JSON-serialized array describing photos and videos to be sent, must
|
|
|
|
|
// include 2–10 items
|
|
|
|
|
Media []interface{} `json:"media"`
|
|
|
|
|
|
|
|
|
|
// Sends the messages silently. Users will receive a notification with no
|
|
|
|
|
// sound.
|
|
|
|
|
DisableNotification bool `json:"disable_notification,omitempty"`
|
|
|
|
|
|
|
|
|
|
// If the messages are a reply, ID of the original message
|
|
|
|
|
ReplyToMessageID int `json:"reply_to_message_id,omitempty"`
|
|
|
|
|
}
|
2017-12-14 07:33:44 +00:00
|
|
|
|
|
2018-04-19 13:02:15 +00:00
|
|
|
|
// NewMediaGroup creates SendMediaGroupParameters only with required parameters.
|
2018-02-14 21:54:23 +00:00
|
|
|
|
func NewMediaGroup(chatID int64, media ...interface{}) *SendMediaGroupParameters {
|
|
|
|
|
return &SendMediaGroupParameters{
|
|
|
|
|
ChatID: chatID,
|
|
|
|
|
Media: media,
|
2017-12-14 07:33:44 +00:00
|
|
|
|
}
|
2018-02-14 21:54:23 +00:00
|
|
|
|
}
|
2017-12-14 07:33:44 +00:00
|
|
|
|
|
2018-02-14 21:54:23 +00:00
|
|
|
|
// SendMediaGroup send a group of photos or videos as an album. On success, an array of the sent
|
|
|
|
|
// Messages is returned.
|
|
|
|
|
func (bot *Bot) SendMediaGroup(params *SendMediaGroupParameters) ([]Message, error) {
|
2018-02-15 12:32:47 +00:00
|
|
|
|
dst, err := json.Marshal(params)
|
2017-12-14 07:33:44 +00:00
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-12 11:58:05 +00:00
|
|
|
|
resp, err := bot.request(dst, MethodSendMediaGroup)
|
2017-12-14 07:33:44 +00:00
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-14 21:54:23 +00:00
|
|
|
|
var data []Message
|
2017-12-14 07:33:44 +00:00
|
|
|
|
err = json.Unmarshal(*resp.Result, &data)
|
|
|
|
|
return data, err
|
|
|
|
|
}
|