all repos — telegram-bot-api @ cf3ea3f80ddfd0879a35025ff146a2e1d5ea1046

Golang bindings for the Telegram Bot API

Merge pull request #304 from blasphemy/getstickerset2

add getStickerSet call
Kirill Zhuharev zhuharev@users.noreply.github.com
Thu, 19 Mar 2020 07:14:48 +0300
commit

cf3ea3f80ddfd0879a35025ff146a2e1d5ea1046

parent

d1fd9b736cf5afef5df5553f1c378a986d2f5ee9

3 files changed, 42 insertions(+), 0 deletions(-)

jump to
M bot.gobot.go

@@ -982,3 +982,22 @@ bot.debugLog(config.method(), v, nil)

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 +}
M configs.goconfigs.go

@@ -1262,3 +1262,18 @@ v.Add("chat_id", strconv.FormatInt(config.ChatID, 10))

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 +}
M types.gotypes.go

@@ -348,6 +348,14 @@ SetName string `json:"set_name"` // optional

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"`