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

207 lines
4.7 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{}
)
// GetStickerSetRequest represents TL type `getStickerSet#3eb91bc3`.
type GetStickerSetRequest struct {
// Identifier of the sticker set
SetID int64
}
// GetStickerSetRequestTypeID is TL type id of GetStickerSetRequest.
const GetStickerSetRequestTypeID = 0x3eb91bc3
// Ensuring interfaces in compile-time for GetStickerSetRequest.
var (
_ bin.Encoder = &GetStickerSetRequest{}
_ bin.Decoder = &GetStickerSetRequest{}
_ bin.BareEncoder = &GetStickerSetRequest{}
_ bin.BareDecoder = &GetStickerSetRequest{}
)
func (g *GetStickerSetRequest) Zero() bool {
if g == nil {
return true
}
if !(g.SetID == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (g *GetStickerSetRequest) String() string {
if g == nil {
return "GetStickerSetRequest(nil)"
}
type Alias GetStickerSetRequest
return fmt.Sprintf("GetStickerSetRequest%+v", Alias(*g))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*GetStickerSetRequest) TypeID() uint32 {
return GetStickerSetRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*GetStickerSetRequest) TypeName() string {
return "getStickerSet"
}
// TypeInfo returns info about TL type.
func (g *GetStickerSetRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "getStickerSet",
ID: GetStickerSetRequestTypeID,
}
if g == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "SetID",
SchemaName: "set_id",
},
}
return typ
}
// Encode implements bin.Encoder.
func (g *GetStickerSetRequest) Encode(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't encode getStickerSet#3eb91bc3 as nil")
}
b.PutID(GetStickerSetRequestTypeID)
return g.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (g *GetStickerSetRequest) EncodeBare(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't encode getStickerSet#3eb91bc3 as nil")
}
b.PutLong(g.SetID)
return nil
}
// Decode implements bin.Decoder.
func (g *GetStickerSetRequest) Decode(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't decode getStickerSet#3eb91bc3 to nil")
}
if err := b.ConsumeID(GetStickerSetRequestTypeID); err != nil {
return fmt.Errorf("unable to decode getStickerSet#3eb91bc3: %w", err)
}
return g.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (g *GetStickerSetRequest) DecodeBare(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't decode getStickerSet#3eb91bc3 to nil")
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode getStickerSet#3eb91bc3: field set_id: %w", err)
}
g.SetID = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (g *GetStickerSetRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
if g == nil {
return fmt.Errorf("can't encode getStickerSet#3eb91bc3 as nil")
}
b.ObjStart()
b.PutID("getStickerSet")
b.Comma()
b.FieldStart("set_id")
b.PutLong(g.SetID)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (g *GetStickerSetRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
if g == nil {
return fmt.Errorf("can't decode getStickerSet#3eb91bc3 to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("getStickerSet"); err != nil {
return fmt.Errorf("unable to decode getStickerSet#3eb91bc3: %w", err)
}
case "set_id":
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode getStickerSet#3eb91bc3: field set_id: %w", err)
}
g.SetID = value
default:
return b.Skip()
}
return nil
})
}
// GetSetID returns value of SetID field.
func (g *GetStickerSetRequest) GetSetID() (value int64) {
if g == nil {
return
}
return g.SetID
}
// GetStickerSet invokes method getStickerSet#3eb91bc3 returning error if any.
func (c *Client) GetStickerSet(ctx context.Context, setid int64) (*StickerSet, error) {
var result StickerSet
request := &GetStickerSetRequest{
SetID: setid,
}
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
return nil, err
}
return &result, nil
}