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 BotsSetBotMenuButtonRequest struct {
UserID InputUserClass
Button BotMenuButtonClass
}
const BotsSetBotMenuButtonRequestTypeID = 0x4504d54f
var (
_ bin .Encoder = &BotsSetBotMenuButtonRequest {}
_ bin .Decoder = &BotsSetBotMenuButtonRequest {}
_ bin .BareEncoder = &BotsSetBotMenuButtonRequest {}
_ bin .BareDecoder = &BotsSetBotMenuButtonRequest {}
)
func (s *BotsSetBotMenuButtonRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .UserID == nil ) {
return false
}
if !(s .Button == nil ) {
return false
}
return true
}
func (s *BotsSetBotMenuButtonRequest ) String () string {
if s == nil {
return "BotsSetBotMenuButtonRequest(nil)"
}
type Alias BotsSetBotMenuButtonRequest
return fmt .Sprintf ("BotsSetBotMenuButtonRequest%+v" , Alias (*s ))
}
func (s *BotsSetBotMenuButtonRequest ) FillFrom (from interface {
GetUserID () (value InputUserClass )
GetButton () (value BotMenuButtonClass )
}) {
s .UserID = from .GetUserID ()
s .Button = from .GetButton ()
}
func (*BotsSetBotMenuButtonRequest ) TypeID () uint32 {
return BotsSetBotMenuButtonRequestTypeID
}
func (*BotsSetBotMenuButtonRequest ) TypeName () string {
return "bots.setBotMenuButton"
}
func (s *BotsSetBotMenuButtonRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "bots.setBotMenuButton" ,
ID : BotsSetBotMenuButtonRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "UserID" ,
SchemaName : "user_id" ,
},
{
Name : "Button" ,
SchemaName : "button" ,
},
}
return typ
}
func (s *BotsSetBotMenuButtonRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode bots.setBotMenuButton#4504d54f as nil" )
}
b .PutID (BotsSetBotMenuButtonRequestTypeID )
return s .EncodeBare (b )
}
func (s *BotsSetBotMenuButtonRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode bots.setBotMenuButton#4504d54f as nil" )
}
if s .UserID == nil {
return fmt .Errorf ("unable to encode bots.setBotMenuButton#4504d54f: field user_id is nil" )
}
if err := s .UserID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode bots.setBotMenuButton#4504d54f: field user_id: %w" , err )
}
if s .Button == nil {
return fmt .Errorf ("unable to encode bots.setBotMenuButton#4504d54f: field button is nil" )
}
if err := s .Button .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode bots.setBotMenuButton#4504d54f: field button: %w" , err )
}
return nil
}
func (s *BotsSetBotMenuButtonRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode bots.setBotMenuButton#4504d54f to nil" )
}
if err := b .ConsumeID (BotsSetBotMenuButtonRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode bots.setBotMenuButton#4504d54f: %w" , err )
}
return s .DecodeBare (b )
}
func (s *BotsSetBotMenuButtonRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode bots.setBotMenuButton#4504d54f to nil" )
}
{
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode bots.setBotMenuButton#4504d54f: field user_id: %w" , err )
}
s .UserID = value
}
{
value , err := DecodeBotMenuButton (b )
if err != nil {
return fmt .Errorf ("unable to decode bots.setBotMenuButton#4504d54f: field button: %w" , err )
}
s .Button = value
}
return nil
}
func (s *BotsSetBotMenuButtonRequest ) GetUserID () (value InputUserClass ) {
if s == nil {
return
}
return s .UserID
}
func (s *BotsSetBotMenuButtonRequest ) GetButton () (value BotMenuButtonClass ) {
if s == nil {
return
}
return s .Button
}
func (c *Client ) BotsSetBotMenuButton (ctx context .Context , request *BotsSetBotMenuButtonRequest ) (bool , error ) {
var result BoolBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return false , err
}
_ , ok := result .Bool .(*BoolTrue )
return ok , nil
}
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 .