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

742 lines
18 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{}
)
// StickerSet represents TL type `stickerSet#e3b8a114`.
type StickerSet struct {
// Identifier of the sticker set
ID int64
// Title of the sticker set
Title string
// Name of the sticker set
Name string
// Sticker set thumbnail in WEBP, TGS, or WEBM format with width and height 100; may be
// null. The file can be downloaded only before the thumbnail is changed
Thumbnail Thumbnail
// Sticker set thumbnail's outline; may be null if unknown
ThumbnailOutline Outline
// True, if the sticker set is owned by the current user
IsOwned bool
// True, if the sticker set has been installed by the current user
IsInstalled bool
// True, if the sticker set has been archived. A sticker set can't be installed and
// archived simultaneously
IsArchived bool
// True, if the sticker set is official
IsOfficial bool
// Type of the stickers in the set
StickerType StickerTypeClass
// True, if stickers in the sticker set are custom emoji that must be repainted; for
// custom emoji sticker sets only
NeedsRepainting bool
// True, if stickers in the sticker set are custom emoji that can be used as chat emoji
// status; for custom emoji sticker sets only
IsAllowedAsChatEmojiStatus bool
// True for already viewed trending sticker sets
IsViewed bool
// List of stickers in this set
Stickers []Sticker
// A list of emojis corresponding to the stickers in the same order. The list is only for
// informational purposes, because a sticker is always sent with a fixed emoji from the
// corresponding Sticker object
Emojis []Emojis
}
// StickerSetTypeID is TL type id of StickerSet.
const StickerSetTypeID = 0xe3b8a114
// Ensuring interfaces in compile-time for StickerSet.
var (
_ bin.Encoder = &StickerSet{}
_ bin.Decoder = &StickerSet{}
_ bin.BareEncoder = &StickerSet{}
_ bin.BareDecoder = &StickerSet{}
)
func (s *StickerSet) Zero() bool {
if s == nil {
return true
}
if !(s.ID == 0) {
return false
}
if !(s.Title == "") {
return false
}
if !(s.Name == "") {
return false
}
if !(s.Thumbnail.Zero()) {
return false
}
if !(s.ThumbnailOutline.Zero()) {
return false
}
if !(s.IsOwned == false) {
return false
}
if !(s.IsInstalled == false) {
return false
}
if !(s.IsArchived == false) {
return false
}
if !(s.IsOfficial == false) {
return false
}
if !(s.StickerType == nil) {
return false
}
if !(s.NeedsRepainting == false) {
return false
}
if !(s.IsAllowedAsChatEmojiStatus == false) {
return false
}
if !(s.IsViewed == false) {
return false
}
if !(s.Stickers == nil) {
return false
}
if !(s.Emojis == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (s *StickerSet) String() string {
if s == nil {
return "StickerSet(nil)"
}
type Alias StickerSet
return fmt.Sprintf("StickerSet%+v", Alias(*s))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*StickerSet) TypeID() uint32 {
return StickerSetTypeID
}
// TypeName returns name of type in TL schema.
func (*StickerSet) TypeName() string {
return "stickerSet"
}
// TypeInfo returns info about TL type.
func (s *StickerSet) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "stickerSet",
ID: StickerSetTypeID,
}
if s == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "ID",
SchemaName: "id",
},
{
Name: "Title",
SchemaName: "title",
},
{
Name: "Name",
SchemaName: "name",
},
{
Name: "Thumbnail",
SchemaName: "thumbnail",
},
{
Name: "ThumbnailOutline",
SchemaName: "thumbnail_outline",
},
{
Name: "IsOwned",
SchemaName: "is_owned",
},
{
Name: "IsInstalled",
SchemaName: "is_installed",
},
{
Name: "IsArchived",
SchemaName: "is_archived",
},
{
Name: "IsOfficial",
SchemaName: "is_official",
},
{
Name: "StickerType",
SchemaName: "sticker_type",
},
{
Name: "NeedsRepainting",
SchemaName: "needs_repainting",
},
{
Name: "IsAllowedAsChatEmojiStatus",
SchemaName: "is_allowed_as_chat_emoji_status",
},
{
Name: "IsViewed",
SchemaName: "is_viewed",
},
{
Name: "Stickers",
SchemaName: "stickers",
},
{
Name: "Emojis",
SchemaName: "emojis",
},
}
return typ
}
// Encode implements bin.Encoder.
func (s *StickerSet) Encode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode stickerSet#e3b8a114 as nil")
}
b.PutID(StickerSetTypeID)
return s.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (s *StickerSet) EncodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't encode stickerSet#e3b8a114 as nil")
}
b.PutLong(s.ID)
b.PutString(s.Title)
b.PutString(s.Name)
if err := s.Thumbnail.Encode(b); err != nil {
return fmt.Errorf("unable to encode stickerSet#e3b8a114: field thumbnail: %w", err)
}
if err := s.ThumbnailOutline.Encode(b); err != nil {
return fmt.Errorf("unable to encode stickerSet#e3b8a114: field thumbnail_outline: %w", err)
}
b.PutBool(s.IsOwned)
b.PutBool(s.IsInstalled)
b.PutBool(s.IsArchived)
b.PutBool(s.IsOfficial)
if s.StickerType == nil {
return fmt.Errorf("unable to encode stickerSet#e3b8a114: field sticker_type is nil")
}
if err := s.StickerType.Encode(b); err != nil {
return fmt.Errorf("unable to encode stickerSet#e3b8a114: field sticker_type: %w", err)
}
b.PutBool(s.NeedsRepainting)
b.PutBool(s.IsAllowedAsChatEmojiStatus)
b.PutBool(s.IsViewed)
b.PutInt(len(s.Stickers))
for idx, v := range s.Stickers {
if err := v.EncodeBare(b); err != nil {
return fmt.Errorf("unable to encode bare stickerSet#e3b8a114: field stickers element with index %d: %w", idx, err)
}
}
b.PutInt(len(s.Emojis))
for idx, v := range s.Emojis {
if err := v.EncodeBare(b); err != nil {
return fmt.Errorf("unable to encode bare stickerSet#e3b8a114: field emojis element with index %d: %w", idx, err)
}
}
return nil
}
// Decode implements bin.Decoder.
func (s *StickerSet) Decode(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode stickerSet#e3b8a114 to nil")
}
if err := b.ConsumeID(StickerSetTypeID); err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: %w", err)
}
return s.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (s *StickerSet) DecodeBare(b *bin.Buffer) error {
if s == nil {
return fmt.Errorf("can't decode stickerSet#e3b8a114 to nil")
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field id: %w", err)
}
s.ID = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field title: %w", err)
}
s.Title = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field name: %w", err)
}
s.Name = value
}
{
if err := s.Thumbnail.Decode(b); err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field thumbnail: %w", err)
}
}
{
if err := s.ThumbnailOutline.Decode(b); err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field thumbnail_outline: %w", err)
}
}
{
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field is_owned: %w", err)
}
s.IsOwned = value
}
{
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field is_installed: %w", err)
}
s.IsInstalled = value
}
{
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field is_archived: %w", err)
}
s.IsArchived = value
}
{
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field is_official: %w", err)
}
s.IsOfficial = value
}
{
value, err := DecodeStickerType(b)
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field sticker_type: %w", err)
}
s.StickerType = value
}
{
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field needs_repainting: %w", err)
}
s.NeedsRepainting = value
}
{
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field is_allowed_as_chat_emoji_status: %w", err)
}
s.IsAllowedAsChatEmojiStatus = value
}
{
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field is_viewed: %w", err)
}
s.IsViewed = value
}
{
headerLen, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field stickers: %w", err)
}
if headerLen > 0 {
s.Stickers = make([]Sticker, 0, headerLen%bin.PreallocateLimit)
}
for idx := 0; idx < headerLen; idx++ {
var value Sticker
if err := value.DecodeBare(b); err != nil {
return fmt.Errorf("unable to decode bare stickerSet#e3b8a114: field stickers: %w", err)
}
s.Stickers = append(s.Stickers, value)
}
}
{
headerLen, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field emojis: %w", err)
}
if headerLen > 0 {
s.Emojis = make([]Emojis, 0, headerLen%bin.PreallocateLimit)
}
for idx := 0; idx < headerLen; idx++ {
var value Emojis
if err := value.DecodeBare(b); err != nil {
return fmt.Errorf("unable to decode bare stickerSet#e3b8a114: field emojis: %w", err)
}
s.Emojis = append(s.Emojis, value)
}
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *StickerSet) EncodeTDLibJSON(b tdjson.Encoder) error {
if s == nil {
return fmt.Errorf("can't encode stickerSet#e3b8a114 as nil")
}
b.ObjStart()
b.PutID("stickerSet")
b.Comma()
b.FieldStart("id")
b.PutLong(s.ID)
b.Comma()
b.FieldStart("title")
b.PutString(s.Title)
b.Comma()
b.FieldStart("name")
b.PutString(s.Name)
b.Comma()
b.FieldStart("thumbnail")
if err := s.Thumbnail.EncodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to encode stickerSet#e3b8a114: field thumbnail: %w", err)
}
b.Comma()
b.FieldStart("thumbnail_outline")
if err := s.ThumbnailOutline.EncodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to encode stickerSet#e3b8a114: field thumbnail_outline: %w", err)
}
b.Comma()
b.FieldStart("is_owned")
b.PutBool(s.IsOwned)
b.Comma()
b.FieldStart("is_installed")
b.PutBool(s.IsInstalled)
b.Comma()
b.FieldStart("is_archived")
b.PutBool(s.IsArchived)
b.Comma()
b.FieldStart("is_official")
b.PutBool(s.IsOfficial)
b.Comma()
b.FieldStart("sticker_type")
if s.StickerType == nil {
return fmt.Errorf("unable to encode stickerSet#e3b8a114: field sticker_type is nil")
}
if err := s.StickerType.EncodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to encode stickerSet#e3b8a114: field sticker_type: %w", err)
}
b.Comma()
b.FieldStart("needs_repainting")
b.PutBool(s.NeedsRepainting)
b.Comma()
b.FieldStart("is_allowed_as_chat_emoji_status")
b.PutBool(s.IsAllowedAsChatEmojiStatus)
b.Comma()
b.FieldStart("is_viewed")
b.PutBool(s.IsViewed)
b.Comma()
b.FieldStart("stickers")
b.ArrStart()
for idx, v := range s.Stickers {
if err := v.EncodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to encode stickerSet#e3b8a114: field stickers element with index %d: %w", idx, err)
}
b.Comma()
}
b.StripComma()
b.ArrEnd()
b.Comma()
b.FieldStart("emojis")
b.ArrStart()
for idx, v := range s.Emojis {
if err := v.EncodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to encode stickerSet#e3b8a114: field emojis element with index %d: %w", idx, err)
}
b.Comma()
}
b.StripComma()
b.ArrEnd()
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *StickerSet) DecodeTDLibJSON(b tdjson.Decoder) error {
if s == nil {
return fmt.Errorf("can't decode stickerSet#e3b8a114 to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("stickerSet"); err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: %w", err)
}
case "id":
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field id: %w", err)
}
s.ID = value
case "title":
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field title: %w", err)
}
s.Title = value
case "name":
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field name: %w", err)
}
s.Name = value
case "thumbnail":
if err := s.Thumbnail.DecodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field thumbnail: %w", err)
}
case "thumbnail_outline":
if err := s.ThumbnailOutline.DecodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field thumbnail_outline: %w", err)
}
case "is_owned":
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field is_owned: %w", err)
}
s.IsOwned = value
case "is_installed":
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field is_installed: %w", err)
}
s.IsInstalled = value
case "is_archived":
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field is_archived: %w", err)
}
s.IsArchived = value
case "is_official":
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field is_official: %w", err)
}
s.IsOfficial = value
case "sticker_type":
value, err := DecodeTDLibJSONStickerType(b)
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field sticker_type: %w", err)
}
s.StickerType = value
case "needs_repainting":
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field needs_repainting: %w", err)
}
s.NeedsRepainting = value
case "is_allowed_as_chat_emoji_status":
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field is_allowed_as_chat_emoji_status: %w", err)
}
s.IsAllowedAsChatEmojiStatus = value
case "is_viewed":
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field is_viewed: %w", err)
}
s.IsViewed = value
case "stickers":
if err := b.Arr(func(b tdjson.Decoder) error {
var value Sticker
if err := value.DecodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field stickers: %w", err)
}
s.Stickers = append(s.Stickers, value)
return nil
}); err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field stickers: %w", err)
}
case "emojis":
if err := b.Arr(func(b tdjson.Decoder) error {
var value Emojis
if err := value.DecodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field emojis: %w", err)
}
s.Emojis = append(s.Emojis, value)
return nil
}); err != nil {
return fmt.Errorf("unable to decode stickerSet#e3b8a114: field emojis: %w", err)
}
default:
return b.Skip()
}
return nil
})
}
// GetID returns value of ID field.
func (s *StickerSet) GetID() (value int64) {
if s == nil {
return
}
return s.ID
}
// GetTitle returns value of Title field.
func (s *StickerSet) GetTitle() (value string) {
if s == nil {
return
}
return s.Title
}
// GetName returns value of Name field.
func (s *StickerSet) GetName() (value string) {
if s == nil {
return
}
return s.Name
}
// GetThumbnail returns value of Thumbnail field.
func (s *StickerSet) GetThumbnail() (value Thumbnail) {
if s == nil {
return
}
return s.Thumbnail
}
// GetThumbnailOutline returns value of ThumbnailOutline field.
func (s *StickerSet) GetThumbnailOutline() (value Outline) {
if s == nil {
return
}
return s.ThumbnailOutline
}
// GetIsOwned returns value of IsOwned field.
func (s *StickerSet) GetIsOwned() (value bool) {
if s == nil {
return
}
return s.IsOwned
}
// GetIsInstalled returns value of IsInstalled field.
func (s *StickerSet) GetIsInstalled() (value bool) {
if s == nil {
return
}
return s.IsInstalled
}
// GetIsArchived returns value of IsArchived field.
func (s *StickerSet) GetIsArchived() (value bool) {
if s == nil {
return
}
return s.IsArchived
}
// GetIsOfficial returns value of IsOfficial field.
func (s *StickerSet) GetIsOfficial() (value bool) {
if s == nil {
return
}
return s.IsOfficial
}
// GetStickerType returns value of StickerType field.
func (s *StickerSet) GetStickerType() (value StickerTypeClass) {
if s == nil {
return
}
return s.StickerType
}
// GetNeedsRepainting returns value of NeedsRepainting field.
func (s *StickerSet) GetNeedsRepainting() (value bool) {
if s == nil {
return
}
return s.NeedsRepainting
}
// GetIsAllowedAsChatEmojiStatus returns value of IsAllowedAsChatEmojiStatus field.
func (s *StickerSet) GetIsAllowedAsChatEmojiStatus() (value bool) {
if s == nil {
return
}
return s.IsAllowedAsChatEmojiStatus
}
// GetIsViewed returns value of IsViewed field.
func (s *StickerSet) GetIsViewed() (value bool) {
if s == nil {
return
}
return s.IsViewed
}
// GetStickers returns value of Stickers field.
func (s *StickerSet) GetStickers() (value []Sticker) {
if s == nil {
return
}
return s.Stickers
}
// GetEmojis returns value of Emojis field.
func (s *StickerSet) GetEmojis() (value []Emojis) {
if s == nil {
return
}
return s.Emojis
}