package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type StickerSet struct {
Flags bin .Fields
Archived bool
Official bool
Masks bool
Animated bool
Videos bool
Emojis bool
TextColor bool
ChannelEmojiStatus bool
InstalledDate int
ID int64
AccessHash int64
Title string
ShortName string
Thumbs []PhotoSizeClass
ThumbDCID int
ThumbVersion int
ThumbDocumentID int64
Count int
Hash int
}
const StickerSetTypeID = 0x2dd14edc
var (
_ bin .Encoder = &StickerSet {}
_ bin .Decoder = &StickerSet {}
_ bin .BareEncoder = &StickerSet {}
_ bin .BareDecoder = &StickerSet {}
)
func (s *StickerSet ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Archived == false ) {
return false
}
if !(s .Official == false ) {
return false
}
if !(s .Masks == false ) {
return false
}
if !(s .Animated == false ) {
return false
}
if !(s .Videos == false ) {
return false
}
if !(s .Emojis == false ) {
return false
}
if !(s .TextColor == false ) {
return false
}
if !(s .ChannelEmojiStatus == false ) {
return false
}
if !(s .InstalledDate == 0 ) {
return false
}
if !(s .ID == 0 ) {
return false
}
if !(s .AccessHash == 0 ) {
return false
}
if !(s .Title == "" ) {
return false
}
if !(s .ShortName == "" ) {
return false
}
if !(s .Thumbs == nil ) {
return false
}
if !(s .ThumbDCID == 0 ) {
return false
}
if !(s .ThumbVersion == 0 ) {
return false
}
if !(s .ThumbDocumentID == 0 ) {
return false
}
if !(s .Count == 0 ) {
return false
}
if !(s .Hash == 0 ) {
return false
}
return true
}
func (s *StickerSet ) String () string {
if s == nil {
return "StickerSet(nil)"
}
type Alias StickerSet
return fmt .Sprintf ("StickerSet%+v" , Alias (*s ))
}
func (s *StickerSet ) FillFrom (from interface {
GetArchived () (value bool )
GetOfficial () (value bool )
GetMasks () (value bool )
GetAnimated () (value bool )
GetVideos () (value bool )
GetEmojis () (value bool )
GetTextColor () (value bool )
GetChannelEmojiStatus () (value bool )
GetInstalledDate () (value int , ok bool )
GetID () (value int64 )
GetAccessHash () (value int64 )
GetTitle () (value string )
GetShortName () (value string )
GetThumbs () (value []PhotoSizeClass , ok bool )
GetThumbDCID () (value int , ok bool )
GetThumbVersion () (value int , ok bool )
GetThumbDocumentID () (value int64 , ok bool )
GetCount () (value int )
GetHash () (value int )
}) {
s .Archived = from .GetArchived ()
s .Official = from .GetOfficial ()
s .Masks = from .GetMasks ()
s .Animated = from .GetAnimated ()
s .Videos = from .GetVideos ()
s .Emojis = from .GetEmojis ()
s .TextColor = from .GetTextColor ()
s .ChannelEmojiStatus = from .GetChannelEmojiStatus ()
if val , ok := from .GetInstalledDate (); ok {
s .InstalledDate = val
}
s .ID = from .GetID ()
s .AccessHash = from .GetAccessHash ()
s .Title = from .GetTitle ()
s .ShortName = from .GetShortName ()
if val , ok := from .GetThumbs (); ok {
s .Thumbs = val
}
if val , ok := from .GetThumbDCID (); ok {
s .ThumbDCID = val
}
if val , ok := from .GetThumbVersion (); ok {
s .ThumbVersion = val
}
if val , ok := from .GetThumbDocumentID (); ok {
s .ThumbDocumentID = val
}
s .Count = from .GetCount ()
s .Hash = from .GetHash ()
}
func (*StickerSet ) TypeID () uint32 {
return StickerSetTypeID
}
func (*StickerSet ) TypeName () string {
return "stickerSet"
}
func (s *StickerSet ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "stickerSet" ,
ID : StickerSetTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Archived" ,
SchemaName : "archived" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "Official" ,
SchemaName : "official" ,
Null : !s .Flags .Has (2 ),
},
{
Name : "Masks" ,
SchemaName : "masks" ,
Null : !s .Flags .Has (3 ),
},
{
Name : "Animated" ,
SchemaName : "animated" ,
Null : !s .Flags .Has (5 ),
},
{
Name : "Videos" ,
SchemaName : "videos" ,
Null : !s .Flags .Has (6 ),
},
{
Name : "Emojis" ,
SchemaName : "emojis" ,
Null : !s .Flags .Has (7 ),
},
{
Name : "TextColor" ,
SchemaName : "text_color" ,
Null : !s .Flags .Has (9 ),
},
{
Name : "ChannelEmojiStatus" ,
SchemaName : "channel_emoji_status" ,
Null : !s .Flags .Has (10 ),
},
{
Name : "InstalledDate" ,
SchemaName : "installed_date" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "AccessHash" ,
SchemaName : "access_hash" ,
},
{
Name : "Title" ,
SchemaName : "title" ,
},
{
Name : "ShortName" ,
SchemaName : "short_name" ,
},
{
Name : "Thumbs" ,
SchemaName : "thumbs" ,
Null : !s .Flags .Has (4 ),
},
{
Name : "ThumbDCID" ,
SchemaName : "thumb_dc_id" ,
Null : !s .Flags .Has (4 ),
},
{
Name : "ThumbVersion" ,
SchemaName : "thumb_version" ,
Null : !s .Flags .Has (4 ),
},
{
Name : "ThumbDocumentID" ,
SchemaName : "thumb_document_id" ,
Null : !s .Flags .Has (8 ),
},
{
Name : "Count" ,
SchemaName : "count" ,
},
{
Name : "Hash" ,
SchemaName : "hash" ,
},
}
return typ
}
func (s *StickerSet ) SetFlags () {
if !(s .Archived == false ) {
s .Flags .Set (1 )
}
if !(s .Official == false ) {
s .Flags .Set (2 )
}
if !(s .Masks == false ) {
s .Flags .Set (3 )
}
if !(s .Animated == false ) {
s .Flags .Set (5 )
}
if !(s .Videos == false ) {
s .Flags .Set (6 )
}
if !(s .Emojis == false ) {
s .Flags .Set (7 )
}
if !(s .TextColor == false ) {
s .Flags .Set (9 )
}
if !(s .ChannelEmojiStatus == false ) {
s .Flags .Set (10 )
}
if !(s .InstalledDate == 0 ) {
s .Flags .Set (0 )
}
if !(s .Thumbs == nil ) {
s .Flags .Set (4 )
}
if !(s .ThumbDCID == 0 ) {
s .Flags .Set (4 )
}
if !(s .ThumbVersion == 0 ) {
s .Flags .Set (4 )
}
if !(s .ThumbDocumentID == 0 ) {
s .Flags .Set (8 )
}
}
func (s *StickerSet ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode stickerSet#2dd14edc as nil" )
}
b .PutID (StickerSetTypeID )
return s .EncodeBare (b )
}
func (s *StickerSet ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode stickerSet#2dd14edc as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stickerSet#2dd14edc: field flags: %w" , err )
}
if s .Flags .Has (0 ) {
b .PutInt (s .InstalledDate )
}
b .PutLong (s .ID )
b .PutLong (s .AccessHash )
b .PutString (s .Title )
b .PutString (s .ShortName )
if s .Flags .Has (4 ) {
b .PutVectorHeader (len (s .Thumbs ))
for idx , v := range s .Thumbs {
if v == nil {
return fmt .Errorf ("unable to encode stickerSet#2dd14edc: field thumbs element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stickerSet#2dd14edc: field thumbs element with index %d: %w" , idx , err )
}
}
}
if s .Flags .Has (4 ) {
b .PutInt (s .ThumbDCID )
}
if s .Flags .Has (4 ) {
b .PutInt (s .ThumbVersion )
}
if s .Flags .Has (8 ) {
b .PutLong (s .ThumbDocumentID )
}
b .PutInt (s .Count )
b .PutInt (s .Hash )
return nil
}
func (s *StickerSet ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode stickerSet#2dd14edc to nil" )
}
if err := b .ConsumeID (StickerSetTypeID ); err != nil {
return fmt .Errorf ("unable to decode stickerSet#2dd14edc: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StickerSet ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode stickerSet#2dd14edc to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode stickerSet#2dd14edc: field flags: %w" , err )
}
}
s .Archived = s .Flags .Has (1 )
s .Official = s .Flags .Has (2 )
s .Masks = s .Flags .Has (3 )
s .Animated = s .Flags .Has (5 )
s .Videos = s .Flags .Has (6 )
s .Emojis = s .Flags .Has (7 )
s .TextColor = s .Flags .Has (9 )
s .ChannelEmojiStatus = s .Flags .Has (10 )
if s .Flags .Has (0 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode stickerSet#2dd14edc: field installed_date: %w" , err )
}
s .InstalledDate = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode stickerSet#2dd14edc: field id: %w" , err )
}
s .ID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode stickerSet#2dd14edc: field access_hash: %w" , err )
}
s .AccessHash = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode stickerSet#2dd14edc: field title: %w" , err )
}
s .Title = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode stickerSet#2dd14edc: field short_name: %w" , err )
}
s .ShortName = value
}
if s .Flags .Has (4 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stickerSet#2dd14edc: field thumbs: %w" , err )
}
if headerLen > 0 {
s .Thumbs = make ([]PhotoSizeClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodePhotoSize (b )
if err != nil {
return fmt .Errorf ("unable to decode stickerSet#2dd14edc: field thumbs: %w" , err )
}
s .Thumbs = append (s .Thumbs , value )
}
}
if s .Flags .Has (4 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode stickerSet#2dd14edc: field thumb_dc_id: %w" , err )
}
s .ThumbDCID = value
}
if s .Flags .Has (4 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode stickerSet#2dd14edc: field thumb_version: %w" , err )
}
s .ThumbVersion = value
}
if s .Flags .Has (8 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode stickerSet#2dd14edc: field thumb_document_id: %w" , err )
}
s .ThumbDocumentID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode stickerSet#2dd14edc: field count: %w" , err )
}
s .Count = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode stickerSet#2dd14edc: field hash: %w" , err )
}
s .Hash = value
}
return nil
}
func (s *StickerSet ) SetArchived (value bool ) {
if value {
s .Flags .Set (1 )
s .Archived = true
} else {
s .Flags .Unset (1 )
s .Archived = false
}
}
func (s *StickerSet ) GetArchived () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (1 )
}
func (s *StickerSet ) SetOfficial (value bool ) {
if value {
s .Flags .Set (2 )
s .Official = true
} else {
s .Flags .Unset (2 )
s .Official = false
}
}
func (s *StickerSet ) GetOfficial () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (2 )
}
func (s *StickerSet ) SetMasks (value bool ) {
if value {
s .Flags .Set (3 )
s .Masks = true
} else {
s .Flags .Unset (3 )
s .Masks = false
}
}
func (s *StickerSet ) GetMasks () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (3 )
}
func (s *StickerSet ) SetAnimated (value bool ) {
if value {
s .Flags .Set (5 )
s .Animated = true
} else {
s .Flags .Unset (5 )
s .Animated = false
}
}
func (s *StickerSet ) GetAnimated () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (5 )
}
func (s *StickerSet ) SetVideos (value bool ) {
if value {
s .Flags .Set (6 )
s .Videos = true
} else {
s .Flags .Unset (6 )
s .Videos = false
}
}
func (s *StickerSet ) GetVideos () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (6 )
}
func (s *StickerSet ) SetEmojis (value bool ) {
if value {
s .Flags .Set (7 )
s .Emojis = true
} else {
s .Flags .Unset (7 )
s .Emojis = false
}
}
func (s *StickerSet ) GetEmojis () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (7 )
}
func (s *StickerSet ) SetTextColor (value bool ) {
if value {
s .Flags .Set (9 )
s .TextColor = true
} else {
s .Flags .Unset (9 )
s .TextColor = false
}
}
func (s *StickerSet ) GetTextColor () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (9 )
}
func (s *StickerSet ) SetChannelEmojiStatus (value bool ) {
if value {
s .Flags .Set (10 )
s .ChannelEmojiStatus = true
} else {
s .Flags .Unset (10 )
s .ChannelEmojiStatus = false
}
}
func (s *StickerSet ) GetChannelEmojiStatus () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (10 )
}
func (s *StickerSet ) SetInstalledDate (value int ) {
s .Flags .Set (0 )
s .InstalledDate = value
}
func (s *StickerSet ) GetInstalledDate () (value int , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .InstalledDate , true
}
func (s *StickerSet ) GetID () (value int64 ) {
if s == nil {
return
}
return s .ID
}
func (s *StickerSet ) GetAccessHash () (value int64 ) {
if s == nil {
return
}
return s .AccessHash
}
func (s *StickerSet ) GetTitle () (value string ) {
if s == nil {
return
}
return s .Title
}
func (s *StickerSet ) GetShortName () (value string ) {
if s == nil {
return
}
return s .ShortName
}
func (s *StickerSet ) SetThumbs (value []PhotoSizeClass ) {
s .Flags .Set (4 )
s .Thumbs = value
}
func (s *StickerSet ) GetThumbs () (value []PhotoSizeClass , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (4 ) {
return value , false
}
return s .Thumbs , true
}
func (s *StickerSet ) SetThumbDCID (value int ) {
s .Flags .Set (4 )
s .ThumbDCID = value
}
func (s *StickerSet ) GetThumbDCID () (value int , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (4 ) {
return value , false
}
return s .ThumbDCID , true
}
func (s *StickerSet ) SetThumbVersion (value int ) {
s .Flags .Set (4 )
s .ThumbVersion = value
}
func (s *StickerSet ) GetThumbVersion () (value int , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (4 ) {
return value , false
}
return s .ThumbVersion , true
}
func (s *StickerSet ) SetThumbDocumentID (value int64 ) {
s .Flags .Set (8 )
s .ThumbDocumentID = value
}
func (s *StickerSet ) GetThumbDocumentID () (value int64 , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (8 ) {
return value , false
}
return s .ThumbDocumentID , true
}
func (s *StickerSet ) GetCount () (value int ) {
if s == nil {
return
}
return s .Count
}
func (s *StickerSet ) GetHash () (value int ) {
if s == nil {
return
}
return s .Hash
}
func (s *StickerSet ) MapThumbs () (value PhotoSizeClassArray , ok bool ) {
if !s .Flags .Has (4 ) {
return value , false
}
return PhotoSizeClassArray (s .Thumbs ), true
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .