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 KeyboardInlineButton struct {
Flags bin .Fields
Style KeyboardButtonStyle
Text string
Type InlineButtonTypeClass
}
const KeyboardInlineButtonTypeID = 0x11c1a322
var (
_ bin .Encoder = &KeyboardInlineButton {}
_ bin .Decoder = &KeyboardInlineButton {}
_ bin .BareEncoder = &KeyboardInlineButton {}
_ bin .BareDecoder = &KeyboardInlineButton {}
)
func (k *KeyboardInlineButton ) Zero () bool {
if k == nil {
return true
}
if !(k .Flags .Zero ()) {
return false
}
if !(k .Style .Zero ()) {
return false
}
if !(k .Text == "" ) {
return false
}
if !(k .Type == nil ) {
return false
}
return true
}
func (k *KeyboardInlineButton ) String () string {
if k == nil {
return "KeyboardInlineButton(nil)"
}
type Alias KeyboardInlineButton
return fmt .Sprintf ("KeyboardInlineButton%+v" , Alias (*k ))
}
func (k *KeyboardInlineButton ) FillFrom (from interface {
GetStyle () (value KeyboardButtonStyle , ok bool )
GetText () (value string )
GetType () (value InlineButtonTypeClass )
}) {
if val , ok := from .GetStyle (); ok {
k .Style = val
}
k .Text = from .GetText ()
k .Type = from .GetType ()
}
func (*KeyboardInlineButton ) TypeID () uint32 {
return KeyboardInlineButtonTypeID
}
func (*KeyboardInlineButton ) TypeName () string {
return "keyboardInlineButton"
}
func (k *KeyboardInlineButton ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "keyboardInlineButton" ,
ID : KeyboardInlineButtonTypeID ,
}
if k == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Style" ,
SchemaName : "style" ,
Null : !k .Flags .Has (10 ),
},
{
Name : "Text" ,
SchemaName : "text" ,
},
{
Name : "Type" ,
SchemaName : "type" ,
},
}
return typ
}
func (k *KeyboardInlineButton ) SetFlags () {
if !(k .Style .Zero ()) {
k .Flags .Set (10 )
}
}
func (k *KeyboardInlineButton ) Encode (b *bin .Buffer ) error {
if k == nil {
return fmt .Errorf ("can't encode keyboardInlineButton#11c1a322 as nil" )
}
b .PutID (KeyboardInlineButtonTypeID )
return k .EncodeBare (b )
}
func (k *KeyboardInlineButton ) EncodeBare (b *bin .Buffer ) error {
if k == nil {
return fmt .Errorf ("can't encode keyboardInlineButton#11c1a322 as nil" )
}
k .SetFlags ()
if err := k .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode keyboardInlineButton#11c1a322: field flags: %w" , err )
}
if k .Flags .Has (10 ) {
if err := k .Style .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode keyboardInlineButton#11c1a322: field style: %w" , err )
}
}
b .PutString (k .Text )
if k .Type == nil {
return fmt .Errorf ("unable to encode keyboardInlineButton#11c1a322: field type is nil" )
}
if err := k .Type .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode keyboardInlineButton#11c1a322: field type: %w" , err )
}
return nil
}
func (k *KeyboardInlineButton ) Decode (b *bin .Buffer ) error {
if k == nil {
return fmt .Errorf ("can't decode keyboardInlineButton#11c1a322 to nil" )
}
if err := b .ConsumeID (KeyboardInlineButtonTypeID ); err != nil {
return fmt .Errorf ("unable to decode keyboardInlineButton#11c1a322: %w" , err )
}
return k .DecodeBare (b )
}
func (k *KeyboardInlineButton ) DecodeBare (b *bin .Buffer ) error {
if k == nil {
return fmt .Errorf ("can't decode keyboardInlineButton#11c1a322 to nil" )
}
{
if err := k .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode keyboardInlineButton#11c1a322: field flags: %w" , err )
}
}
if k .Flags .Has (10 ) {
if err := k .Style .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode keyboardInlineButton#11c1a322: field style: %w" , err )
}
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode keyboardInlineButton#11c1a322: field text: %w" , err )
}
k .Text = value
}
{
value , err := DecodeInlineButtonType (b )
if err != nil {
return fmt .Errorf ("unable to decode keyboardInlineButton#11c1a322: field type: %w" , err )
}
k .Type = value
}
return nil
}
func (k *KeyboardInlineButton ) SetStyle (value KeyboardButtonStyle ) {
k .Flags .Set (10 )
k .Style = value
}
func (k *KeyboardInlineButton ) GetStyle () (value KeyboardButtonStyle , ok bool ) {
if k == nil {
return
}
if !k .Flags .Has (10 ) {
return value , false
}
return k .Style , true
}
func (k *KeyboardInlineButton ) GetText () (value string ) {
if k == nil {
return
}
return k .Text
}
func (k *KeyboardInlineButton ) GetType () (value InlineButtonTypeClass ) {
if k == nil {
return
}
return k .Type
}
The pages are generated with Golds v0.8.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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .