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 AttachMenuBotsBot struct {
Bot AttachMenuBot
Users []UserClass
}
const AttachMenuBotsBotTypeID = 0x93bf667f
var (
_ bin .Encoder = &AttachMenuBotsBot {}
_ bin .Decoder = &AttachMenuBotsBot {}
_ bin .BareEncoder = &AttachMenuBotsBot {}
_ bin .BareDecoder = &AttachMenuBotsBot {}
)
func (a *AttachMenuBotsBot ) Zero () bool {
if a == nil {
return true
}
if !(a .Bot .Zero ()) {
return false
}
if !(a .Users == nil ) {
return false
}
return true
}
func (a *AttachMenuBotsBot ) String () string {
if a == nil {
return "AttachMenuBotsBot(nil)"
}
type Alias AttachMenuBotsBot
return fmt .Sprintf ("AttachMenuBotsBot%+v" , Alias (*a ))
}
func (a *AttachMenuBotsBot ) FillFrom (from interface {
GetBot () (value AttachMenuBot )
GetUsers () (value []UserClass )
}) {
a .Bot = from .GetBot ()
a .Users = from .GetUsers ()
}
func (*AttachMenuBotsBot ) TypeID () uint32 {
return AttachMenuBotsBotTypeID
}
func (*AttachMenuBotsBot ) TypeName () string {
return "attachMenuBotsBot"
}
func (a *AttachMenuBotsBot ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "attachMenuBotsBot" ,
ID : AttachMenuBotsBotTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Bot" ,
SchemaName : "bot" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (a *AttachMenuBotsBot ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode attachMenuBotsBot#93bf667f as nil" )
}
b .PutID (AttachMenuBotsBotTypeID )
return a .EncodeBare (b )
}
func (a *AttachMenuBotsBot ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode attachMenuBotsBot#93bf667f as nil" )
}
if err := a .Bot .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode attachMenuBotsBot#93bf667f: field bot: %w" , err )
}
b .PutVectorHeader (len (a .Users ))
for idx , v := range a .Users {
if v == nil {
return fmt .Errorf ("unable to encode attachMenuBotsBot#93bf667f: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode attachMenuBotsBot#93bf667f: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (a *AttachMenuBotsBot ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode attachMenuBotsBot#93bf667f to nil" )
}
if err := b .ConsumeID (AttachMenuBotsBotTypeID ); err != nil {
return fmt .Errorf ("unable to decode attachMenuBotsBot#93bf667f: %w" , err )
}
return a .DecodeBare (b )
}
func (a *AttachMenuBotsBot ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode attachMenuBotsBot#93bf667f to nil" )
}
{
if err := a .Bot .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode attachMenuBotsBot#93bf667f: field bot: %w" , err )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode attachMenuBotsBot#93bf667f: field users: %w" , err )
}
if headerLen > 0 {
a .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 attachMenuBotsBot#93bf667f: field users: %w" , err )
}
a .Users = append (a .Users , value )
}
}
return nil
}
func (a *AttachMenuBotsBot ) GetBot () (value AttachMenuBot ) {
if a == nil {
return
}
return a .Bot
}
func (a *AttachMenuBotsBot ) GetUsers () (value []UserClass ) {
if a == nil {
return
}
return a .Users
}
func (a *AttachMenuBotsBot ) MapUsers () (value UserClassArray ) {
return UserClassArray (a .Users )
}
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 .