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 MessagesStickerSet struct {
Set StickerSet
Packs []StickerPack
Keywords []StickerKeyword
Documents []DocumentClass
}
const MessagesStickerSetTypeID = 0x6e153f16
func (s MessagesStickerSet ) construct () MessagesStickerSetClass { return &s }
var (
_ bin .Encoder = &MessagesStickerSet {}
_ bin .Decoder = &MessagesStickerSet {}
_ bin .BareEncoder = &MessagesStickerSet {}
_ bin .BareDecoder = &MessagesStickerSet {}
_ MessagesStickerSetClass = &MessagesStickerSet {}
)
func (s *MessagesStickerSet ) Zero () bool {
if s == nil {
return true
}
if !(s .Set .Zero ()) {
return false
}
if !(s .Packs == nil ) {
return false
}
if !(s .Keywords == nil ) {
return false
}
if !(s .Documents == nil ) {
return false
}
return true
}
func (s *MessagesStickerSet ) String () string {
if s == nil {
return "MessagesStickerSet(nil)"
}
type Alias MessagesStickerSet
return fmt .Sprintf ("MessagesStickerSet%+v" , Alias (*s ))
}
func (s *MessagesStickerSet ) FillFrom (from interface {
GetSet () (value StickerSet )
GetPacks () (value []StickerPack )
GetKeywords () (value []StickerKeyword )
GetDocuments () (value []DocumentClass )
}) {
s .Set = from .GetSet ()
s .Packs = from .GetPacks ()
s .Keywords = from .GetKeywords ()
s .Documents = from .GetDocuments ()
}
func (*MessagesStickerSet ) TypeID () uint32 {
return MessagesStickerSetTypeID
}
func (*MessagesStickerSet ) TypeName () string {
return "messages.stickerSet"
}
func (s *MessagesStickerSet ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.stickerSet" ,
ID : MessagesStickerSetTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Set" ,
SchemaName : "set" ,
},
{
Name : "Packs" ,
SchemaName : "packs" ,
},
{
Name : "Keywords" ,
SchemaName : "keywords" ,
},
{
Name : "Documents" ,
SchemaName : "documents" ,
},
}
return typ
}
func (s *MessagesStickerSet ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.stickerSet#6e153f16 as nil" )
}
b .PutID (MessagesStickerSetTypeID )
return s .EncodeBare (b )
}
func (s *MessagesStickerSet ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.stickerSet#6e153f16 as nil" )
}
if err := s .Set .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.stickerSet#6e153f16: field set: %w" , err )
}
b .PutVectorHeader (len (s .Packs ))
for idx , v := range s .Packs {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.stickerSet#6e153f16: field packs element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (s .Keywords ))
for idx , v := range s .Keywords {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.stickerSet#6e153f16: field keywords element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (s .Documents ))
for idx , v := range s .Documents {
if v == nil {
return fmt .Errorf ("unable to encode messages.stickerSet#6e153f16: field documents element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.stickerSet#6e153f16: field documents element with index %d: %w" , idx , err )
}
}
return nil
}
func (s *MessagesStickerSet ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.stickerSet#6e153f16 to nil" )
}
if err := b .ConsumeID (MessagesStickerSetTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.stickerSet#6e153f16: %w" , err )
}
return s .DecodeBare (b )
}
func (s *MessagesStickerSet ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.stickerSet#6e153f16 to nil" )
}
{
if err := s .Set .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.stickerSet#6e153f16: field set: %w" , err )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.stickerSet#6e153f16: field packs: %w" , err )
}
if headerLen > 0 {
s .Packs = make ([]StickerPack , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value StickerPack
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.stickerSet#6e153f16: field packs: %w" , err )
}
s .Packs = append (s .Packs , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.stickerSet#6e153f16: field keywords: %w" , err )
}
if headerLen > 0 {
s .Keywords = make ([]StickerKeyword , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value StickerKeyword
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.stickerSet#6e153f16: field keywords: %w" , err )
}
s .Keywords = append (s .Keywords , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.stickerSet#6e153f16: field documents: %w" , err )
}
if headerLen > 0 {
s .Documents = make ([]DocumentClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.stickerSet#6e153f16: field documents: %w" , err )
}
s .Documents = append (s .Documents , value )
}
}
return nil
}
func (s *MessagesStickerSet ) GetSet () (value StickerSet ) {
if s == nil {
return
}
return s .Set
}
func (s *MessagesStickerSet ) GetPacks () (value []StickerPack ) {
if s == nil {
return
}
return s .Packs
}
func (s *MessagesStickerSet ) GetKeywords () (value []StickerKeyword ) {
if s == nil {
return
}
return s .Keywords
}
func (s *MessagesStickerSet ) GetDocuments () (value []DocumentClass ) {
if s == nil {
return
}
return s .Documents
}
func (s *MessagesStickerSet ) MapDocuments () (value DocumentClassArray ) {
return DocumentClassArray (s .Documents )
}
type MessagesStickerSetNotModified struct {
}
const MessagesStickerSetNotModifiedTypeID = 0xd3f924eb
func (s MessagesStickerSetNotModified ) construct () MessagesStickerSetClass { return &s }
var (
_ bin .Encoder = &MessagesStickerSetNotModified {}
_ bin .Decoder = &MessagesStickerSetNotModified {}
_ bin .BareEncoder = &MessagesStickerSetNotModified {}
_ bin .BareDecoder = &MessagesStickerSetNotModified {}
_ MessagesStickerSetClass = &MessagesStickerSetNotModified {}
)
func (s *MessagesStickerSetNotModified ) Zero () bool {
if s == nil {
return true
}
return true
}
func (s *MessagesStickerSetNotModified ) String () string {
if s == nil {
return "MessagesStickerSetNotModified(nil)"
}
type Alias MessagesStickerSetNotModified
return fmt .Sprintf ("MessagesStickerSetNotModified%+v" , Alias (*s ))
}
func (*MessagesStickerSetNotModified ) TypeID () uint32 {
return MessagesStickerSetNotModifiedTypeID
}
func (*MessagesStickerSetNotModified ) TypeName () string {
return "messages.stickerSetNotModified"
}
func (s *MessagesStickerSetNotModified ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.stickerSetNotModified" ,
ID : MessagesStickerSetNotModifiedTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (s *MessagesStickerSetNotModified ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.stickerSetNotModified#d3f924eb as nil" )
}
b .PutID (MessagesStickerSetNotModifiedTypeID )
return s .EncodeBare (b )
}
func (s *MessagesStickerSetNotModified ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.stickerSetNotModified#d3f924eb as nil" )
}
return nil
}
func (s *MessagesStickerSetNotModified ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.stickerSetNotModified#d3f924eb to nil" )
}
if err := b .ConsumeID (MessagesStickerSetNotModifiedTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.stickerSetNotModified#d3f924eb: %w" , err )
}
return s .DecodeBare (b )
}
func (s *MessagesStickerSetNotModified ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.stickerSetNotModified#d3f924eb to nil" )
}
return nil
}
const MessagesStickerSetClassName = "messages.StickerSet"
type MessagesStickerSetClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () MessagesStickerSetClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsModified () (*MessagesStickerSet , bool )
}
func (s *MessagesStickerSet ) AsModified () (*MessagesStickerSet , bool ) {
return s , true
}
func (s *MessagesStickerSetNotModified ) AsModified () (*MessagesStickerSet , bool ) {
return nil , false
}
func DecodeMessagesStickerSet (buf *bin .Buffer ) (MessagesStickerSetClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case MessagesStickerSetTypeID :
v := MessagesStickerSet {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessagesStickerSetClass: %w" , err )
}
return &v , nil
case MessagesStickerSetNotModifiedTypeID :
v := MessagesStickerSetNotModified {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessagesStickerSetClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode MessagesStickerSetClass: %w" , bin .NewUnexpectedID (id ))
}
}
type MessagesStickerSetBox struct {
StickerSet MessagesStickerSetClass
}
func (b *MessagesStickerSetBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode MessagesStickerSetBox to nil" )
}
v , err := DecodeMessagesStickerSet (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .StickerSet = v
return nil
}
func (b *MessagesStickerSetBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .StickerSet == nil {
return fmt .Errorf ("unable to encode MessagesStickerSetClass as nil" )
}
return b .StickerSet .Encode (buf )
}
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 .