Add support for Polls and other API 4.2 updates.

This commit is contained in:
Syfaro 2019-04-14 14:46:45 -05:00
parent fa40708257
commit db88019230
5 changed files with 127 additions and 1 deletions

20
bot.go
View file

@ -548,7 +548,7 @@ func (bot *BotAPI) GetStickerSet(config GetStickerSetConfig) (StickerSet, error)
resp, err := bot.MakeRequest(config.method(), params)
if err != nil {
return StickerSet{}, nil
return StickerSet{}, err
}
var stickers StickerSet
@ -556,3 +556,21 @@ func (bot *BotAPI) GetStickerSet(config GetStickerSetConfig) (StickerSet, error)
return stickers, err
}
// StopPoll stops a poll and returns the result.
func (bot *BotAPI) StopPoll(config StopPollConfig) (Poll, error) {
params, err := config.params()
if err != nil {
return Poll{}, err
}
resp, err := bot.MakeRequest(config.method(), params)
if err != nil {
return Poll{}, err
}
var poll Poll
err = json.Unmarshal(resp.Result, &poll)
return poll, err
}