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 HelpAppUpdate struct {
Flags bin .Fields
CanNotSkip bool
ID int
Version string
Text string
Entities []MessageEntityClass
Document DocumentClass
URL string
Sticker DocumentClass
}
const HelpAppUpdateTypeID = 0xccbbce30
func (a HelpAppUpdate ) construct () HelpAppUpdateClass { return &a }
var (
_ bin .Encoder = &HelpAppUpdate {}
_ bin .Decoder = &HelpAppUpdate {}
_ bin .BareEncoder = &HelpAppUpdate {}
_ bin .BareDecoder = &HelpAppUpdate {}
_ HelpAppUpdateClass = &HelpAppUpdate {}
)
func (a *HelpAppUpdate ) Zero () bool {
if a == nil {
return true
}
if !(a .Flags .Zero ()) {
return false
}
if !(a .CanNotSkip == false ) {
return false
}
if !(a .ID == 0 ) {
return false
}
if !(a .Version == "" ) {
return false
}
if !(a .Text == "" ) {
return false
}
if !(a .Entities == nil ) {
return false
}
if !(a .Document == nil ) {
return false
}
if !(a .URL == "" ) {
return false
}
if !(a .Sticker == nil ) {
return false
}
return true
}
func (a *HelpAppUpdate ) String () string {
if a == nil {
return "HelpAppUpdate(nil)"
}
type Alias HelpAppUpdate
return fmt .Sprintf ("HelpAppUpdate%+v" , Alias (*a ))
}
func (a *HelpAppUpdate ) FillFrom (from interface {
GetCanNotSkip () (value bool )
GetID () (value int )
GetVersion () (value string )
GetText () (value string )
GetEntities () (value []MessageEntityClass )
GetDocument () (value DocumentClass , ok bool )
GetURL () (value string , ok bool )
GetSticker () (value DocumentClass , ok bool )
}) {
a .CanNotSkip = from .GetCanNotSkip ()
a .ID = from .GetID ()
a .Version = from .GetVersion ()
a .Text = from .GetText ()
a .Entities = from .GetEntities ()
if val , ok := from .GetDocument (); ok {
a .Document = val
}
if val , ok := from .GetURL (); ok {
a .URL = val
}
if val , ok := from .GetSticker (); ok {
a .Sticker = val
}
}
func (*HelpAppUpdate ) TypeID () uint32 {
return HelpAppUpdateTypeID
}
func (*HelpAppUpdate ) TypeName () string {
return "help.appUpdate"
}
func (a *HelpAppUpdate ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "help.appUpdate" ,
ID : HelpAppUpdateTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "CanNotSkip" ,
SchemaName : "can_not_skip" ,
Null : !a .Flags .Has (0 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Version" ,
SchemaName : "version" ,
},
{
Name : "Text" ,
SchemaName : "text" ,
},
{
Name : "Entities" ,
SchemaName : "entities" ,
},
{
Name : "Document" ,
SchemaName : "document" ,
Null : !a .Flags .Has (1 ),
},
{
Name : "URL" ,
SchemaName : "url" ,
Null : !a .Flags .Has (2 ),
},
{
Name : "Sticker" ,
SchemaName : "sticker" ,
Null : !a .Flags .Has (3 ),
},
}
return typ
}
func (a *HelpAppUpdate ) SetFlags () {
if !(a .CanNotSkip == false ) {
a .Flags .Set (0 )
}
if !(a .Document == nil ) {
a .Flags .Set (1 )
}
if !(a .URL == "" ) {
a .Flags .Set (2 )
}
if !(a .Sticker == nil ) {
a .Flags .Set (3 )
}
}
func (a *HelpAppUpdate ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode help.appUpdate#ccbbce30 as nil" )
}
b .PutID (HelpAppUpdateTypeID )
return a .EncodeBare (b )
}
func (a *HelpAppUpdate ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode help.appUpdate#ccbbce30 as nil" )
}
a .SetFlags ()
if err := a .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode help.appUpdate#ccbbce30: field flags: %w" , err )
}
b .PutInt (a .ID )
b .PutString (a .Version )
b .PutString (a .Text )
b .PutVectorHeader (len (a .Entities ))
for idx , v := range a .Entities {
if v == nil {
return fmt .Errorf ("unable to encode help.appUpdate#ccbbce30: field entities element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode help.appUpdate#ccbbce30: field entities element with index %d: %w" , idx , err )
}
}
if a .Flags .Has (1 ) {
if a .Document == nil {
return fmt .Errorf ("unable to encode help.appUpdate#ccbbce30: field document is nil" )
}
if err := a .Document .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode help.appUpdate#ccbbce30: field document: %w" , err )
}
}
if a .Flags .Has (2 ) {
b .PutString (a .URL )
}
if a .Flags .Has (3 ) {
if a .Sticker == nil {
return fmt .Errorf ("unable to encode help.appUpdate#ccbbce30: field sticker is nil" )
}
if err := a .Sticker .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode help.appUpdate#ccbbce30: field sticker: %w" , err )
}
}
return nil
}
func (a *HelpAppUpdate ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode help.appUpdate#ccbbce30 to nil" )
}
if err := b .ConsumeID (HelpAppUpdateTypeID ); err != nil {
return fmt .Errorf ("unable to decode help.appUpdate#ccbbce30: %w" , err )
}
return a .DecodeBare (b )
}
func (a *HelpAppUpdate ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode help.appUpdate#ccbbce30 to nil" )
}
{
if err := a .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode help.appUpdate#ccbbce30: field flags: %w" , err )
}
}
a .CanNotSkip = a .Flags .Has (0 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode help.appUpdate#ccbbce30: field id: %w" , err )
}
a .ID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode help.appUpdate#ccbbce30: field version: %w" , err )
}
a .Version = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode help.appUpdate#ccbbce30: field text: %w" , err )
}
a .Text = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode help.appUpdate#ccbbce30: field entities: %w" , err )
}
if headerLen > 0 {
a .Entities = make ([]MessageEntityClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeMessageEntity (b )
if err != nil {
return fmt .Errorf ("unable to decode help.appUpdate#ccbbce30: field entities: %w" , err )
}
a .Entities = append (a .Entities , value )
}
}
if a .Flags .Has (1 ) {
value , err := DecodeDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode help.appUpdate#ccbbce30: field document: %w" , err )
}
a .Document = value
}
if a .Flags .Has (2 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode help.appUpdate#ccbbce30: field url: %w" , err )
}
a .URL = value
}
if a .Flags .Has (3 ) {
value , err := DecodeDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode help.appUpdate#ccbbce30: field sticker: %w" , err )
}
a .Sticker = value
}
return nil
}
func (a *HelpAppUpdate ) SetCanNotSkip (value bool ) {
if value {
a .Flags .Set (0 )
a .CanNotSkip = true
} else {
a .Flags .Unset (0 )
a .CanNotSkip = false
}
}
func (a *HelpAppUpdate ) GetCanNotSkip () (value bool ) {
if a == nil {
return
}
return a .Flags .Has (0 )
}
func (a *HelpAppUpdate ) GetID () (value int ) {
if a == nil {
return
}
return a .ID
}
func (a *HelpAppUpdate ) GetVersion () (value string ) {
if a == nil {
return
}
return a .Version
}
func (a *HelpAppUpdate ) GetText () (value string ) {
if a == nil {
return
}
return a .Text
}
func (a *HelpAppUpdate ) GetEntities () (value []MessageEntityClass ) {
if a == nil {
return
}
return a .Entities
}
func (a *HelpAppUpdate ) SetDocument (value DocumentClass ) {
a .Flags .Set (1 )
a .Document = value
}
func (a *HelpAppUpdate ) GetDocument () (value DocumentClass , ok bool ) {
if a == nil {
return
}
if !a .Flags .Has (1 ) {
return value , false
}
return a .Document , true
}
func (a *HelpAppUpdate ) SetURL (value string ) {
a .Flags .Set (2 )
a .URL = value
}
func (a *HelpAppUpdate ) GetURL () (value string , ok bool ) {
if a == nil {
return
}
if !a .Flags .Has (2 ) {
return value , false
}
return a .URL , true
}
func (a *HelpAppUpdate ) SetSticker (value DocumentClass ) {
a .Flags .Set (3 )
a .Sticker = value
}
func (a *HelpAppUpdate ) GetSticker () (value DocumentClass , ok bool ) {
if a == nil {
return
}
if !a .Flags .Has (3 ) {
return value , false
}
return a .Sticker , true
}
func (a *HelpAppUpdate ) MapEntities () (value MessageEntityClassArray ) {
return MessageEntityClassArray (a .Entities )
}
type HelpNoAppUpdate struct {
}
const HelpNoAppUpdateTypeID = 0xc45a6536
func (n HelpNoAppUpdate ) construct () HelpAppUpdateClass { return &n }
var (
_ bin .Encoder = &HelpNoAppUpdate {}
_ bin .Decoder = &HelpNoAppUpdate {}
_ bin .BareEncoder = &HelpNoAppUpdate {}
_ bin .BareDecoder = &HelpNoAppUpdate {}
_ HelpAppUpdateClass = &HelpNoAppUpdate {}
)
func (n *HelpNoAppUpdate ) Zero () bool {
if n == nil {
return true
}
return true
}
func (n *HelpNoAppUpdate ) String () string {
if n == nil {
return "HelpNoAppUpdate(nil)"
}
type Alias HelpNoAppUpdate
return fmt .Sprintf ("HelpNoAppUpdate%+v" , Alias (*n ))
}
func (*HelpNoAppUpdate ) TypeID () uint32 {
return HelpNoAppUpdateTypeID
}
func (*HelpNoAppUpdate ) TypeName () string {
return "help.noAppUpdate"
}
func (n *HelpNoAppUpdate ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "help.noAppUpdate" ,
ID : HelpNoAppUpdateTypeID ,
}
if n == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (n *HelpNoAppUpdate ) Encode (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't encode help.noAppUpdate#c45a6536 as nil" )
}
b .PutID (HelpNoAppUpdateTypeID )
return n .EncodeBare (b )
}
func (n *HelpNoAppUpdate ) EncodeBare (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't encode help.noAppUpdate#c45a6536 as nil" )
}
return nil
}
func (n *HelpNoAppUpdate ) Decode (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't decode help.noAppUpdate#c45a6536 to nil" )
}
if err := b .ConsumeID (HelpNoAppUpdateTypeID ); err != nil {
return fmt .Errorf ("unable to decode help.noAppUpdate#c45a6536: %w" , err )
}
return n .DecodeBare (b )
}
func (n *HelpNoAppUpdate ) DecodeBare (b *bin .Buffer ) error {
if n == nil {
return fmt .Errorf ("can't decode help.noAppUpdate#c45a6536 to nil" )
}
return nil
}
const HelpAppUpdateClassName = "help.AppUpdate"
type HelpAppUpdateClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () HelpAppUpdateClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeHelpAppUpdate (buf *bin .Buffer ) (HelpAppUpdateClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case HelpAppUpdateTypeID :
v := HelpAppUpdate {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode HelpAppUpdateClass: %w" , err )
}
return &v , nil
case HelpNoAppUpdateTypeID :
v := HelpNoAppUpdate {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode HelpAppUpdateClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode HelpAppUpdateClass: %w" , bin .NewUnexpectedID (id ))
}
}
type HelpAppUpdateBox struct {
AppUpdate HelpAppUpdateClass
}
func (b *HelpAppUpdateBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode HelpAppUpdateBox to nil" )
}
v , err := DecodeHelpAppUpdate (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .AppUpdate = v
return nil
}
func (b *HelpAppUpdateBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .AppUpdate == nil {
return fmt .Errorf ("unable to encode HelpAppUpdateClass as nil" )
}
return b .AppUpdate .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 .