Add SendMediaGroup method.
parent
5781187bc2
commit
fa40708257
15
bot.go
15
bot.go
|
@ -307,6 +307,21 @@ func (bot *BotAPI) Send(c Chattable) (Message, error) {
|
|||
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.
|
||||
|
|
11
bot_test.go
11
bot_test.go
|
@ -517,10 +517,19 @@ func TestSendWithMediaGroup(t *testing.T) {
|
|||
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()
|
||||
}
|
||||
}
|
||||
|
||||
func ExampleNewBotAPI() {
|
||||
|
|
Loading…
Reference in New Issue