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 BotAppNotModified struct {
}
const BotAppNotModifiedTypeID = 0x5da674b7
func (b BotAppNotModified ) construct () BotAppClass { return &b }
var (
_ bin .Encoder = &BotAppNotModified {}
_ bin .Decoder = &BotAppNotModified {}
_ bin .BareEncoder = &BotAppNotModified {}
_ bin .BareDecoder = &BotAppNotModified {}
_ BotAppClass = &BotAppNotModified {}
)
func (b *BotAppNotModified ) Zero () bool {
if b == nil {
return true
}
return true
}
func (b *BotAppNotModified ) String () string {
if b == nil {
return "BotAppNotModified(nil)"
}
type Alias BotAppNotModified
return fmt .Sprintf ("BotAppNotModified%+v" , Alias (*b ))
}
func (*BotAppNotModified ) TypeID () uint32 {
return BotAppNotModifiedTypeID
}
func (*BotAppNotModified ) TypeName () string {
return "botAppNotModified"
}
func (b *BotAppNotModified ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "botAppNotModified" ,
ID : BotAppNotModifiedTypeID ,
}
if b == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (b *BotAppNotModified ) Encode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode botAppNotModified#5da674b7 as nil" )
}
buf .PutID (BotAppNotModifiedTypeID )
return b .EncodeBare (buf )
}
func (b *BotAppNotModified ) EncodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode botAppNotModified#5da674b7 as nil" )
}
return nil
}
func (b *BotAppNotModified ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode botAppNotModified#5da674b7 to nil" )
}
if err := buf .ConsumeID (BotAppNotModifiedTypeID ); err != nil {
return fmt .Errorf ("unable to decode botAppNotModified#5da674b7: %w" , err )
}
return b .DecodeBare (buf )
}
func (b *BotAppNotModified ) DecodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode botAppNotModified#5da674b7 to nil" )
}
return nil
}
type BotApp struct {
Flags bin .Fields
ID int64
AccessHash int64
ShortName string
Title string
Description string
Photo PhotoClass
Document DocumentClass
Hash int64
}
const BotAppTypeID = 0x95fcd1d6
func (b BotApp ) construct () BotAppClass { return &b }
var (
_ bin .Encoder = &BotApp {}
_ bin .Decoder = &BotApp {}
_ bin .BareEncoder = &BotApp {}
_ bin .BareDecoder = &BotApp {}
_ BotAppClass = &BotApp {}
)
func (b *BotApp ) Zero () bool {
if b == nil {
return true
}
if !(b .Flags .Zero ()) {
return false
}
if !(b .ID == 0 ) {
return false
}
if !(b .AccessHash == 0 ) {
return false
}
if !(b .ShortName == "" ) {
return false
}
if !(b .Title == "" ) {
return false
}
if !(b .Description == "" ) {
return false
}
if !(b .Photo == nil ) {
return false
}
if !(b .Document == nil ) {
return false
}
if !(b .Hash == 0 ) {
return false
}
return true
}
func (b *BotApp ) String () string {
if b == nil {
return "BotApp(nil)"
}
type Alias BotApp
return fmt .Sprintf ("BotApp%+v" , Alias (*b ))
}
func (b *BotApp ) FillFrom (from interface {
GetID () (value int64 )
GetAccessHash () (value int64 )
GetShortName () (value string )
GetTitle () (value string )
GetDescription () (value string )
GetPhoto () (value PhotoClass )
GetDocument () (value DocumentClass , ok bool )
GetHash () (value int64 )
}) {
b .ID = from .GetID ()
b .AccessHash = from .GetAccessHash ()
b .ShortName = from .GetShortName ()
b .Title = from .GetTitle ()
b .Description = from .GetDescription ()
b .Photo = from .GetPhoto ()
if val , ok := from .GetDocument (); ok {
b .Document = val
}
b .Hash = from .GetHash ()
}
func (*BotApp ) TypeID () uint32 {
return BotAppTypeID
}
func (*BotApp ) TypeName () string {
return "botApp"
}
func (b *BotApp ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "botApp" ,
ID : BotAppTypeID ,
}
if b == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "AccessHash" ,
SchemaName : "access_hash" ,
},
{
Name : "ShortName" ,
SchemaName : "short_name" ,
},
{
Name : "Title" ,
SchemaName : "title" ,
},
{
Name : "Description" ,
SchemaName : "description" ,
},
{
Name : "Photo" ,
SchemaName : "photo" ,
},
{
Name : "Document" ,
SchemaName : "document" ,
Null : !b .Flags .Has (0 ),
},
{
Name : "Hash" ,
SchemaName : "hash" ,
},
}
return typ
}
func (b *BotApp ) SetFlags () {
if !(b .Document == nil ) {
b .Flags .Set (0 )
}
}
func (b *BotApp ) Encode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode botApp#95fcd1d6 as nil" )
}
buf .PutID (BotAppTypeID )
return b .EncodeBare (buf )
}
func (b *BotApp ) EncodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode botApp#95fcd1d6 as nil" )
}
b .SetFlags ()
if err := b .Flags .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode botApp#95fcd1d6: field flags: %w" , err )
}
buf .PutLong (b .ID )
buf .PutLong (b .AccessHash )
buf .PutString (b .ShortName )
buf .PutString (b .Title )
buf .PutString (b .Description )
if b .Photo == nil {
return fmt .Errorf ("unable to encode botApp#95fcd1d6: field photo is nil" )
}
if err := b .Photo .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode botApp#95fcd1d6: field photo: %w" , err )
}
if b .Flags .Has (0 ) {
if b .Document == nil {
return fmt .Errorf ("unable to encode botApp#95fcd1d6: field document is nil" )
}
if err := b .Document .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode botApp#95fcd1d6: field document: %w" , err )
}
}
buf .PutLong (b .Hash )
return nil
}
func (b *BotApp ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode botApp#95fcd1d6 to nil" )
}
if err := buf .ConsumeID (BotAppTypeID ); err != nil {
return fmt .Errorf ("unable to decode botApp#95fcd1d6: %w" , err )
}
return b .DecodeBare (buf )
}
func (b *BotApp ) DecodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode botApp#95fcd1d6 to nil" )
}
{
if err := b .Flags .Decode (buf ); err != nil {
return fmt .Errorf ("unable to decode botApp#95fcd1d6: field flags: %w" , err )
}
}
{
value , err := buf .Long ()
if err != nil {
return fmt .Errorf ("unable to decode botApp#95fcd1d6: field id: %w" , err )
}
b .ID = value
}
{
value , err := buf .Long ()
if err != nil {
return fmt .Errorf ("unable to decode botApp#95fcd1d6: field access_hash: %w" , err )
}
b .AccessHash = value
}
{
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode botApp#95fcd1d6: field short_name: %w" , err )
}
b .ShortName = value
}
{
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode botApp#95fcd1d6: field title: %w" , err )
}
b .Title = value
}
{
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode botApp#95fcd1d6: field description: %w" , err )
}
b .Description = value
}
{
value , err := DecodePhoto (buf )
if err != nil {
return fmt .Errorf ("unable to decode botApp#95fcd1d6: field photo: %w" , err )
}
b .Photo = value
}
if b .Flags .Has (0 ) {
value , err := DecodeDocument (buf )
if err != nil {
return fmt .Errorf ("unable to decode botApp#95fcd1d6: field document: %w" , err )
}
b .Document = value
}
{
value , err := buf .Long ()
if err != nil {
return fmt .Errorf ("unable to decode botApp#95fcd1d6: field hash: %w" , err )
}
b .Hash = value
}
return nil
}
func (b *BotApp ) GetID () (value int64 ) {
if b == nil {
return
}
return b .ID
}
func (b *BotApp ) GetAccessHash () (value int64 ) {
if b == nil {
return
}
return b .AccessHash
}
func (b *BotApp ) GetShortName () (value string ) {
if b == nil {
return
}
return b .ShortName
}
func (b *BotApp ) GetTitle () (value string ) {
if b == nil {
return
}
return b .Title
}
func (b *BotApp ) GetDescription () (value string ) {
if b == nil {
return
}
return b .Description
}
func (b *BotApp ) GetPhoto () (value PhotoClass ) {
if b == nil {
return
}
return b .Photo
}
func (b *BotApp ) SetDocument (value DocumentClass ) {
b .Flags .Set (0 )
b .Document = value
}
func (b *BotApp ) GetDocument () (value DocumentClass , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (0 ) {
return value , false
}
return b .Document , true
}
func (b *BotApp ) GetHash () (value int64 ) {
if b == nil {
return
}
return b .Hash
}
const BotAppClassName = "BotApp"
type BotAppClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () BotAppClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsModified () (*BotApp , bool )
}
func (b *BotApp ) AsInputBotAppID () *InputBotAppID {
value := new (InputBotAppID )
value .ID = b .GetID ()
value .AccessHash = b .GetAccessHash ()
value .AccessHash = b .GetHash ()
return value
}
func (b *BotAppNotModified ) AsModified () (*BotApp , bool ) {
return nil , false
}
func (b *BotApp ) AsModified () (*BotApp , bool ) {
return b , true
}
func DecodeBotApp (buf *bin .Buffer ) (BotAppClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case BotAppNotModifiedTypeID :
v := BotAppNotModified {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode BotAppClass: %w" , err )
}
return &v , nil
case BotAppTypeID :
v := BotApp {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode BotAppClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode BotAppClass: %w" , bin .NewUnexpectedID (id ))
}
}
type BotAppBox struct {
BotApp BotAppClass
}
func (b *BotAppBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode BotAppBox to nil" )
}
v , err := DecodeBotApp (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .BotApp = v
return nil
}
func (b *BotAppBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .BotApp == nil {
return fmt .Errorf ("unable to encode BotAppClass as nil" )
}
return b .BotApp .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 .