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 AttachMenuBotsNotModified struct {
}
const AttachMenuBotsNotModifiedTypeID = 0xf1d88a5c
func (a AttachMenuBotsNotModified ) construct () AttachMenuBotsClass { return &a }
var (
_ bin .Encoder = &AttachMenuBotsNotModified {}
_ bin .Decoder = &AttachMenuBotsNotModified {}
_ bin .BareEncoder = &AttachMenuBotsNotModified {}
_ bin .BareDecoder = &AttachMenuBotsNotModified {}
_ AttachMenuBotsClass = &AttachMenuBotsNotModified {}
)
func (a *AttachMenuBotsNotModified ) Zero () bool {
if a == nil {
return true
}
return true
}
func (a *AttachMenuBotsNotModified ) String () string {
if a == nil {
return "AttachMenuBotsNotModified(nil)"
}
type Alias AttachMenuBotsNotModified
return fmt .Sprintf ("AttachMenuBotsNotModified%+v" , Alias (*a ))
}
func (*AttachMenuBotsNotModified ) TypeID () uint32 {
return AttachMenuBotsNotModifiedTypeID
}
func (*AttachMenuBotsNotModified ) TypeName () string {
return "attachMenuBotsNotModified"
}
func (a *AttachMenuBotsNotModified ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "attachMenuBotsNotModified" ,
ID : AttachMenuBotsNotModifiedTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (a *AttachMenuBotsNotModified ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode attachMenuBotsNotModified#f1d88a5c as nil" )
}
b .PutID (AttachMenuBotsNotModifiedTypeID )
return a .EncodeBare (b )
}
func (a *AttachMenuBotsNotModified ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode attachMenuBotsNotModified#f1d88a5c as nil" )
}
return nil
}
func (a *AttachMenuBotsNotModified ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode attachMenuBotsNotModified#f1d88a5c to nil" )
}
if err := b .ConsumeID (AttachMenuBotsNotModifiedTypeID ); err != nil {
return fmt .Errorf ("unable to decode attachMenuBotsNotModified#f1d88a5c: %w" , err )
}
return a .DecodeBare (b )
}
func (a *AttachMenuBotsNotModified ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode attachMenuBotsNotModified#f1d88a5c to nil" )
}
return nil
}
type AttachMenuBots struct {
Hash int64
Bots []AttachMenuBot
Users []UserClass
}
const AttachMenuBotsTypeID = 0x3c4301c0
func (a AttachMenuBots ) construct () AttachMenuBotsClass { return &a }
var (
_ bin .Encoder = &AttachMenuBots {}
_ bin .Decoder = &AttachMenuBots {}
_ bin .BareEncoder = &AttachMenuBots {}
_ bin .BareDecoder = &AttachMenuBots {}
_ AttachMenuBotsClass = &AttachMenuBots {}
)
func (a *AttachMenuBots ) Zero () bool {
if a == nil {
return true
}
if !(a .Hash == 0 ) {
return false
}
if !(a .Bots == nil ) {
return false
}
if !(a .Users == nil ) {
return false
}
return true
}
func (a *AttachMenuBots ) String () string {
if a == nil {
return "AttachMenuBots(nil)"
}
type Alias AttachMenuBots
return fmt .Sprintf ("AttachMenuBots%+v" , Alias (*a ))
}
func (a *AttachMenuBots ) FillFrom (from interface {
GetHash () (value int64 )
GetBots () (value []AttachMenuBot )
GetUsers () (value []UserClass )
}) {
a .Hash = from .GetHash ()
a .Bots = from .GetBots ()
a .Users = from .GetUsers ()
}
func (*AttachMenuBots ) TypeID () uint32 {
return AttachMenuBotsTypeID
}
func (*AttachMenuBots ) TypeName () string {
return "attachMenuBots"
}
func (a *AttachMenuBots ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "attachMenuBots" ,
ID : AttachMenuBotsTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Hash" ,
SchemaName : "hash" ,
},
{
Name : "Bots" ,
SchemaName : "bots" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (a *AttachMenuBots ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode attachMenuBots#3c4301c0 as nil" )
}
b .PutID (AttachMenuBotsTypeID )
return a .EncodeBare (b )
}
func (a *AttachMenuBots ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode attachMenuBots#3c4301c0 as nil" )
}
b .PutLong (a .Hash )
b .PutVectorHeader (len (a .Bots ))
for idx , v := range a .Bots {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode attachMenuBots#3c4301c0: field bots element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (a .Users ))
for idx , v := range a .Users {
if v == nil {
return fmt .Errorf ("unable to encode attachMenuBots#3c4301c0: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode attachMenuBots#3c4301c0: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (a *AttachMenuBots ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode attachMenuBots#3c4301c0 to nil" )
}
if err := b .ConsumeID (AttachMenuBotsTypeID ); err != nil {
return fmt .Errorf ("unable to decode attachMenuBots#3c4301c0: %w" , err )
}
return a .DecodeBare (b )
}
func (a *AttachMenuBots ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode attachMenuBots#3c4301c0 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode attachMenuBots#3c4301c0: field hash: %w" , err )
}
a .Hash = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode attachMenuBots#3c4301c0: field bots: %w" , err )
}
if headerLen > 0 {
a .Bots = make ([]AttachMenuBot , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value AttachMenuBot
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode attachMenuBots#3c4301c0: field bots: %w" , err )
}
a .Bots = append (a .Bots , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode attachMenuBots#3c4301c0: 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 attachMenuBots#3c4301c0: field users: %w" , err )
}
a .Users = append (a .Users , value )
}
}
return nil
}
func (a *AttachMenuBots ) GetHash () (value int64 ) {
if a == nil {
return
}
return a .Hash
}
func (a *AttachMenuBots ) GetBots () (value []AttachMenuBot ) {
if a == nil {
return
}
return a .Bots
}
func (a *AttachMenuBots ) GetUsers () (value []UserClass ) {
if a == nil {
return
}
return a .Users
}
func (a *AttachMenuBots ) MapUsers () (value UserClassArray ) {
return UserClassArray (a .Users )
}
const AttachMenuBotsClassName = "AttachMenuBots"
type AttachMenuBotsClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () AttachMenuBotsClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsModified () (*AttachMenuBots , bool )
}
func (a *AttachMenuBotsNotModified ) AsModified () (*AttachMenuBots , bool ) {
return nil , false
}
func (a *AttachMenuBots ) AsModified () (*AttachMenuBots , bool ) {
return a , true
}
func DecodeAttachMenuBots (buf *bin .Buffer ) (AttachMenuBotsClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case AttachMenuBotsNotModifiedTypeID :
v := AttachMenuBotsNotModified {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode AttachMenuBotsClass: %w" , err )
}
return &v , nil
case AttachMenuBotsTypeID :
v := AttachMenuBots {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode AttachMenuBotsClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode AttachMenuBotsClass: %w" , bin .NewUnexpectedID (id ))
}
}
type AttachMenuBotsBox struct {
AttachMenuBots AttachMenuBotsClass
}
func (b *AttachMenuBotsBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode AttachMenuBotsBox to nil" )
}
v , err := DecodeAttachMenuBots (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .AttachMenuBots = v
return nil
}
func (b *AttachMenuBotsBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .AttachMenuBots == nil {
return fmt .Errorf ("unable to encode AttachMenuBotsClass as nil" )
}
return b .AttachMenuBots .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 .