all repos — telegram-bot-api @ fa4070825746d9c5c9d73bb37774a6ccc60fb80d

Golang bindings for the Telegram Bot API

Add SendMediaGroup method.
Syfaro syfaro@huefox.com
Tue, 25 Dec 2018 15:44:01 -0600
commit

fa4070825746d9c5c9d73bb37774a6ccc60fb80d

parent

5781187bc20cbb9910ba867eafe318479be119b6

2 files changed, 25 insertions(+), 1 deletions(-)

jump to
M bot.gobot.go

@@ -307,6 +307,21 @@

return message, err } +// SendMediaGroup sends a media group and returns the resulting messages. +func (bot *BotAPI) SendMediaGroup(config MediaGroupConfig) ([]Message, error) { + params, _ := config.params() + + resp, err := bot.MakeRequest(config.method(), params) + if err != nil { + return nil, err + } + + var messages []Message + err = json.Unmarshal(resp.Result, &messages) + + return messages, err +} + // GetUserProfilePhotos gets a user's profile photos. // // It requires UserID.
M bot_test.gobot_test.go

@@ -517,9 +517,18 @@ NewInputMediaPhoto("https://i.imgur.com/unQLJIb.jpg"),

NewInputMediaPhoto("https://i.imgur.com/J5qweNZ.jpg"), NewInputMediaVideo("https://i.imgur.com/F6RmI24.mp4"), }) - _, err := bot.Request(cfg) + + messages, err := bot.SendMediaGroup(cfg) if err != nil { t.Error(err) + } + + if messages == nil { + t.Error() + } + + if len(messages) != 3 { + t.Error() } }