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 BotsPopularAppBots struct {
Flags bin .Fields
NextOffset string
Users []UserClass
}
const BotsPopularAppBotsTypeID = 0x1991b13b
var (
_ bin .Encoder = &BotsPopularAppBots {}
_ bin .Decoder = &BotsPopularAppBots {}
_ bin .BareEncoder = &BotsPopularAppBots {}
_ bin .BareDecoder = &BotsPopularAppBots {}
)
func (p *BotsPopularAppBots ) Zero () bool {
if p == nil {
return true
}
if !(p .Flags .Zero ()) {
return false
}
if !(p .NextOffset == "" ) {
return false
}
if !(p .Users == nil ) {
return false
}
return true
}
func (p *BotsPopularAppBots ) String () string {
if p == nil {
return "BotsPopularAppBots(nil)"
}
type Alias BotsPopularAppBots
return fmt .Sprintf ("BotsPopularAppBots%+v" , Alias (*p ))
}
func (p *BotsPopularAppBots ) FillFrom (from interface {
GetNextOffset () (value string , ok bool )
GetUsers () (value []UserClass )
}) {
if val , ok := from .GetNextOffset (); ok {
p .NextOffset = val
}
p .Users = from .GetUsers ()
}
func (*BotsPopularAppBots ) TypeID () uint32 {
return BotsPopularAppBotsTypeID
}
func (*BotsPopularAppBots ) TypeName () string {
return "bots.popularAppBots"
}
func (p *BotsPopularAppBots ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "bots.popularAppBots" ,
ID : BotsPopularAppBotsTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "NextOffset" ,
SchemaName : "next_offset" ,
Null : !p .Flags .Has (0 ),
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (p *BotsPopularAppBots ) SetFlags () {
if !(p .NextOffset == "" ) {
p .Flags .Set (0 )
}
}
func (p *BotsPopularAppBots ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode bots.popularAppBots#1991b13b as nil" )
}
b .PutID (BotsPopularAppBotsTypeID )
return p .EncodeBare (b )
}
func (p *BotsPopularAppBots ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode bots.popularAppBots#1991b13b as nil" )
}
p .SetFlags ()
if err := p .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode bots.popularAppBots#1991b13b: field flags: %w" , err )
}
if p .Flags .Has (0 ) {
b .PutString (p .NextOffset )
}
b .PutVectorHeader (len (p .Users ))
for idx , v := range p .Users {
if v == nil {
return fmt .Errorf ("unable to encode bots.popularAppBots#1991b13b: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode bots.popularAppBots#1991b13b: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (p *BotsPopularAppBots ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode bots.popularAppBots#1991b13b to nil" )
}
if err := b .ConsumeID (BotsPopularAppBotsTypeID ); err != nil {
return fmt .Errorf ("unable to decode bots.popularAppBots#1991b13b: %w" , err )
}
return p .DecodeBare (b )
}
func (p *BotsPopularAppBots ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode bots.popularAppBots#1991b13b to nil" )
}
{
if err := p .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode bots.popularAppBots#1991b13b: field flags: %w" , err )
}
}
if p .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode bots.popularAppBots#1991b13b: field next_offset: %w" , err )
}
p .NextOffset = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode bots.popularAppBots#1991b13b: field users: %w" , err )
}
if headerLen > 0 {
p .Users = make ([]UserClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeUser (b )
if err != nil {
return fmt .Errorf ("unable to decode bots.popularAppBots#1991b13b: field users: %w" , err )
}
p .Users = append (p .Users , value )
}
}
return nil
}
func (p *BotsPopularAppBots ) SetNextOffset (value string ) {
p .Flags .Set (0 )
p .NextOffset = value
}
func (p *BotsPopularAppBots ) GetNextOffset () (value string , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (0 ) {
return value , false
}
return p .NextOffset , true
}
func (p *BotsPopularAppBots ) GetUsers () (value []UserClass ) {
if p == nil {
return
}
return p .Users
}
func (p *BotsPopularAppBots ) MapUsers () (value UserClassArray ) {
return UserClassArray (p .Users )
}
The pages are generated with Golds v0.8.4 . (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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .