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 MessagesFeaturedStickersNotModified struct {
Count int
}
const MessagesFeaturedStickersNotModifiedTypeID = 0xc6dc0c66
func (f MessagesFeaturedStickersNotModified ) construct () MessagesFeaturedStickersClass { return &f }
var (
_ bin .Encoder = &MessagesFeaturedStickersNotModified {}
_ bin .Decoder = &MessagesFeaturedStickersNotModified {}
_ bin .BareEncoder = &MessagesFeaturedStickersNotModified {}
_ bin .BareDecoder = &MessagesFeaturedStickersNotModified {}
_ MessagesFeaturedStickersClass = &MessagesFeaturedStickersNotModified {}
)
func (f *MessagesFeaturedStickersNotModified ) Zero () bool {
if f == nil {
return true
}
if !(f .Count == 0 ) {
return false
}
return true
}
func (f *MessagesFeaturedStickersNotModified ) String () string {
if f == nil {
return "MessagesFeaturedStickersNotModified(nil)"
}
type Alias MessagesFeaturedStickersNotModified
return fmt .Sprintf ("MessagesFeaturedStickersNotModified%+v" , Alias (*f ))
}
func (f *MessagesFeaturedStickersNotModified ) FillFrom (from interface {
GetCount () (value int )
}) {
f .Count = from .GetCount ()
}
func (*MessagesFeaturedStickersNotModified ) TypeID () uint32 {
return MessagesFeaturedStickersNotModifiedTypeID
}
func (*MessagesFeaturedStickersNotModified ) TypeName () string {
return "messages.featuredStickersNotModified"
}
func (f *MessagesFeaturedStickersNotModified ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.featuredStickersNotModified" ,
ID : MessagesFeaturedStickersNotModifiedTypeID ,
}
if f == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Count" ,
SchemaName : "count" ,
},
}
return typ
}
func (f *MessagesFeaturedStickersNotModified ) Encode (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't encode messages.featuredStickersNotModified#c6dc0c66 as nil" )
}
b .PutID (MessagesFeaturedStickersNotModifiedTypeID )
return f .EncodeBare (b )
}
func (f *MessagesFeaturedStickersNotModified ) EncodeBare (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't encode messages.featuredStickersNotModified#c6dc0c66 as nil" )
}
b .PutInt (f .Count )
return nil
}
func (f *MessagesFeaturedStickersNotModified ) Decode (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't decode messages.featuredStickersNotModified#c6dc0c66 to nil" )
}
if err := b .ConsumeID (MessagesFeaturedStickersNotModifiedTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.featuredStickersNotModified#c6dc0c66: %w" , err )
}
return f .DecodeBare (b )
}
func (f *MessagesFeaturedStickersNotModified ) DecodeBare (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't decode messages.featuredStickersNotModified#c6dc0c66 to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.featuredStickersNotModified#c6dc0c66: field count: %w" , err )
}
f .Count = value
}
return nil
}
func (f *MessagesFeaturedStickersNotModified ) GetCount () (value int ) {
if f == nil {
return
}
return f .Count
}
type MessagesFeaturedStickers struct {
Flags bin .Fields
Premium bool
Hash int64
Count int
Sets []StickerSetCoveredClass
Unread []int64
}
const MessagesFeaturedStickersTypeID = 0xbe382906
func (f MessagesFeaturedStickers ) construct () MessagesFeaturedStickersClass { return &f }
var (
_ bin .Encoder = &MessagesFeaturedStickers {}
_ bin .Decoder = &MessagesFeaturedStickers {}
_ bin .BareEncoder = &MessagesFeaturedStickers {}
_ bin .BareDecoder = &MessagesFeaturedStickers {}
_ MessagesFeaturedStickersClass = &MessagesFeaturedStickers {}
)
func (f *MessagesFeaturedStickers ) Zero () bool {
if f == nil {
return true
}
if !(f .Flags .Zero ()) {
return false
}
if !(f .Premium == false ) {
return false
}
if !(f .Hash == 0 ) {
return false
}
if !(f .Count == 0 ) {
return false
}
if !(f .Sets == nil ) {
return false
}
if !(f .Unread == nil ) {
return false
}
return true
}
func (f *MessagesFeaturedStickers ) String () string {
if f == nil {
return "MessagesFeaturedStickers(nil)"
}
type Alias MessagesFeaturedStickers
return fmt .Sprintf ("MessagesFeaturedStickers%+v" , Alias (*f ))
}
func (f *MessagesFeaturedStickers ) FillFrom (from interface {
GetPremium () (value bool )
GetHash () (value int64 )
GetCount () (value int )
GetSets () (value []StickerSetCoveredClass )
GetUnread () (value []int64 )
}) {
f .Premium = from .GetPremium ()
f .Hash = from .GetHash ()
f .Count = from .GetCount ()
f .Sets = from .GetSets ()
f .Unread = from .GetUnread ()
}
func (*MessagesFeaturedStickers ) TypeID () uint32 {
return MessagesFeaturedStickersTypeID
}
func (*MessagesFeaturedStickers ) TypeName () string {
return "messages.featuredStickers"
}
func (f *MessagesFeaturedStickers ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.featuredStickers" ,
ID : MessagesFeaturedStickersTypeID ,
}
if f == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Premium" ,
SchemaName : "premium" ,
Null : !f .Flags .Has (0 ),
},
{
Name : "Hash" ,
SchemaName : "hash" ,
},
{
Name : "Count" ,
SchemaName : "count" ,
},
{
Name : "Sets" ,
SchemaName : "sets" ,
},
{
Name : "Unread" ,
SchemaName : "unread" ,
},
}
return typ
}
func (f *MessagesFeaturedStickers ) SetFlags () {
if !(f .Premium == false ) {
f .Flags .Set (0 )
}
}
func (f *MessagesFeaturedStickers ) Encode (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't encode messages.featuredStickers#be382906 as nil" )
}
b .PutID (MessagesFeaturedStickersTypeID )
return f .EncodeBare (b )
}
func (f *MessagesFeaturedStickers ) EncodeBare (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't encode messages.featuredStickers#be382906 as nil" )
}
f .SetFlags ()
if err := f .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.featuredStickers#be382906: field flags: %w" , err )
}
b .PutLong (f .Hash )
b .PutInt (f .Count )
b .PutVectorHeader (len (f .Sets ))
for idx , v := range f .Sets {
if v == nil {
return fmt .Errorf ("unable to encode messages.featuredStickers#be382906: field sets element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.featuredStickers#be382906: field sets element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (f .Unread ))
for _ , v := range f .Unread {
b .PutLong (v )
}
return nil
}
func (f *MessagesFeaturedStickers ) Decode (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't decode messages.featuredStickers#be382906 to nil" )
}
if err := b .ConsumeID (MessagesFeaturedStickersTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.featuredStickers#be382906: %w" , err )
}
return f .DecodeBare (b )
}
func (f *MessagesFeaturedStickers ) DecodeBare (b *bin .Buffer ) error {
if f == nil {
return fmt .Errorf ("can't decode messages.featuredStickers#be382906 to nil" )
}
{
if err := f .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.featuredStickers#be382906: field flags: %w" , err )
}
}
f .Premium = f .Flags .Has (0 )
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode messages.featuredStickers#be382906: field hash: %w" , err )
}
f .Hash = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.featuredStickers#be382906: field count: %w" , err )
}
f .Count = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.featuredStickers#be382906: field sets: %w" , err )
}
if headerLen > 0 {
f .Sets = make ([]StickerSetCoveredClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeStickerSetCovered (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.featuredStickers#be382906: field sets: %w" , err )
}
f .Sets = append (f .Sets , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.featuredStickers#be382906: field unread: %w" , err )
}
if headerLen > 0 {
f .Unread = 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 messages.featuredStickers#be382906: field unread: %w" , err )
}
f .Unread = append (f .Unread , value )
}
}
return nil
}
func (f *MessagesFeaturedStickers ) SetPremium (value bool ) {
if value {
f .Flags .Set (0 )
f .Premium = true
} else {
f .Flags .Unset (0 )
f .Premium = false
}
}
func (f *MessagesFeaturedStickers ) GetPremium () (value bool ) {
if f == nil {
return
}
return f .Flags .Has (0 )
}
func (f *MessagesFeaturedStickers ) GetHash () (value int64 ) {
if f == nil {
return
}
return f .Hash
}
func (f *MessagesFeaturedStickers ) GetCount () (value int ) {
if f == nil {
return
}
return f .Count
}
func (f *MessagesFeaturedStickers ) GetSets () (value []StickerSetCoveredClass ) {
if f == nil {
return
}
return f .Sets
}
func (f *MessagesFeaturedStickers ) GetUnread () (value []int64 ) {
if f == nil {
return
}
return f .Unread
}
func (f *MessagesFeaturedStickers ) MapSets () (value StickerSetCoveredClassArray ) {
return StickerSetCoveredClassArray (f .Sets )
}
const MessagesFeaturedStickersClassName = "messages.FeaturedStickers"
type MessagesFeaturedStickersClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () MessagesFeaturedStickersClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetCount () (value int )
AsModified () (*MessagesFeaturedStickers , bool )
}
func (f *MessagesFeaturedStickersNotModified ) AsModified () (*MessagesFeaturedStickers , bool ) {
return nil , false
}
func (f *MessagesFeaturedStickers ) AsModified () (*MessagesFeaturedStickers , bool ) {
return f , true
}
func DecodeMessagesFeaturedStickers (buf *bin .Buffer ) (MessagesFeaturedStickersClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case MessagesFeaturedStickersNotModifiedTypeID :
v := MessagesFeaturedStickersNotModified {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessagesFeaturedStickersClass: %w" , err )
}
return &v , nil
case MessagesFeaturedStickersTypeID :
v := MessagesFeaturedStickers {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessagesFeaturedStickersClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode MessagesFeaturedStickersClass: %w" , bin .NewUnexpectedID (id ))
}
}
type MessagesFeaturedStickersBox struct {
FeaturedStickers MessagesFeaturedStickersClass
}
func (b *MessagesFeaturedStickersBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode MessagesFeaturedStickersBox to nil" )
}
v , err := DecodeMessagesFeaturedStickers (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .FeaturedStickers = v
return nil
}
func (b *MessagesFeaturedStickersBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .FeaturedStickers == nil {
return fmt .Errorf ("unable to encode MessagesFeaturedStickersClass as nil" )
}
return b .FeaturedStickers .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 .