1
0
telegram/utils_sticker.go
Maxim Lebedev 4131980f6a
Added IsWebP method for sticker
Also fixed Set method
2018-09-05 16:46:58 +05:00

38 lines
829 B
Go

package telegram
// InSet checks that the current sticker in the stickers set.
//
// For uploaded WebP files this return false.
func (s *Sticker) InSet() bool {
return s != nil && s.SetName != ""
}
// IsWebP check that the current sticker is a WebP file uploaded by user.
func (s *Sticker) IsWebP() bool {
return s != nil && s.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 (s *Sticker) Set(bot *Bot) *StickerSet {
if s.IsWebP() || bot == nil {
return nil
}
set, err := bot.GetStickerSet(s.SetName)
if err != nil {
return nil
}
return set
}
func (s *Sticker) HasThumb() bool {
return s != nil && s.Thumb != nil
}
func (s *Sticker) IsMask() bool {
return s != nil && s.MaskPosition != nil
}