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

231 lines
6.0 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{}
)
// ViewTrendingStickerSetsRequest represents TL type `viewTrendingStickerSets#36d6469`.
type ViewTrendingStickerSetsRequest struct {
// Identifiers of viewed trending sticker sets
StickerSetIDs []int64
}
// ViewTrendingStickerSetsRequestTypeID is TL type id of ViewTrendingStickerSetsRequest.
const ViewTrendingStickerSetsRequestTypeID = 0x36d6469
// Ensuring interfaces in compile-time for ViewTrendingStickerSetsRequest.
var (
_ bin.Encoder = &ViewTrendingStickerSetsRequest{}
_ bin.Decoder = &ViewTrendingStickerSetsRequest{}
_ bin.BareEncoder = &ViewTrendingStickerSetsRequest{}
_ bin.BareDecoder = &ViewTrendingStickerSetsRequest{}
)
func (v *ViewTrendingStickerSetsRequest) Zero() bool {
if v == nil {
return true
}
if !(v.StickerSetIDs == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (v *ViewTrendingStickerSetsRequest) String() string {
if v == nil {
return "ViewTrendingStickerSetsRequest(nil)"
}
type Alias ViewTrendingStickerSetsRequest
return fmt.Sprintf("ViewTrendingStickerSetsRequest%+v", Alias(*v))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*ViewTrendingStickerSetsRequest) TypeID() uint32 {
return ViewTrendingStickerSetsRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*ViewTrendingStickerSetsRequest) TypeName() string {
return "viewTrendingStickerSets"
}
// TypeInfo returns info about TL type.
func (v *ViewTrendingStickerSetsRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "viewTrendingStickerSets",
ID: ViewTrendingStickerSetsRequestTypeID,
}
if v == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "StickerSetIDs",
SchemaName: "sticker_set_ids",
},
}
return typ
}
// Encode implements bin.Encoder.
func (v *ViewTrendingStickerSetsRequest) Encode(b *bin.Buffer) error {
if v == nil {
return fmt.Errorf("can't encode viewTrendingStickerSets#36d6469 as nil")
}
b.PutID(ViewTrendingStickerSetsRequestTypeID)
return v.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (v *ViewTrendingStickerSetsRequest) EncodeBare(b *bin.Buffer) error {
if v == nil {
return fmt.Errorf("can't encode viewTrendingStickerSets#36d6469 as nil")
}
b.PutInt(len(v.StickerSetIDs))
for _, v := range v.StickerSetIDs {
b.PutLong(v)
}
return nil
}
// Decode implements bin.Decoder.
func (v *ViewTrendingStickerSetsRequest) Decode(b *bin.Buffer) error {
if v == nil {
return fmt.Errorf("can't decode viewTrendingStickerSets#36d6469 to nil")
}
if err := b.ConsumeID(ViewTrendingStickerSetsRequestTypeID); err != nil {
return fmt.Errorf("unable to decode viewTrendingStickerSets#36d6469: %w", err)
}
return v.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (v *ViewTrendingStickerSetsRequest) DecodeBare(b *bin.Buffer) error {
if v == nil {
return fmt.Errorf("can't decode viewTrendingStickerSets#36d6469 to nil")
}
{
headerLen, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode viewTrendingStickerSets#36d6469: field sticker_set_ids: %w", err)
}
if headerLen > 0 {
v.StickerSetIDs = make([]int64, 0, headerLen%bin.PreallocateLimit)
}
for idx := 0; idx < headerLen; idx++ {
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode viewTrendingStickerSets#36d6469: field sticker_set_ids: %w", err)
}
v.StickerSetIDs = append(v.StickerSetIDs, value)
}
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (v *ViewTrendingStickerSetsRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
if v == nil {
return fmt.Errorf("can't encode viewTrendingStickerSets#36d6469 as nil")
}
b.ObjStart()
b.PutID("viewTrendingStickerSets")
b.Comma()
b.FieldStart("sticker_set_ids")
b.ArrStart()
for _, v := range v.StickerSetIDs {
b.PutLong(v)
b.Comma()
}
b.StripComma()
b.ArrEnd()
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (v *ViewTrendingStickerSetsRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
if v == nil {
return fmt.Errorf("can't decode viewTrendingStickerSets#36d6469 to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("viewTrendingStickerSets"); err != nil {
return fmt.Errorf("unable to decode viewTrendingStickerSets#36d6469: %w", err)
}
case "sticker_set_ids":
if err := b.Arr(func(b tdjson.Decoder) error {
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode viewTrendingStickerSets#36d6469: field sticker_set_ids: %w", err)
}
v.StickerSetIDs = append(v.StickerSetIDs, value)
return nil
}); err != nil {
return fmt.Errorf("unable to decode viewTrendingStickerSets#36d6469: field sticker_set_ids: %w", err)
}
default:
return b.Skip()
}
return nil
})
}
// GetStickerSetIDs returns value of StickerSetIDs field.
func (v *ViewTrendingStickerSetsRequest) GetStickerSetIDs() (value []int64) {
if v == nil {
return
}
return v.StickerSetIDs
}
// ViewTrendingStickerSets invokes method viewTrendingStickerSets#36d6469 returning error if any.
func (c *Client) ViewTrendingStickerSets(ctx context.Context, stickersetids []int64) error {
var ok Ok
request := &ViewTrendingStickerSetsRequest{
StickerSetIDs: stickersetids,
}
if err := c.rpc.Invoke(ctx, request, &ok); err != nil {
return err
}
return nil
}