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 StickerPack struct {
Emoticon string
Documents []int64
}
const StickerPackTypeID = 0x12b299d4
var (
_ bin .Encoder = &StickerPack {}
_ bin .Decoder = &StickerPack {}
_ bin .BareEncoder = &StickerPack {}
_ bin .BareDecoder = &StickerPack {}
)
func (s *StickerPack ) Zero () bool {
if s == nil {
return true
}
if !(s .Emoticon == "" ) {
return false
}
if !(s .Documents == nil ) {
return false
}
return true
}
func (s *StickerPack ) String () string {
if s == nil {
return "StickerPack(nil)"
}
type Alias StickerPack
return fmt .Sprintf ("StickerPack%+v" , Alias (*s ))
}
func (s *StickerPack ) FillFrom (from interface {
GetEmoticon () (value string )
GetDocuments () (value []int64 )
}) {
s .Emoticon = from .GetEmoticon ()
s .Documents = from .GetDocuments ()
}
func (*StickerPack ) TypeID () uint32 {
return StickerPackTypeID
}
func (*StickerPack ) TypeName () string {
return "stickerPack"
}
func (s *StickerPack ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "stickerPack" ,
ID : StickerPackTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Emoticon" ,
SchemaName : "emoticon" ,
},
{
Name : "Documents" ,
SchemaName : "documents" ,
},
}
return typ
}
func (s *StickerPack ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode stickerPack#12b299d4 as nil" )
}
b .PutID (StickerPackTypeID )
return s .EncodeBare (b )
}
func (s *StickerPack ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode stickerPack#12b299d4 as nil" )
}
b .PutString (s .Emoticon )
b .PutVectorHeader (len (s .Documents ))
for _ , v := range s .Documents {
b .PutLong (v )
}
return nil
}
func (s *StickerPack ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode stickerPack#12b299d4 to nil" )
}
if err := b .ConsumeID (StickerPackTypeID ); err != nil {
return fmt .Errorf ("unable to decode stickerPack#12b299d4: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StickerPack ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode stickerPack#12b299d4 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode stickerPack#12b299d4: field emoticon: %w" , err )
}
s .Emoticon = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stickerPack#12b299d4: field documents: %w" , err )
}
if headerLen > 0 {
s .Documents = make ([]int64 , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode stickerPack#12b299d4: field documents: %w" , err )
}
s .Documents = append (s .Documents , value )
}
}
return nil
}
func (s *StickerPack ) GetEmoticon () (value string ) {
if s == nil {
return
}
return s .Emoticon
}
func (s *StickerPack ) GetDocuments () (value []int64 ) {
if s == nil {
return
}
return s .Documents
}
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 .