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 AttachMenuBotIcon struct {
Flags bin .Fields
Name string
Icon DocumentClass
Colors []AttachMenuBotIconColor
}
const AttachMenuBotIconTypeID = 0xb2a7386b
var (
_ bin .Encoder = &AttachMenuBotIcon {}
_ bin .Decoder = &AttachMenuBotIcon {}
_ bin .BareEncoder = &AttachMenuBotIcon {}
_ bin .BareDecoder = &AttachMenuBotIcon {}
)
func (a *AttachMenuBotIcon ) Zero () bool {
if a == nil {
return true
}
if !(a .Flags .Zero ()) {
return false
}
if !(a .Name == "" ) {
return false
}
if !(a .Icon == nil ) {
return false
}
if !(a .Colors == nil ) {
return false
}
return true
}
func (a *AttachMenuBotIcon ) String () string {
if a == nil {
return "AttachMenuBotIcon(nil)"
}
type Alias AttachMenuBotIcon
return fmt .Sprintf ("AttachMenuBotIcon%+v" , Alias (*a ))
}
func (a *AttachMenuBotIcon ) FillFrom (from interface {
GetName () (value string )
GetIcon () (value DocumentClass )
GetColors () (value []AttachMenuBotIconColor , ok bool )
}) {
a .Name = from .GetName ()
a .Icon = from .GetIcon ()
if val , ok := from .GetColors (); ok {
a .Colors = val
}
}
func (*AttachMenuBotIcon ) TypeID () uint32 {
return AttachMenuBotIconTypeID
}
func (*AttachMenuBotIcon ) TypeName () string {
return "attachMenuBotIcon"
}
func (a *AttachMenuBotIcon ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "attachMenuBotIcon" ,
ID : AttachMenuBotIconTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Name" ,
SchemaName : "name" ,
},
{
Name : "Icon" ,
SchemaName : "icon" ,
},
{
Name : "Colors" ,
SchemaName : "colors" ,
Null : !a .Flags .Has (0 ),
},
}
return typ
}
func (a *AttachMenuBotIcon ) SetFlags () {
if !(a .Colors == nil ) {
a .Flags .Set (0 )
}
}
func (a *AttachMenuBotIcon ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode attachMenuBotIcon#b2a7386b as nil" )
}
b .PutID (AttachMenuBotIconTypeID )
return a .EncodeBare (b )
}
func (a *AttachMenuBotIcon ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode attachMenuBotIcon#b2a7386b as nil" )
}
a .SetFlags ()
if err := a .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode attachMenuBotIcon#b2a7386b: field flags: %w" , err )
}
b .PutString (a .Name )
if a .Icon == nil {
return fmt .Errorf ("unable to encode attachMenuBotIcon#b2a7386b: field icon is nil" )
}
if err := a .Icon .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode attachMenuBotIcon#b2a7386b: field icon: %w" , err )
}
if a .Flags .Has (0 ) {
b .PutVectorHeader (len (a .Colors ))
for idx , v := range a .Colors {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode attachMenuBotIcon#b2a7386b: field colors element with index %d: %w" , idx , err )
}
}
}
return nil
}
func (a *AttachMenuBotIcon ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode attachMenuBotIcon#b2a7386b to nil" )
}
if err := b .ConsumeID (AttachMenuBotIconTypeID ); err != nil {
return fmt .Errorf ("unable to decode attachMenuBotIcon#b2a7386b: %w" , err )
}
return a .DecodeBare (b )
}
func (a *AttachMenuBotIcon ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode attachMenuBotIcon#b2a7386b to nil" )
}
{
if err := a .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode attachMenuBotIcon#b2a7386b: field flags: %w" , err )
}
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode attachMenuBotIcon#b2a7386b: field name: %w" , err )
}
a .Name = value
}
{
value , err := DecodeDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode attachMenuBotIcon#b2a7386b: field icon: %w" , err )
}
a .Icon = value
}
if a .Flags .Has (0 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode attachMenuBotIcon#b2a7386b: field colors: %w" , err )
}
if headerLen > 0 {
a .Colors = make ([]AttachMenuBotIconColor , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value AttachMenuBotIconColor
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode attachMenuBotIcon#b2a7386b: field colors: %w" , err )
}
a .Colors = append (a .Colors , value )
}
}
return nil
}
func (a *AttachMenuBotIcon ) GetName () (value string ) {
if a == nil {
return
}
return a .Name
}
func (a *AttachMenuBotIcon ) GetIcon () (value DocumentClass ) {
if a == nil {
return
}
return a .Icon
}
func (a *AttachMenuBotIcon ) SetColors (value []AttachMenuBotIconColor ) {
a .Flags .Set (0 )
a .Colors = value
}
func (a *AttachMenuBotIcon ) GetColors () (value []AttachMenuBotIconColor , ok bool ) {
if a == nil {
return
}
if !a .Flags .Has (0 ) {
return value , false
}
return a .Colors , true
}
func (a *AttachMenuBotIcon ) GetIconAsNotEmpty () (*Document , bool ) {
return a .Icon .AsNotEmpty ()
}
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 .