Files
mautrix-telegram/pkg/gotd/tdapi/tl_get_bot_info_description_gen.go
T
2025-06-27 20:03:37 -07:00

238 lines
5.9 KiB
Go

// Code generated by gotdgen, DO NOT EDIT.
package tdapi
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
)
// No-op definition for keeping imports.
var (
_ = bin.Buffer{}
_ = context.Background()
_ = fmt.Stringer(nil)
_ = strings.Builder{}
_ = errors.Is
_ = multierr.AppendInto
_ = sort.Ints
_ = tdp.Format
_ = tgerr.Error{}
_ = tdjson.Encoder{}
)
// GetBotInfoDescriptionRequest represents TL type `getBotInfoDescription#d287f835`.
type GetBotInfoDescriptionRequest struct {
// Identifier of the target bot
BotUserID int64
// A two-letter ISO 639-1 language code or an empty string
LanguageCode string
}
// GetBotInfoDescriptionRequestTypeID is TL type id of GetBotInfoDescriptionRequest.
const GetBotInfoDescriptionRequestTypeID = 0xd287f835
// Ensuring interfaces in compile-time for GetBotInfoDescriptionRequest.
var (
_ bin.Encoder = &GetBotInfoDescriptionRequest{}
_ bin.Decoder = &GetBotInfoDescriptionRequest{}
_ bin.BareEncoder = &GetBotInfoDescriptionRequest{}
_ bin.BareDecoder = &GetBotInfoDescriptionRequest{}
)
func (g *GetBotInfoDescriptionRequest) Zero() bool {
if g == nil {
return true
}
if !(g.BotUserID == 0) {
return false
}
if !(g.LanguageCode == "") {
return false
}
return true
}
// String implements fmt.Stringer.
func (g *GetBotInfoDescriptionRequest) String() string {
if g == nil {
return "GetBotInfoDescriptionRequest(nil)"
}
type Alias GetBotInfoDescriptionRequest
return fmt.Sprintf("GetBotInfoDescriptionRequest%+v", Alias(*g))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*GetBotInfoDescriptionRequest) TypeID() uint32 {
return GetBotInfoDescriptionRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*GetBotInfoDescriptionRequest) TypeName() string {
return "getBotInfoDescription"
}
// TypeInfo returns info about TL type.
func (g *GetBotInfoDescriptionRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "getBotInfoDescription",
ID: GetBotInfoDescriptionRequestTypeID,
}
if g == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "BotUserID",
SchemaName: "bot_user_id",
},
{
Name: "LanguageCode",
SchemaName: "language_code",
},
}
return typ
}
// Encode implements bin.Encoder.
func (g *GetBotInfoDescriptionRequest) Encode(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't encode getBotInfoDescription#d287f835 as nil")
}
b.PutID(GetBotInfoDescriptionRequestTypeID)
return g.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (g *GetBotInfoDescriptionRequest) EncodeBare(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't encode getBotInfoDescription#d287f835 as nil")
}
b.PutInt53(g.BotUserID)
b.PutString(g.LanguageCode)
return nil
}
// Decode implements bin.Decoder.
func (g *GetBotInfoDescriptionRequest) Decode(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't decode getBotInfoDescription#d287f835 to nil")
}
if err := b.ConsumeID(GetBotInfoDescriptionRequestTypeID); err != nil {
return fmt.Errorf("unable to decode getBotInfoDescription#d287f835: %w", err)
}
return g.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (g *GetBotInfoDescriptionRequest) DecodeBare(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't decode getBotInfoDescription#d287f835 to nil")
}
{
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode getBotInfoDescription#d287f835: field bot_user_id: %w", err)
}
g.BotUserID = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode getBotInfoDescription#d287f835: field language_code: %w", err)
}
g.LanguageCode = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (g *GetBotInfoDescriptionRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
if g == nil {
return fmt.Errorf("can't encode getBotInfoDescription#d287f835 as nil")
}
b.ObjStart()
b.PutID("getBotInfoDescription")
b.Comma()
b.FieldStart("bot_user_id")
b.PutInt53(g.BotUserID)
b.Comma()
b.FieldStart("language_code")
b.PutString(g.LanguageCode)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (g *GetBotInfoDescriptionRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
if g == nil {
return fmt.Errorf("can't decode getBotInfoDescription#d287f835 to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("getBotInfoDescription"); err != nil {
return fmt.Errorf("unable to decode getBotInfoDescription#d287f835: %w", err)
}
case "bot_user_id":
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode getBotInfoDescription#d287f835: field bot_user_id: %w", err)
}
g.BotUserID = value
case "language_code":
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode getBotInfoDescription#d287f835: field language_code: %w", err)
}
g.LanguageCode = value
default:
return b.Skip()
}
return nil
})
}
// GetBotUserID returns value of BotUserID field.
func (g *GetBotInfoDescriptionRequest) GetBotUserID() (value int64) {
if g == nil {
return
}
return g.BotUserID
}
// GetLanguageCode returns value of LanguageCode field.
func (g *GetBotInfoDescriptionRequest) GetLanguageCode() (value string) {
if g == nil {
return
}
return g.LanguageCode
}
// GetBotInfoDescription invokes method getBotInfoDescription#d287f835 returning error if any.
func (c *Client) GetBotInfoDescription(ctx context.Context, request *GetBotInfoDescriptionRequest) (*Text, error) {
var result Text
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
return nil, err
}
return &result, nil
}