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

182 lines
4.8 KiB
Go

// Code generated by gotdgen, DO NOT EDIT.
package tg
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{}
)
// BotsGetBotRecommendationsRequest represents TL type `bots.getBotRecommendations#a1b70815`.
//
// See https://core.telegram.org/method/bots.getBotRecommendations for reference.
type BotsGetBotRecommendationsRequest struct {
// Bot field of BotsGetBotRecommendationsRequest.
Bot InputUserClass
}
// BotsGetBotRecommendationsRequestTypeID is TL type id of BotsGetBotRecommendationsRequest.
const BotsGetBotRecommendationsRequestTypeID = 0xa1b70815
// Ensuring interfaces in compile-time for BotsGetBotRecommendationsRequest.
var (
_ bin.Encoder = &BotsGetBotRecommendationsRequest{}
_ bin.Decoder = &BotsGetBotRecommendationsRequest{}
_ bin.BareEncoder = &BotsGetBotRecommendationsRequest{}
_ bin.BareDecoder = &BotsGetBotRecommendationsRequest{}
)
func (g *BotsGetBotRecommendationsRequest) Zero() bool {
if g == nil {
return true
}
if !(g.Bot == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (g *BotsGetBotRecommendationsRequest) String() string {
if g == nil {
return "BotsGetBotRecommendationsRequest(nil)"
}
type Alias BotsGetBotRecommendationsRequest
return fmt.Sprintf("BotsGetBotRecommendationsRequest%+v", Alias(*g))
}
// FillFrom fills BotsGetBotRecommendationsRequest from given interface.
func (g *BotsGetBotRecommendationsRequest) FillFrom(from interface {
GetBot() (value InputUserClass)
}) {
g.Bot = from.GetBot()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*BotsGetBotRecommendationsRequest) TypeID() uint32 {
return BotsGetBotRecommendationsRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*BotsGetBotRecommendationsRequest) TypeName() string {
return "bots.getBotRecommendations"
}
// TypeInfo returns info about TL type.
func (g *BotsGetBotRecommendationsRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "bots.getBotRecommendations",
ID: BotsGetBotRecommendationsRequestTypeID,
}
if g == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Bot",
SchemaName: "bot",
},
}
return typ
}
// Encode implements bin.Encoder.
func (g *BotsGetBotRecommendationsRequest) Encode(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't encode bots.getBotRecommendations#a1b70815 as nil")
}
b.PutID(BotsGetBotRecommendationsRequestTypeID)
return g.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (g *BotsGetBotRecommendationsRequest) EncodeBare(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't encode bots.getBotRecommendations#a1b70815 as nil")
}
if g.Bot == nil {
return fmt.Errorf("unable to encode bots.getBotRecommendations#a1b70815: field bot is nil")
}
if err := g.Bot.Encode(b); err != nil {
return fmt.Errorf("unable to encode bots.getBotRecommendations#a1b70815: field bot: %w", err)
}
return nil
}
// Decode implements bin.Decoder.
func (g *BotsGetBotRecommendationsRequest) Decode(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't decode bots.getBotRecommendations#a1b70815 to nil")
}
if err := b.ConsumeID(BotsGetBotRecommendationsRequestTypeID); err != nil {
return fmt.Errorf("unable to decode bots.getBotRecommendations#a1b70815: %w", err)
}
return g.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (g *BotsGetBotRecommendationsRequest) DecodeBare(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't decode bots.getBotRecommendations#a1b70815 to nil")
}
{
value, err := DecodeInputUser(b)
if err != nil {
return fmt.Errorf("unable to decode bots.getBotRecommendations#a1b70815: field bot: %w", err)
}
g.Bot = value
}
return nil
}
// GetBot returns value of Bot field.
func (g *BotsGetBotRecommendationsRequest) GetBot() (value InputUserClass) {
if g == nil {
return
}
return g.Bot
}
// BotsGetBotRecommendations invokes method bots.getBotRecommendations#a1b70815 returning error if any.
//
// See https://core.telegram.org/method/bots.getBotRecommendations for reference.
func (c *Client) BotsGetBotRecommendations(ctx context.Context, bot InputUserClass) (UsersUsersClass, error) {
var result UsersUsersBox
request := &BotsGetBotRecommendationsRequest{
Bot: bot,
}
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
return nil, err
}
return result.Users, nil
}