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 InputBotAppID struct {
ID int64
AccessHash int64
}
const InputBotAppIDTypeID = 0xa920bd7a
func (i InputBotAppID ) construct () InputBotAppClass { return &i }
var (
_ bin .Encoder = &InputBotAppID {}
_ bin .Decoder = &InputBotAppID {}
_ bin .BareEncoder = &InputBotAppID {}
_ bin .BareDecoder = &InputBotAppID {}
_ InputBotAppClass = &InputBotAppID {}
)
func (i *InputBotAppID ) Zero () bool {
if i == nil {
return true
}
if !(i .ID == 0 ) {
return false
}
if !(i .AccessHash == 0 ) {
return false
}
return true
}
func (i *InputBotAppID ) String () string {
if i == nil {
return "InputBotAppID(nil)"
}
type Alias InputBotAppID
return fmt .Sprintf ("InputBotAppID%+v" , Alias (*i ))
}
func (i *InputBotAppID ) FillFrom (from interface {
GetID () (value int64 )
GetAccessHash () (value int64 )
}) {
i .ID = from .GetID ()
i .AccessHash = from .GetAccessHash ()
}
func (*InputBotAppID ) TypeID () uint32 {
return InputBotAppIDTypeID
}
func (*InputBotAppID ) TypeName () string {
return "inputBotAppID"
}
func (i *InputBotAppID ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputBotAppID" ,
ID : InputBotAppIDTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "AccessHash" ,
SchemaName : "access_hash" ,
},
}
return typ
}
func (i *InputBotAppID ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputBotAppID#a920bd7a as nil" )
}
b .PutID (InputBotAppIDTypeID )
return i .EncodeBare (b )
}
func (i *InputBotAppID ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputBotAppID#a920bd7a as nil" )
}
b .PutLong (i .ID )
b .PutLong (i .AccessHash )
return nil
}
func (i *InputBotAppID ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputBotAppID#a920bd7a to nil" )
}
if err := b .ConsumeID (InputBotAppIDTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputBotAppID#a920bd7a: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputBotAppID ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputBotAppID#a920bd7a to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputBotAppID#a920bd7a: field id: %w" , err )
}
i .ID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputBotAppID#a920bd7a: field access_hash: %w" , err )
}
i .AccessHash = value
}
return nil
}
func (i *InputBotAppID ) GetID () (value int64 ) {
if i == nil {
return
}
return i .ID
}
func (i *InputBotAppID ) GetAccessHash () (value int64 ) {
if i == nil {
return
}
return i .AccessHash
}
type InputBotAppShortName struct {
BotID InputUserClass
ShortName string
}
const InputBotAppShortNameTypeID = 0x908c0407
func (i InputBotAppShortName ) construct () InputBotAppClass { return &i }
var (
_ bin .Encoder = &InputBotAppShortName {}
_ bin .Decoder = &InputBotAppShortName {}
_ bin .BareEncoder = &InputBotAppShortName {}
_ bin .BareDecoder = &InputBotAppShortName {}
_ InputBotAppClass = &InputBotAppShortName {}
)
func (i *InputBotAppShortName ) Zero () bool {
if i == nil {
return true
}
if !(i .BotID == nil ) {
return false
}
if !(i .ShortName == "" ) {
return false
}
return true
}
func (i *InputBotAppShortName ) String () string {
if i == nil {
return "InputBotAppShortName(nil)"
}
type Alias InputBotAppShortName
return fmt .Sprintf ("InputBotAppShortName%+v" , Alias (*i ))
}
func (i *InputBotAppShortName ) FillFrom (from interface {
GetBotID () (value InputUserClass )
GetShortName () (value string )
}) {
i .BotID = from .GetBotID ()
i .ShortName = from .GetShortName ()
}
func (*InputBotAppShortName ) TypeID () uint32 {
return InputBotAppShortNameTypeID
}
func (*InputBotAppShortName ) TypeName () string {
return "inputBotAppShortName"
}
func (i *InputBotAppShortName ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputBotAppShortName" ,
ID : InputBotAppShortNameTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "BotID" ,
SchemaName : "bot_id" ,
},
{
Name : "ShortName" ,
SchemaName : "short_name" ,
},
}
return typ
}
func (i *InputBotAppShortName ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputBotAppShortName#908c0407 as nil" )
}
b .PutID (InputBotAppShortNameTypeID )
return i .EncodeBare (b )
}
func (i *InputBotAppShortName ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputBotAppShortName#908c0407 as nil" )
}
if i .BotID == nil {
return fmt .Errorf ("unable to encode inputBotAppShortName#908c0407: field bot_id is nil" )
}
if err := i .BotID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputBotAppShortName#908c0407: field bot_id: %w" , err )
}
b .PutString (i .ShortName )
return nil
}
func (i *InputBotAppShortName ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputBotAppShortName#908c0407 to nil" )
}
if err := b .ConsumeID (InputBotAppShortNameTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputBotAppShortName#908c0407: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputBotAppShortName ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputBotAppShortName#908c0407 to nil" )
}
{
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode inputBotAppShortName#908c0407: field bot_id: %w" , err )
}
i .BotID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputBotAppShortName#908c0407: field short_name: %w" , err )
}
i .ShortName = value
}
return nil
}
func (i *InputBotAppShortName ) GetBotID () (value InputUserClass ) {
if i == nil {
return
}
return i .BotID
}
func (i *InputBotAppShortName ) GetShortName () (value string ) {
if i == nil {
return
}
return i .ShortName
}
const InputBotAppClassName = "InputBotApp"
type InputBotAppClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () InputBotAppClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeInputBotApp (buf *bin .Buffer ) (InputBotAppClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case InputBotAppIDTypeID :
v := InputBotAppID {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputBotAppClass: %w" , err )
}
return &v , nil
case InputBotAppShortNameTypeID :
v := InputBotAppShortName {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputBotAppClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode InputBotAppClass: %w" , bin .NewUnexpectedID (id ))
}
}
type InputBotAppBox struct {
InputBotApp InputBotAppClass
}
func (b *InputBotAppBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode InputBotAppBox to nil" )
}
v , err := DecodeInputBotApp (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .InputBotApp = v
return nil
}
func (b *InputBotAppBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .InputBotApp == nil {
return fmt .Errorf ("unable to encode InputBotAppClass as nil" )
}
return b .InputBotApp .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 .