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 BotsGetBotInfoRequest struct {
Flags bin .Fields
Bot InputUserClass
LangCode string
}
const BotsGetBotInfoRequestTypeID = 0xdcd914fd
var (
_ bin .Encoder = &BotsGetBotInfoRequest {}
_ bin .Decoder = &BotsGetBotInfoRequest {}
_ bin .BareEncoder = &BotsGetBotInfoRequest {}
_ bin .BareDecoder = &BotsGetBotInfoRequest {}
)
func (g *BotsGetBotInfoRequest ) Zero () bool {
if g == nil {
return true
}
if !(g .Flags .Zero ()) {
return false
}
if !(g .Bot == nil ) {
return false
}
if !(g .LangCode == "" ) {
return false
}
return true
}
func (g *BotsGetBotInfoRequest ) String () string {
if g == nil {
return "BotsGetBotInfoRequest(nil)"
}
type Alias BotsGetBotInfoRequest
return fmt .Sprintf ("BotsGetBotInfoRequest%+v" , Alias (*g ))
}
func (g *BotsGetBotInfoRequest ) FillFrom (from interface {
GetBot () (value InputUserClass , ok bool )
GetLangCode () (value string )
}) {
if val , ok := from .GetBot (); ok {
g .Bot = val
}
g .LangCode = from .GetLangCode ()
}
func (*BotsGetBotInfoRequest ) TypeID () uint32 {
return BotsGetBotInfoRequestTypeID
}
func (*BotsGetBotInfoRequest ) TypeName () string {
return "bots.getBotInfo"
}
func (g *BotsGetBotInfoRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "bots.getBotInfo" ,
ID : BotsGetBotInfoRequestTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Bot" ,
SchemaName : "bot" ,
Null : !g .Flags .Has (0 ),
},
{
Name : "LangCode" ,
SchemaName : "lang_code" ,
},
}
return typ
}
func (g *BotsGetBotInfoRequest ) SetFlags () {
if !(g .Bot == nil ) {
g .Flags .Set (0 )
}
}
func (g *BotsGetBotInfoRequest ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode bots.getBotInfo#dcd914fd as nil" )
}
b .PutID (BotsGetBotInfoRequestTypeID )
return g .EncodeBare (b )
}
func (g *BotsGetBotInfoRequest ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode bots.getBotInfo#dcd914fd as nil" )
}
g .SetFlags ()
if err := g .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode bots.getBotInfo#dcd914fd: field flags: %w" , err )
}
if g .Flags .Has (0 ) {
if g .Bot == nil {
return fmt .Errorf ("unable to encode bots.getBotInfo#dcd914fd: field bot is nil" )
}
if err := g .Bot .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode bots.getBotInfo#dcd914fd: field bot: %w" , err )
}
}
b .PutString (g .LangCode )
return nil
}
func (g *BotsGetBotInfoRequest ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode bots.getBotInfo#dcd914fd to nil" )
}
if err := b .ConsumeID (BotsGetBotInfoRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode bots.getBotInfo#dcd914fd: %w" , err )
}
return g .DecodeBare (b )
}
func (g *BotsGetBotInfoRequest ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode bots.getBotInfo#dcd914fd to nil" )
}
{
if err := g .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode bots.getBotInfo#dcd914fd: field flags: %w" , err )
}
}
if g .Flags .Has (0 ) {
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode bots.getBotInfo#dcd914fd: field bot: %w" , err )
}
g .Bot = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode bots.getBotInfo#dcd914fd: field lang_code: %w" , err )
}
g .LangCode = value
}
return nil
}
func (g *BotsGetBotInfoRequest ) SetBot (value InputUserClass ) {
g .Flags .Set (0 )
g .Bot = value
}
func (g *BotsGetBotInfoRequest ) GetBot () (value InputUserClass , ok bool ) {
if g == nil {
return
}
if !g .Flags .Has (0 ) {
return value , false
}
return g .Bot , true
}
func (g *BotsGetBotInfoRequest ) GetLangCode () (value string ) {
if g == nil {
return
}
return g .LangCode
}
func (c *Client ) BotsGetBotInfo (ctx context .Context , request *BotsGetBotInfoRequest ) (*BotsBotInfo , error ) {
var result BotsBotInfo
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 .