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 InputGameID struct {
ID int64
AccessHash int64
}
const InputGameIDTypeID = 0x32c3e77
func (i InputGameID ) construct () InputGameClass { return &i }
var (
_ bin .Encoder = &InputGameID {}
_ bin .Decoder = &InputGameID {}
_ bin .BareEncoder = &InputGameID {}
_ bin .BareDecoder = &InputGameID {}
_ InputGameClass = &InputGameID {}
)
func (i *InputGameID ) Zero () bool {
if i == nil {
return true
}
if !(i .ID == 0 ) {
return false
}
if !(i .AccessHash == 0 ) {
return false
}
return true
}
func (i *InputGameID ) String () string {
if i == nil {
return "InputGameID(nil)"
}
type Alias InputGameID
return fmt .Sprintf ("InputGameID%+v" , Alias (*i ))
}
func (i *InputGameID ) FillFrom (from interface {
GetID () (value int64 )
GetAccessHash () (value int64 )
}) {
i .ID = from .GetID ()
i .AccessHash = from .GetAccessHash ()
}
func (*InputGameID ) TypeID () uint32 {
return InputGameIDTypeID
}
func (*InputGameID ) TypeName () string {
return "inputGameID"
}
func (i *InputGameID ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputGameID" ,
ID : InputGameIDTypeID ,
}
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 *InputGameID ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputGameID#32c3e77 as nil" )
}
b .PutID (InputGameIDTypeID )
return i .EncodeBare (b )
}
func (i *InputGameID ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputGameID#32c3e77 as nil" )
}
b .PutLong (i .ID )
b .PutLong (i .AccessHash )
return nil
}
func (i *InputGameID ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputGameID#32c3e77 to nil" )
}
if err := b .ConsumeID (InputGameIDTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputGameID#32c3e77: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputGameID ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputGameID#32c3e77 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputGameID#32c3e77: field id: %w" , err )
}
i .ID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputGameID#32c3e77: field access_hash: %w" , err )
}
i .AccessHash = value
}
return nil
}
func (i *InputGameID ) GetID () (value int64 ) {
if i == nil {
return
}
return i .ID
}
func (i *InputGameID ) GetAccessHash () (value int64 ) {
if i == nil {
return
}
return i .AccessHash
}
type InputGameShortName struct {
BotID InputUserClass
ShortName string
}
const InputGameShortNameTypeID = 0xc331e80a
func (i InputGameShortName ) construct () InputGameClass { return &i }
var (
_ bin .Encoder = &InputGameShortName {}
_ bin .Decoder = &InputGameShortName {}
_ bin .BareEncoder = &InputGameShortName {}
_ bin .BareDecoder = &InputGameShortName {}
_ InputGameClass = &InputGameShortName {}
)
func (i *InputGameShortName ) Zero () bool {
if i == nil {
return true
}
if !(i .BotID == nil ) {
return false
}
if !(i .ShortName == "" ) {
return false
}
return true
}
func (i *InputGameShortName ) String () string {
if i == nil {
return "InputGameShortName(nil)"
}
type Alias InputGameShortName
return fmt .Sprintf ("InputGameShortName%+v" , Alias (*i ))
}
func (i *InputGameShortName ) FillFrom (from interface {
GetBotID () (value InputUserClass )
GetShortName () (value string )
}) {
i .BotID = from .GetBotID ()
i .ShortName = from .GetShortName ()
}
func (*InputGameShortName ) TypeID () uint32 {
return InputGameShortNameTypeID
}
func (*InputGameShortName ) TypeName () string {
return "inputGameShortName"
}
func (i *InputGameShortName ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputGameShortName" ,
ID : InputGameShortNameTypeID ,
}
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 *InputGameShortName ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputGameShortName#c331e80a as nil" )
}
b .PutID (InputGameShortNameTypeID )
return i .EncodeBare (b )
}
func (i *InputGameShortName ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputGameShortName#c331e80a as nil" )
}
if i .BotID == nil {
return fmt .Errorf ("unable to encode inputGameShortName#c331e80a: field bot_id is nil" )
}
if err := i .BotID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputGameShortName#c331e80a: field bot_id: %w" , err )
}
b .PutString (i .ShortName )
return nil
}
func (i *InputGameShortName ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputGameShortName#c331e80a to nil" )
}
if err := b .ConsumeID (InputGameShortNameTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputGameShortName#c331e80a: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputGameShortName ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputGameShortName#c331e80a to nil" )
}
{
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode inputGameShortName#c331e80a: field bot_id: %w" , err )
}
i .BotID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputGameShortName#c331e80a: field short_name: %w" , err )
}
i .ShortName = value
}
return nil
}
func (i *InputGameShortName ) GetBotID () (value InputUserClass ) {
if i == nil {
return
}
return i .BotID
}
func (i *InputGameShortName ) GetShortName () (value string ) {
if i == nil {
return
}
return i .ShortName
}
const InputGameClassName = "InputGame"
type InputGameClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () InputGameClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeInputGame (buf *bin .Buffer ) (InputGameClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case InputGameIDTypeID :
v := InputGameID {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputGameClass: %w" , err )
}
return &v , nil
case InputGameShortNameTypeID :
v := InputGameShortName {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputGameClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode InputGameClass: %w" , bin .NewUnexpectedID (id ))
}
}
type InputGameBox struct {
InputGame InputGameClass
}
func (b *InputGameBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode InputGameBox to nil" )
}
v , err := DecodeInputGame (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .InputGame = v
return nil
}
func (b *InputGameBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .InputGame == nil {
return fmt .Errorf ("unable to encode InputGameClass as nil" )
}
return b .InputGame .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 .