1
0
Fork 0

Added Stickers utils

This commit is contained in:
Maxim Lebedev 2018-04-19 20:15:47 +05:00
parent 86a3f2148e
commit 2f199bb9a4
No known key found for this signature in database
GPG Key ID: F8978F46FF0FFA4F
1 changed files with 24 additions and 0 deletions

24
utils_sticker.go Normal file
View File

@ -0,0 +1,24 @@
package telegram
// InSet checks that the current sticker in the stickers set.
//
// For uploaded WebP files this return false.
func (sticker *Sticker) InSet() bool {
return sticker != nil && sticker.SetName != ""
}
// Set use bot for getting parent StickerSet if SetName is present.
//
// Return nil if current sticker has been uploaded by user as WebP file.
func (sticker *Sticker) Set(bot *Bot) *StickerSet {
if !sticker.InSet() || bot == nil {
return nil
}
set, err := bot.GetStickerSet(sticker.SetName)
if err != nil {
return nil
}
return set
}