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

238 lines
5.8 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{}
)
// OpenBotSimilarBotRequest represents TL type `openBotSimilarBot#e9f6fed8`.
type OpenBotSimilarBotRequest struct {
// Identifier of the original bot, which similar bots were requested
BotUserID int64
// Identifier of the opened bot
OpenedBotUserID int64
}
// OpenBotSimilarBotRequestTypeID is TL type id of OpenBotSimilarBotRequest.
const OpenBotSimilarBotRequestTypeID = 0xe9f6fed8
// Ensuring interfaces in compile-time for OpenBotSimilarBotRequest.
var (
_ bin.Encoder = &OpenBotSimilarBotRequest{}
_ bin.Decoder = &OpenBotSimilarBotRequest{}
_ bin.BareEncoder = &OpenBotSimilarBotRequest{}
_ bin.BareDecoder = &OpenBotSimilarBotRequest{}
)
func (o *OpenBotSimilarBotRequest) Zero() bool {
if o == nil {
return true
}
if !(o.BotUserID == 0) {
return false
}
if !(o.OpenedBotUserID == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (o *OpenBotSimilarBotRequest) String() string {
if o == nil {
return "OpenBotSimilarBotRequest(nil)"
}
type Alias OpenBotSimilarBotRequest
return fmt.Sprintf("OpenBotSimilarBotRequest%+v", Alias(*o))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*OpenBotSimilarBotRequest) TypeID() uint32 {
return OpenBotSimilarBotRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*OpenBotSimilarBotRequest) TypeName() string {
return "openBotSimilarBot"
}
// TypeInfo returns info about TL type.
func (o *OpenBotSimilarBotRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "openBotSimilarBot",
ID: OpenBotSimilarBotRequestTypeID,
}
if o == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "BotUserID",
SchemaName: "bot_user_id",
},
{
Name: "OpenedBotUserID",
SchemaName: "opened_bot_user_id",
},
}
return typ
}
// Encode implements bin.Encoder.
func (o *OpenBotSimilarBotRequest) Encode(b *bin.Buffer) error {
if o == nil {
return fmt.Errorf("can't encode openBotSimilarBot#e9f6fed8 as nil")
}
b.PutID(OpenBotSimilarBotRequestTypeID)
return o.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (o *OpenBotSimilarBotRequest) EncodeBare(b *bin.Buffer) error {
if o == nil {
return fmt.Errorf("can't encode openBotSimilarBot#e9f6fed8 as nil")
}
b.PutInt53(o.BotUserID)
b.PutInt53(o.OpenedBotUserID)
return nil
}
// Decode implements bin.Decoder.
func (o *OpenBotSimilarBotRequest) Decode(b *bin.Buffer) error {
if o == nil {
return fmt.Errorf("can't decode openBotSimilarBot#e9f6fed8 to nil")
}
if err := b.ConsumeID(OpenBotSimilarBotRequestTypeID); err != nil {
return fmt.Errorf("unable to decode openBotSimilarBot#e9f6fed8: %w", err)
}
return o.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (o *OpenBotSimilarBotRequest) DecodeBare(b *bin.Buffer) error {
if o == nil {
return fmt.Errorf("can't decode openBotSimilarBot#e9f6fed8 to nil")
}
{
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode openBotSimilarBot#e9f6fed8: field bot_user_id: %w", err)
}
o.BotUserID = value
}
{
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode openBotSimilarBot#e9f6fed8: field opened_bot_user_id: %w", err)
}
o.OpenedBotUserID = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (o *OpenBotSimilarBotRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
if o == nil {
return fmt.Errorf("can't encode openBotSimilarBot#e9f6fed8 as nil")
}
b.ObjStart()
b.PutID("openBotSimilarBot")
b.Comma()
b.FieldStart("bot_user_id")
b.PutInt53(o.BotUserID)
b.Comma()
b.FieldStart("opened_bot_user_id")
b.PutInt53(o.OpenedBotUserID)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (o *OpenBotSimilarBotRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
if o == nil {
return fmt.Errorf("can't decode openBotSimilarBot#e9f6fed8 to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("openBotSimilarBot"); err != nil {
return fmt.Errorf("unable to decode openBotSimilarBot#e9f6fed8: %w", err)
}
case "bot_user_id":
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode openBotSimilarBot#e9f6fed8: field bot_user_id: %w", err)
}
o.BotUserID = value
case "opened_bot_user_id":
value, err := b.Int53()
if err != nil {
return fmt.Errorf("unable to decode openBotSimilarBot#e9f6fed8: field opened_bot_user_id: %w", err)
}
o.OpenedBotUserID = value
default:
return b.Skip()
}
return nil
})
}
// GetBotUserID returns value of BotUserID field.
func (o *OpenBotSimilarBotRequest) GetBotUserID() (value int64) {
if o == nil {
return
}
return o.BotUserID
}
// GetOpenedBotUserID returns value of OpenedBotUserID field.
func (o *OpenBotSimilarBotRequest) GetOpenedBotUserID() (value int64) {
if o == nil {
return
}
return o.OpenedBotUserID
}
// OpenBotSimilarBot invokes method openBotSimilarBot#e9f6fed8 returning error if any.
func (c *Client) OpenBotSimilarBot(ctx context.Context, request *OpenBotSimilarBotRequest) error {
var ok Ok
if err := c.rpc.Invoke(ctx, request, &ok); err != nil {
return err
}
return nil
}