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 HelpDeepLinkInfoEmpty struct {
}
const HelpDeepLinkInfoEmptyTypeID = 0x66afa166
func (d HelpDeepLinkInfoEmpty ) construct () HelpDeepLinkInfoClass { return &d }
var (
_ bin .Encoder = &HelpDeepLinkInfoEmpty {}
_ bin .Decoder = &HelpDeepLinkInfoEmpty {}
_ bin .BareEncoder = &HelpDeepLinkInfoEmpty {}
_ bin .BareDecoder = &HelpDeepLinkInfoEmpty {}
_ HelpDeepLinkInfoClass = &HelpDeepLinkInfoEmpty {}
)
func (d *HelpDeepLinkInfoEmpty ) Zero () bool {
if d == nil {
return true
}
return true
}
func (d *HelpDeepLinkInfoEmpty ) String () string {
if d == nil {
return "HelpDeepLinkInfoEmpty(nil)"
}
type Alias HelpDeepLinkInfoEmpty
return fmt .Sprintf ("HelpDeepLinkInfoEmpty%+v" , Alias (*d ))
}
func (*HelpDeepLinkInfoEmpty ) TypeID () uint32 {
return HelpDeepLinkInfoEmptyTypeID
}
func (*HelpDeepLinkInfoEmpty ) TypeName () string {
return "help.deepLinkInfoEmpty"
}
func (d *HelpDeepLinkInfoEmpty ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "help.deepLinkInfoEmpty" ,
ID : HelpDeepLinkInfoEmptyTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (d *HelpDeepLinkInfoEmpty ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode help.deepLinkInfoEmpty#66afa166 as nil" )
}
b .PutID (HelpDeepLinkInfoEmptyTypeID )
return d .EncodeBare (b )
}
func (d *HelpDeepLinkInfoEmpty ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode help.deepLinkInfoEmpty#66afa166 as nil" )
}
return nil
}
func (d *HelpDeepLinkInfoEmpty ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode help.deepLinkInfoEmpty#66afa166 to nil" )
}
if err := b .ConsumeID (HelpDeepLinkInfoEmptyTypeID ); err != nil {
return fmt .Errorf ("unable to decode help.deepLinkInfoEmpty#66afa166: %w" , err )
}
return d .DecodeBare (b )
}
func (d *HelpDeepLinkInfoEmpty ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode help.deepLinkInfoEmpty#66afa166 to nil" )
}
return nil
}
type HelpDeepLinkInfo struct {
Flags bin .Fields
UpdateApp bool
Message string
Entities []MessageEntityClass
}
const HelpDeepLinkInfoTypeID = 0x6a4ee832
func (d HelpDeepLinkInfo ) construct () HelpDeepLinkInfoClass { return &d }
var (
_ bin .Encoder = &HelpDeepLinkInfo {}
_ bin .Decoder = &HelpDeepLinkInfo {}
_ bin .BareEncoder = &HelpDeepLinkInfo {}
_ bin .BareDecoder = &HelpDeepLinkInfo {}
_ HelpDeepLinkInfoClass = &HelpDeepLinkInfo {}
)
func (d *HelpDeepLinkInfo ) Zero () bool {
if d == nil {
return true
}
if !(d .Flags .Zero ()) {
return false
}
if !(d .UpdateApp == false ) {
return false
}
if !(d .Message == "" ) {
return false
}
if !(d .Entities == nil ) {
return false
}
return true
}
func (d *HelpDeepLinkInfo ) String () string {
if d == nil {
return "HelpDeepLinkInfo(nil)"
}
type Alias HelpDeepLinkInfo
return fmt .Sprintf ("HelpDeepLinkInfo%+v" , Alias (*d ))
}
func (d *HelpDeepLinkInfo ) FillFrom (from interface {
GetUpdateApp () (value bool )
GetMessage () (value string )
GetEntities () (value []MessageEntityClass , ok bool )
}) {
d .UpdateApp = from .GetUpdateApp ()
d .Message = from .GetMessage ()
if val , ok := from .GetEntities (); ok {
d .Entities = val
}
}
func (*HelpDeepLinkInfo ) TypeID () uint32 {
return HelpDeepLinkInfoTypeID
}
func (*HelpDeepLinkInfo ) TypeName () string {
return "help.deepLinkInfo"
}
func (d *HelpDeepLinkInfo ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "help.deepLinkInfo" ,
ID : HelpDeepLinkInfoTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "UpdateApp" ,
SchemaName : "update_app" ,
Null : !d .Flags .Has (0 ),
},
{
Name : "Message" ,
SchemaName : "message" ,
},
{
Name : "Entities" ,
SchemaName : "entities" ,
Null : !d .Flags .Has (1 ),
},
}
return typ
}
func (d *HelpDeepLinkInfo ) SetFlags () {
if !(d .UpdateApp == false ) {
d .Flags .Set (0 )
}
if !(d .Entities == nil ) {
d .Flags .Set (1 )
}
}
func (d *HelpDeepLinkInfo ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode help.deepLinkInfo#6a4ee832 as nil" )
}
b .PutID (HelpDeepLinkInfoTypeID )
return d .EncodeBare (b )
}
func (d *HelpDeepLinkInfo ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode help.deepLinkInfo#6a4ee832 as nil" )
}
d .SetFlags ()
if err := d .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode help.deepLinkInfo#6a4ee832: field flags: %w" , err )
}
b .PutString (d .Message )
if d .Flags .Has (1 ) {
b .PutVectorHeader (len (d .Entities ))
for idx , v := range d .Entities {
if v == nil {
return fmt .Errorf ("unable to encode help.deepLinkInfo#6a4ee832: field entities element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode help.deepLinkInfo#6a4ee832: field entities element with index %d: %w" , idx , err )
}
}
}
return nil
}
func (d *HelpDeepLinkInfo ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode help.deepLinkInfo#6a4ee832 to nil" )
}
if err := b .ConsumeID (HelpDeepLinkInfoTypeID ); err != nil {
return fmt .Errorf ("unable to decode help.deepLinkInfo#6a4ee832: %w" , err )
}
return d .DecodeBare (b )
}
func (d *HelpDeepLinkInfo ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode help.deepLinkInfo#6a4ee832 to nil" )
}
{
if err := d .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode help.deepLinkInfo#6a4ee832: field flags: %w" , err )
}
}
d .UpdateApp = d .Flags .Has (0 )
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode help.deepLinkInfo#6a4ee832: field message: %w" , err )
}
d .Message = value
}
if d .Flags .Has (1 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode help.deepLinkInfo#6a4ee832: field entities: %w" , err )
}
if headerLen > 0 {
d .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.deepLinkInfo#6a4ee832: field entities: %w" , err )
}
d .Entities = append (d .Entities , value )
}
}
return nil
}
func (d *HelpDeepLinkInfo ) SetUpdateApp (value bool ) {
if value {
d .Flags .Set (0 )
d .UpdateApp = true
} else {
d .Flags .Unset (0 )
d .UpdateApp = false
}
}
func (d *HelpDeepLinkInfo ) GetUpdateApp () (value bool ) {
if d == nil {
return
}
return d .Flags .Has (0 )
}
func (d *HelpDeepLinkInfo ) GetMessage () (value string ) {
if d == nil {
return
}
return d .Message
}
func (d *HelpDeepLinkInfo ) SetEntities (value []MessageEntityClass ) {
d .Flags .Set (1 )
d .Entities = value
}
func (d *HelpDeepLinkInfo ) GetEntities () (value []MessageEntityClass , ok bool ) {
if d == nil {
return
}
if !d .Flags .Has (1 ) {
return value , false
}
return d .Entities , true
}
func (d *HelpDeepLinkInfo ) MapEntities () (value MessageEntityClassArray , ok bool ) {
if !d .Flags .Has (1 ) {
return value , false
}
return MessageEntityClassArray (d .Entities ), true
}
const HelpDeepLinkInfoClassName = "help.DeepLinkInfo"
type HelpDeepLinkInfoClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () HelpDeepLinkInfoClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsNotEmpty () (*HelpDeepLinkInfo , bool )
}
func (d *HelpDeepLinkInfoEmpty ) AsNotEmpty () (*HelpDeepLinkInfo , bool ) {
return nil , false
}
func (d *HelpDeepLinkInfo ) AsNotEmpty () (*HelpDeepLinkInfo , bool ) {
return d , true
}
func DecodeHelpDeepLinkInfo (buf *bin .Buffer ) (HelpDeepLinkInfoClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case HelpDeepLinkInfoEmptyTypeID :
v := HelpDeepLinkInfoEmpty {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode HelpDeepLinkInfoClass: %w" , err )
}
return &v , nil
case HelpDeepLinkInfoTypeID :
v := HelpDeepLinkInfo {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode HelpDeepLinkInfoClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode HelpDeepLinkInfoClass: %w" , bin .NewUnexpectedID (id ))
}
}
type HelpDeepLinkInfoBox struct {
DeepLinkInfo HelpDeepLinkInfoClass
}
func (b *HelpDeepLinkInfoBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode HelpDeepLinkInfoBox to nil" )
}
v , err := DecodeHelpDeepLinkInfo (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .DeepLinkInfo = v
return nil
}
func (b *HelpDeepLinkInfoBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .DeepLinkInfo == nil {
return fmt .Errorf ("unable to encode HelpDeepLinkInfoClass as nil" )
}
return b .DeepLinkInfo .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 .