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 MessagesGetBotCallbackAnswerRequest struct {
Flags bin .Fields
Game bool
Peer InputPeerClass
MsgID int
Data []byte
Password InputCheckPasswordSRPClass
}
const MessagesGetBotCallbackAnswerRequestTypeID = 0x9342ca07
var (
_ bin .Encoder = &MessagesGetBotCallbackAnswerRequest {}
_ bin .Decoder = &MessagesGetBotCallbackAnswerRequest {}
_ bin .BareEncoder = &MessagesGetBotCallbackAnswerRequest {}
_ bin .BareDecoder = &MessagesGetBotCallbackAnswerRequest {}
)
func (g *MessagesGetBotCallbackAnswerRequest ) Zero () bool {
if g == nil {
return true
}
if !(g .Flags .Zero ()) {
return false
}
if !(g .Game == false ) {
return false
}
if !(g .Peer == nil ) {
return false
}
if !(g .MsgID == 0 ) {
return false
}
if !(g .Data == nil ) {
return false
}
if !(g .Password == nil ) {
return false
}
return true
}
func (g *MessagesGetBotCallbackAnswerRequest ) String () string {
if g == nil {
return "MessagesGetBotCallbackAnswerRequest(nil)"
}
type Alias MessagesGetBotCallbackAnswerRequest
return fmt .Sprintf ("MessagesGetBotCallbackAnswerRequest%+v" , Alias (*g ))
}
func (g *MessagesGetBotCallbackAnswerRequest ) FillFrom (from interface {
GetGame () (value bool )
GetPeer () (value InputPeerClass )
GetMsgID () (value int )
GetData () (value []byte , ok bool )
GetPassword () (value InputCheckPasswordSRPClass , ok bool )
}) {
g .Game = from .GetGame ()
g .Peer = from .GetPeer ()
g .MsgID = from .GetMsgID ()
if val , ok := from .GetData (); ok {
g .Data = val
}
if val , ok := from .GetPassword (); ok {
g .Password = val
}
}
func (*MessagesGetBotCallbackAnswerRequest ) TypeID () uint32 {
return MessagesGetBotCallbackAnswerRequestTypeID
}
func (*MessagesGetBotCallbackAnswerRequest ) TypeName () string {
return "messages.getBotCallbackAnswer"
}
func (g *MessagesGetBotCallbackAnswerRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.getBotCallbackAnswer" ,
ID : MessagesGetBotCallbackAnswerRequestTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Game" ,
SchemaName : "game" ,
Null : !g .Flags .Has (1 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "MsgID" ,
SchemaName : "msg_id" ,
},
{
Name : "Data" ,
SchemaName : "data" ,
Null : !g .Flags .Has (0 ),
},
{
Name : "Password" ,
SchemaName : "password" ,
Null : !g .Flags .Has (2 ),
},
}
return typ
}
func (g *MessagesGetBotCallbackAnswerRequest ) SetFlags () {
if !(g .Game == false ) {
g .Flags .Set (1 )
}
if !(g .Data == nil ) {
g .Flags .Set (0 )
}
if !(g .Password == nil ) {
g .Flags .Set (2 )
}
}
func (g *MessagesGetBotCallbackAnswerRequest ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode messages.getBotCallbackAnswer#9342ca07 as nil" )
}
b .PutID (MessagesGetBotCallbackAnswerRequestTypeID )
return g .EncodeBare (b )
}
func (g *MessagesGetBotCallbackAnswerRequest ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode messages.getBotCallbackAnswer#9342ca07 as nil" )
}
g .SetFlags ()
if err := g .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.getBotCallbackAnswer#9342ca07: field flags: %w" , err )
}
if g .Peer == nil {
return fmt .Errorf ("unable to encode messages.getBotCallbackAnswer#9342ca07: field peer is nil" )
}
if err := g .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.getBotCallbackAnswer#9342ca07: field peer: %w" , err )
}
b .PutInt (g .MsgID )
if g .Flags .Has (0 ) {
b .PutBytes (g .Data )
}
if g .Flags .Has (2 ) {
if g .Password == nil {
return fmt .Errorf ("unable to encode messages.getBotCallbackAnswer#9342ca07: field password is nil" )
}
if err := g .Password .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.getBotCallbackAnswer#9342ca07: field password: %w" , err )
}
}
return nil
}
func (g *MessagesGetBotCallbackAnswerRequest ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode messages.getBotCallbackAnswer#9342ca07 to nil" )
}
if err := b .ConsumeID (MessagesGetBotCallbackAnswerRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.getBotCallbackAnswer#9342ca07: %w" , err )
}
return g .DecodeBare (b )
}
func (g *MessagesGetBotCallbackAnswerRequest ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode messages.getBotCallbackAnswer#9342ca07 to nil" )
}
{
if err := g .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.getBotCallbackAnswer#9342ca07: field flags: %w" , err )
}
}
g .Game = g .Flags .Has (1 )
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.getBotCallbackAnswer#9342ca07: field peer: %w" , err )
}
g .Peer = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.getBotCallbackAnswer#9342ca07: field msg_id: %w" , err )
}
g .MsgID = value
}
if g .Flags .Has (0 ) {
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode messages.getBotCallbackAnswer#9342ca07: field data: %w" , err )
}
g .Data = value
}
if g .Flags .Has (2 ) {
value , err := DecodeInputCheckPasswordSRP (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.getBotCallbackAnswer#9342ca07: field password: %w" , err )
}
g .Password = value
}
return nil
}
func (g *MessagesGetBotCallbackAnswerRequest ) SetGame (value bool ) {
if value {
g .Flags .Set (1 )
g .Game = true
} else {
g .Flags .Unset (1 )
g .Game = false
}
}
func (g *MessagesGetBotCallbackAnswerRequest ) GetGame () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (1 )
}
func (g *MessagesGetBotCallbackAnswerRequest ) GetPeer () (value InputPeerClass ) {
if g == nil {
return
}
return g .Peer
}
func (g *MessagesGetBotCallbackAnswerRequest ) GetMsgID () (value int ) {
if g == nil {
return
}
return g .MsgID
}
func (g *MessagesGetBotCallbackAnswerRequest ) SetData (value []byte ) {
g .Flags .Set (0 )
g .Data = value
}
func (g *MessagesGetBotCallbackAnswerRequest ) GetData () (value []byte , ok bool ) {
if g == nil {
return
}
if !g .Flags .Has (0 ) {
return value , false
}
return g .Data , true
}
func (g *MessagesGetBotCallbackAnswerRequest ) SetPassword (value InputCheckPasswordSRPClass ) {
g .Flags .Set (2 )
g .Password = value
}
func (g *MessagesGetBotCallbackAnswerRequest ) GetPassword () (value InputCheckPasswordSRPClass , ok bool ) {
if g == nil {
return
}
if !g .Flags .Has (2 ) {
return value , false
}
return g .Password , true
}
func (g *MessagesGetBotCallbackAnswerRequest ) GetPasswordAsNotEmpty () (*InputCheckPasswordSRP , bool ) {
if value , ok := g .GetPassword (); ok {
return value .AsNotEmpty ()
}
return nil , false
}
func (c *Client ) MessagesGetBotCallbackAnswer (ctx context .Context , request *MessagesGetBotCallbackAnswerRequest ) (*MessagesBotCallbackAnswer , error ) {
var result MessagesBotCallbackAnswer
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return &result , 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 .