From f44d515f71f957178c4b408d94f644a267d316d6 Mon Sep 17 00:00:00 2001 From: Daniel Leining Date: Wed, 29 Jan 2020 22:58:02 -0500 Subject: [PATCH] add getStickerSet call --- bot.go | 19 +++++++++++++++++++ configs.go | 15 +++++++++++++++ types.go | 8 ++++++++ 3 files changed, 42 insertions(+) diff --git a/bot.go b/bot.go index a996790..e91e4e0 100644 --- a/bot.go +++ b/bot.go @@ -974,3 +974,22 @@ func (bot *BotAPI) DeleteChatPhoto(config DeleteChatPhotoConfig) (APIResponse, e return bot.MakeRequest(config.method(), v) } + +// GetStickerSet get a sticker set. +func (bot *BotAPI) GetStickerSet(config GetStickerSetConfig) (StickerSet, error) { + v, err := config.values() + if err != nil { + return StickerSet{}, err + } + bot.debugLog(config.method(), v, nil) + res, err := bot.MakeRequest(config.method(), v) + if err != nil { + return StickerSet{}, err + } + stickerSet := StickerSet{} + err = json.Unmarshal(res.Result, &stickerSet) + if err != nil { + return StickerSet{}, err + } + return stickerSet, nil +} diff --git a/configs.go b/configs.go index 181d4e4..a7052dd 100644 --- a/configs.go +++ b/configs.go @@ -1262,3 +1262,18 @@ func (config DeleteChatPhotoConfig) values() (url.Values, error) { return v, nil } + +// GetStickerSetConfig contains information for get sticker set. +type GetStickerSetConfig struct { + Name string +} + +func (config GetStickerSetConfig) method() string { + return "getStickerSet" +} + +func (config GetStickerSetConfig) values() (url.Values, error) { + v := url.Values{} + v.Add("name", config.Name) + return v, nil +} diff --git a/types.go b/types.go index 70d66fa..810dd9b 100644 --- a/types.go +++ b/types.go @@ -348,6 +348,14 @@ type Sticker struct { IsAnimated bool `json:"is_animated"` // optional } +type StickerSet struct { + Name string `json:"name"` + Title string `json:"title"` + IsAnimated bool `json:"is_animated"` + ContainsMasks bool `json:"contains_masks"` + Stickers []Sticker `json:"stickers"` +} + // ChatAnimation contains information about an animation. type ChatAnimation struct { FileID string `json:"file_id"`