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 KeyboardButtonStyle struct {
Flags bin .Fields
BgPrimary bool
BgDanger bool
BgSuccess bool
Icon int64
}
const KeyboardButtonStyleTypeID = 0x4fdd3430
var (
_ bin .Encoder = &KeyboardButtonStyle {}
_ bin .Decoder = &KeyboardButtonStyle {}
_ bin .BareEncoder = &KeyboardButtonStyle {}
_ bin .BareDecoder = &KeyboardButtonStyle {}
)
func (k *KeyboardButtonStyle ) Zero () bool {
if k == nil {
return true
}
if !(k .Flags .Zero ()) {
return false
}
if !(k .BgPrimary == false ) {
return false
}
if !(k .BgDanger == false ) {
return false
}
if !(k .BgSuccess == false ) {
return false
}
if !(k .Icon == 0 ) {
return false
}
return true
}
func (k *KeyboardButtonStyle ) String () string {
if k == nil {
return "KeyboardButtonStyle(nil)"
}
type Alias KeyboardButtonStyle
return fmt .Sprintf ("KeyboardButtonStyle%+v" , Alias (*k ))
}
func (k *KeyboardButtonStyle ) FillFrom (from interface {
GetBgPrimary () (value bool )
GetBgDanger () (value bool )
GetBgSuccess () (value bool )
GetIcon () (value int64 , ok bool )
}) {
k .BgPrimary = from .GetBgPrimary ()
k .BgDanger = from .GetBgDanger ()
k .BgSuccess = from .GetBgSuccess ()
if val , ok := from .GetIcon (); ok {
k .Icon = val
}
}
func (*KeyboardButtonStyle ) TypeID () uint32 {
return KeyboardButtonStyleTypeID
}
func (*KeyboardButtonStyle ) TypeName () string {
return "keyboardButtonStyle"
}
func (k *KeyboardButtonStyle ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "keyboardButtonStyle" ,
ID : KeyboardButtonStyleTypeID ,
}
if k == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "BgPrimary" ,
SchemaName : "bg_primary" ,
Null : !k .Flags .Has (0 ),
},
{
Name : "BgDanger" ,
SchemaName : "bg_danger" ,
Null : !k .Flags .Has (1 ),
},
{
Name : "BgSuccess" ,
SchemaName : "bg_success" ,
Null : !k .Flags .Has (2 ),
},
{
Name : "Icon" ,
SchemaName : "icon" ,
Null : !k .Flags .Has (3 ),
},
}
return typ
}
func (k *KeyboardButtonStyle ) SetFlags () {
if !(k .BgPrimary == false ) {
k .Flags .Set (0 )
}
if !(k .BgDanger == false ) {
k .Flags .Set (1 )
}
if !(k .BgSuccess == false ) {
k .Flags .Set (2 )
}
if !(k .Icon == 0 ) {
k .Flags .Set (3 )
}
}
func (k *KeyboardButtonStyle ) Encode (b *bin .Buffer ) error {
if k == nil {
return fmt .Errorf ("can't encode keyboardButtonStyle#4fdd3430 as nil" )
}
b .PutID (KeyboardButtonStyleTypeID )
return k .EncodeBare (b )
}
func (k *KeyboardButtonStyle ) EncodeBare (b *bin .Buffer ) error {
if k == nil {
return fmt .Errorf ("can't encode keyboardButtonStyle#4fdd3430 as nil" )
}
k .SetFlags ()
if err := k .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode keyboardButtonStyle#4fdd3430: field flags: %w" , err )
}
if k .Flags .Has (3 ) {
b .PutLong (k .Icon )
}
return nil
}
func (k *KeyboardButtonStyle ) Decode (b *bin .Buffer ) error {
if k == nil {
return fmt .Errorf ("can't decode keyboardButtonStyle#4fdd3430 to nil" )
}
if err := b .ConsumeID (KeyboardButtonStyleTypeID ); err != nil {
return fmt .Errorf ("unable to decode keyboardButtonStyle#4fdd3430: %w" , err )
}
return k .DecodeBare (b )
}
func (k *KeyboardButtonStyle ) DecodeBare (b *bin .Buffer ) error {
if k == nil {
return fmt .Errorf ("can't decode keyboardButtonStyle#4fdd3430 to nil" )
}
{
if err := k .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode keyboardButtonStyle#4fdd3430: field flags: %w" , err )
}
}
k .BgPrimary = k .Flags .Has (0 )
k .BgDanger = k .Flags .Has (1 )
k .BgSuccess = k .Flags .Has (2 )
if k .Flags .Has (3 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode keyboardButtonStyle#4fdd3430: field icon: %w" , err )
}
k .Icon = value
}
return nil
}
func (k *KeyboardButtonStyle ) SetBgPrimary (value bool ) {
if value {
k .Flags .Set (0 )
k .BgPrimary = true
} else {
k .Flags .Unset (0 )
k .BgPrimary = false
}
}
func (k *KeyboardButtonStyle ) GetBgPrimary () (value bool ) {
if k == nil {
return
}
return k .Flags .Has (0 )
}
func (k *KeyboardButtonStyle ) SetBgDanger (value bool ) {
if value {
k .Flags .Set (1 )
k .BgDanger = true
} else {
k .Flags .Unset (1 )
k .BgDanger = false
}
}
func (k *KeyboardButtonStyle ) GetBgDanger () (value bool ) {
if k == nil {
return
}
return k .Flags .Has (1 )
}
func (k *KeyboardButtonStyle ) SetBgSuccess (value bool ) {
if value {
k .Flags .Set (2 )
k .BgSuccess = true
} else {
k .Flags .Unset (2 )
k .BgSuccess = false
}
}
func (k *KeyboardButtonStyle ) GetBgSuccess () (value bool ) {
if k == nil {
return
}
return k .Flags .Has (2 )
}
func (k *KeyboardButtonStyle ) SetIcon (value int64 ) {
k .Flags .Set (3 )
k .Icon = value
}
func (k *KeyboardButtonStyle ) GetIcon () (value int64 , ok bool ) {
if k == nil {
return
}
if !k .Flags .Has (3 ) {
return value , false
}
return k .Icon , true
}
The pages are generated with Golds v0.8.4 . (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 .