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 BotMenuButtonDefault struct {
}
const BotMenuButtonDefaultTypeID = 0x7533a588
func (b BotMenuButtonDefault ) construct () BotMenuButtonClass { return &b }
var (
_ bin .Encoder = &BotMenuButtonDefault {}
_ bin .Decoder = &BotMenuButtonDefault {}
_ bin .BareEncoder = &BotMenuButtonDefault {}
_ bin .BareDecoder = &BotMenuButtonDefault {}
_ BotMenuButtonClass = &BotMenuButtonDefault {}
)
func (b *BotMenuButtonDefault ) Zero () bool {
if b == nil {
return true
}
return true
}
func (b *BotMenuButtonDefault ) String () string {
if b == nil {
return "BotMenuButtonDefault(nil)"
}
type Alias BotMenuButtonDefault
return fmt .Sprintf ("BotMenuButtonDefault%+v" , Alias (*b ))
}
func (*BotMenuButtonDefault ) TypeID () uint32 {
return BotMenuButtonDefaultTypeID
}
func (*BotMenuButtonDefault ) TypeName () string {
return "botMenuButtonDefault"
}
func (b *BotMenuButtonDefault ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "botMenuButtonDefault" ,
ID : BotMenuButtonDefaultTypeID ,
}
if b == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (b *BotMenuButtonDefault ) Encode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode botMenuButtonDefault#7533a588 as nil" )
}
buf .PutID (BotMenuButtonDefaultTypeID )
return b .EncodeBare (buf )
}
func (b *BotMenuButtonDefault ) EncodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode botMenuButtonDefault#7533a588 as nil" )
}
return nil
}
func (b *BotMenuButtonDefault ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode botMenuButtonDefault#7533a588 to nil" )
}
if err := buf .ConsumeID (BotMenuButtonDefaultTypeID ); err != nil {
return fmt .Errorf ("unable to decode botMenuButtonDefault#7533a588: %w" , err )
}
return b .DecodeBare (buf )
}
func (b *BotMenuButtonDefault ) DecodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode botMenuButtonDefault#7533a588 to nil" )
}
return nil
}
type BotMenuButtonCommands struct {
}
const BotMenuButtonCommandsTypeID = 0x4258c205
func (b BotMenuButtonCommands ) construct () BotMenuButtonClass { return &b }
var (
_ bin .Encoder = &BotMenuButtonCommands {}
_ bin .Decoder = &BotMenuButtonCommands {}
_ bin .BareEncoder = &BotMenuButtonCommands {}
_ bin .BareDecoder = &BotMenuButtonCommands {}
_ BotMenuButtonClass = &BotMenuButtonCommands {}
)
func (b *BotMenuButtonCommands ) Zero () bool {
if b == nil {
return true
}
return true
}
func (b *BotMenuButtonCommands ) String () string {
if b == nil {
return "BotMenuButtonCommands(nil)"
}
type Alias BotMenuButtonCommands
return fmt .Sprintf ("BotMenuButtonCommands%+v" , Alias (*b ))
}
func (*BotMenuButtonCommands ) TypeID () uint32 {
return BotMenuButtonCommandsTypeID
}
func (*BotMenuButtonCommands ) TypeName () string {
return "botMenuButtonCommands"
}
func (b *BotMenuButtonCommands ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "botMenuButtonCommands" ,
ID : BotMenuButtonCommandsTypeID ,
}
if b == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (b *BotMenuButtonCommands ) Encode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode botMenuButtonCommands#4258c205 as nil" )
}
buf .PutID (BotMenuButtonCommandsTypeID )
return b .EncodeBare (buf )
}
func (b *BotMenuButtonCommands ) EncodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode botMenuButtonCommands#4258c205 as nil" )
}
return nil
}
func (b *BotMenuButtonCommands ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode botMenuButtonCommands#4258c205 to nil" )
}
if err := buf .ConsumeID (BotMenuButtonCommandsTypeID ); err != nil {
return fmt .Errorf ("unable to decode botMenuButtonCommands#4258c205: %w" , err )
}
return b .DecodeBare (buf )
}
func (b *BotMenuButtonCommands ) DecodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode botMenuButtonCommands#4258c205 to nil" )
}
return nil
}
type BotMenuButton struct {
Text string
URL string
}
const BotMenuButtonTypeID = 0xc7b57ce6
func (b BotMenuButton ) construct () BotMenuButtonClass { return &b }
var (
_ bin .Encoder = &BotMenuButton {}
_ bin .Decoder = &BotMenuButton {}
_ bin .BareEncoder = &BotMenuButton {}
_ bin .BareDecoder = &BotMenuButton {}
_ BotMenuButtonClass = &BotMenuButton {}
)
func (b *BotMenuButton ) Zero () bool {
if b == nil {
return true
}
if !(b .Text == "" ) {
return false
}
if !(b .URL == "" ) {
return false
}
return true
}
func (b *BotMenuButton ) String () string {
if b == nil {
return "BotMenuButton(nil)"
}
type Alias BotMenuButton
return fmt .Sprintf ("BotMenuButton%+v" , Alias (*b ))
}
func (b *BotMenuButton ) FillFrom (from interface {
GetText () (value string )
GetURL () (value string )
}) {
b .Text = from .GetText ()
b .URL = from .GetURL ()
}
func (*BotMenuButton ) TypeID () uint32 {
return BotMenuButtonTypeID
}
func (*BotMenuButton ) TypeName () string {
return "botMenuButton"
}
func (b *BotMenuButton ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "botMenuButton" ,
ID : BotMenuButtonTypeID ,
}
if b == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Text" ,
SchemaName : "text" ,
},
{
Name : "URL" ,
SchemaName : "url" ,
},
}
return typ
}
func (b *BotMenuButton ) Encode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode botMenuButton#c7b57ce6 as nil" )
}
buf .PutID (BotMenuButtonTypeID )
return b .EncodeBare (buf )
}
func (b *BotMenuButton ) EncodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode botMenuButton#c7b57ce6 as nil" )
}
buf .PutString (b .Text )
buf .PutString (b .URL )
return nil
}
func (b *BotMenuButton ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode botMenuButton#c7b57ce6 to nil" )
}
if err := buf .ConsumeID (BotMenuButtonTypeID ); err != nil {
return fmt .Errorf ("unable to decode botMenuButton#c7b57ce6: %w" , err )
}
return b .DecodeBare (buf )
}
func (b *BotMenuButton ) DecodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode botMenuButton#c7b57ce6 to nil" )
}
{
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode botMenuButton#c7b57ce6: field text: %w" , err )
}
b .Text = value
}
{
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode botMenuButton#c7b57ce6: field url: %w" , err )
}
b .URL = value
}
return nil
}
func (b *BotMenuButton ) GetText () (value string ) {
if b == nil {
return
}
return b .Text
}
func (b *BotMenuButton ) GetURL () (value string ) {
if b == nil {
return
}
return b .URL
}
const BotMenuButtonClassName = "BotMenuButton"
type BotMenuButtonClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () BotMenuButtonClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeBotMenuButton (buf *bin .Buffer ) (BotMenuButtonClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case BotMenuButtonDefaultTypeID :
v := BotMenuButtonDefault {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode BotMenuButtonClass: %w" , err )
}
return &v , nil
case BotMenuButtonCommandsTypeID :
v := BotMenuButtonCommands {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode BotMenuButtonClass: %w" , err )
}
return &v , nil
case BotMenuButtonTypeID :
v := BotMenuButton {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode BotMenuButtonClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode BotMenuButtonClass: %w" , bin .NewUnexpectedID (id ))
}
}
type BotMenuButtonBox struct {
BotMenuButton BotMenuButtonClass
}
func (b *BotMenuButtonBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode BotMenuButtonBox to nil" )
}
v , err := DecodeBotMenuButton (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .BotMenuButton = v
return nil
}
func (b *BotMenuButtonBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .BotMenuButton == nil {
return fmt .Errorf ("unable to encode BotMenuButtonClass as nil" )
}
return b .BotMenuButton .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 .