Files
mautrix-telegram/pkg/gotd/tg/tl_input_chat_theme_gen.go
2025-12-03 17:11:20 +02:00

513 lines
13 KiB
Go
Generated

// 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{}
)
// InputChatThemeEmpty represents TL type `inputChatThemeEmpty#83268483`.
// Remove any currently configured theme.
//
// See https://core.telegram.org/constructor/inputChatThemeEmpty for reference.
type InputChatThemeEmpty struct {
}
// InputChatThemeEmptyTypeID is TL type id of InputChatThemeEmpty.
const InputChatThemeEmptyTypeID = 0x83268483
// construct implements constructor of InputChatThemeClass.
func (i InputChatThemeEmpty) construct() InputChatThemeClass { return &i }
// Ensuring interfaces in compile-time for InputChatThemeEmpty.
var (
_ bin.Encoder = &InputChatThemeEmpty{}
_ bin.Decoder = &InputChatThemeEmpty{}
_ bin.BareEncoder = &InputChatThemeEmpty{}
_ bin.BareDecoder = &InputChatThemeEmpty{}
_ InputChatThemeClass = &InputChatThemeEmpty{}
)
func (i *InputChatThemeEmpty) Zero() bool {
if i == nil {
return true
}
return true
}
// String implements fmt.Stringer.
func (i *InputChatThemeEmpty) String() string {
if i == nil {
return "InputChatThemeEmpty(nil)"
}
type Alias InputChatThemeEmpty
return fmt.Sprintf("InputChatThemeEmpty%+v", Alias(*i))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*InputChatThemeEmpty) TypeID() uint32 {
return InputChatThemeEmptyTypeID
}
// TypeName returns name of type in TL schema.
func (*InputChatThemeEmpty) TypeName() string {
return "inputChatThemeEmpty"
}
// TypeInfo returns info about TL type.
func (i *InputChatThemeEmpty) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "inputChatThemeEmpty",
ID: InputChatThemeEmptyTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{}
return typ
}
// Encode implements bin.Encoder.
func (i *InputChatThemeEmpty) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputChatThemeEmpty#83268483 as nil")
}
b.PutID(InputChatThemeEmptyTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *InputChatThemeEmpty) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputChatThemeEmpty#83268483 as nil")
}
return nil
}
// Decode implements bin.Decoder.
func (i *InputChatThemeEmpty) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputChatThemeEmpty#83268483 to nil")
}
if err := b.ConsumeID(InputChatThemeEmptyTypeID); err != nil {
return fmt.Errorf("unable to decode inputChatThemeEmpty#83268483: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *InputChatThemeEmpty) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputChatThemeEmpty#83268483 to nil")
}
return nil
}
// InputChatTheme represents TL type `inputChatTheme#c93de95c`.
// Set an emoji-based chat theme, returned by account.getChatThemes¹.
//
// Links:
// 1. https://core.telegram.org/method/account.getChatThemes
//
// See https://core.telegram.org/constructor/inputChatTheme for reference.
type InputChatTheme struct {
// The emoji.
Emoticon string
}
// InputChatThemeTypeID is TL type id of InputChatTheme.
const InputChatThemeTypeID = 0xc93de95c
// construct implements constructor of InputChatThemeClass.
func (i InputChatTheme) construct() InputChatThemeClass { return &i }
// Ensuring interfaces in compile-time for InputChatTheme.
var (
_ bin.Encoder = &InputChatTheme{}
_ bin.Decoder = &InputChatTheme{}
_ bin.BareEncoder = &InputChatTheme{}
_ bin.BareDecoder = &InputChatTheme{}
_ InputChatThemeClass = &InputChatTheme{}
)
func (i *InputChatTheme) Zero() bool {
if i == nil {
return true
}
if !(i.Emoticon == "") {
return false
}
return true
}
// String implements fmt.Stringer.
func (i *InputChatTheme) String() string {
if i == nil {
return "InputChatTheme(nil)"
}
type Alias InputChatTheme
return fmt.Sprintf("InputChatTheme%+v", Alias(*i))
}
// FillFrom fills InputChatTheme from given interface.
func (i *InputChatTheme) FillFrom(from interface {
GetEmoticon() (value string)
}) {
i.Emoticon = from.GetEmoticon()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*InputChatTheme) TypeID() uint32 {
return InputChatThemeTypeID
}
// TypeName returns name of type in TL schema.
func (*InputChatTheme) TypeName() string {
return "inputChatTheme"
}
// TypeInfo returns info about TL type.
func (i *InputChatTheme) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "inputChatTheme",
ID: InputChatThemeTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Emoticon",
SchemaName: "emoticon",
},
}
return typ
}
// Encode implements bin.Encoder.
func (i *InputChatTheme) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputChatTheme#c93de95c as nil")
}
b.PutID(InputChatThemeTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *InputChatTheme) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputChatTheme#c93de95c as nil")
}
b.PutString(i.Emoticon)
return nil
}
// Decode implements bin.Decoder.
func (i *InputChatTheme) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputChatTheme#c93de95c to nil")
}
if err := b.ConsumeID(InputChatThemeTypeID); err != nil {
return fmt.Errorf("unable to decode inputChatTheme#c93de95c: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *InputChatTheme) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputChatTheme#c93de95c to nil")
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputChatTheme#c93de95c: field emoticon: %w", err)
}
i.Emoticon = value
}
return nil
}
// GetEmoticon returns value of Emoticon field.
func (i *InputChatTheme) GetEmoticon() (value string) {
if i == nil {
return
}
return i.Emoticon
}
// InputChatThemeUniqueGift represents TL type `inputChatThemeUniqueGift#87e5dfe4`.
// Set a theme based on an owned collectible gift »¹, returned by account
// getUniqueGiftChatThemes².
//
// Links:
// 1. https://core.telegram.org/api/gifts#collectible-gifts
// 2. https://core.telegram.org/method/account.getUniqueGiftChatThemes
//
// See https://core.telegram.org/constructor/inputChatThemeUniqueGift for reference.
type InputChatThemeUniqueGift struct {
// The slug from starGiftUnique¹.slug.
//
// Links:
// 1) https://core.telegram.org/constructor/starGiftUnique
Slug string
}
// InputChatThemeUniqueGiftTypeID is TL type id of InputChatThemeUniqueGift.
const InputChatThemeUniqueGiftTypeID = 0x87e5dfe4
// construct implements constructor of InputChatThemeClass.
func (i InputChatThemeUniqueGift) construct() InputChatThemeClass { return &i }
// Ensuring interfaces in compile-time for InputChatThemeUniqueGift.
var (
_ bin.Encoder = &InputChatThemeUniqueGift{}
_ bin.Decoder = &InputChatThemeUniqueGift{}
_ bin.BareEncoder = &InputChatThemeUniqueGift{}
_ bin.BareDecoder = &InputChatThemeUniqueGift{}
_ InputChatThemeClass = &InputChatThemeUniqueGift{}
)
func (i *InputChatThemeUniqueGift) Zero() bool {
if i == nil {
return true
}
if !(i.Slug == "") {
return false
}
return true
}
// String implements fmt.Stringer.
func (i *InputChatThemeUniqueGift) String() string {
if i == nil {
return "InputChatThemeUniqueGift(nil)"
}
type Alias InputChatThemeUniqueGift
return fmt.Sprintf("InputChatThemeUniqueGift%+v", Alias(*i))
}
// FillFrom fills InputChatThemeUniqueGift from given interface.
func (i *InputChatThemeUniqueGift) FillFrom(from interface {
GetSlug() (value string)
}) {
i.Slug = from.GetSlug()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*InputChatThemeUniqueGift) TypeID() uint32 {
return InputChatThemeUniqueGiftTypeID
}
// TypeName returns name of type in TL schema.
func (*InputChatThemeUniqueGift) TypeName() string {
return "inputChatThemeUniqueGift"
}
// TypeInfo returns info about TL type.
func (i *InputChatThemeUniqueGift) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "inputChatThemeUniqueGift",
ID: InputChatThemeUniqueGiftTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Slug",
SchemaName: "slug",
},
}
return typ
}
// Encode implements bin.Encoder.
func (i *InputChatThemeUniqueGift) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputChatThemeUniqueGift#87e5dfe4 as nil")
}
b.PutID(InputChatThemeUniqueGiftTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *InputChatThemeUniqueGift) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputChatThemeUniqueGift#87e5dfe4 as nil")
}
b.PutString(i.Slug)
return nil
}
// Decode implements bin.Decoder.
func (i *InputChatThemeUniqueGift) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputChatThemeUniqueGift#87e5dfe4 to nil")
}
if err := b.ConsumeID(InputChatThemeUniqueGiftTypeID); err != nil {
return fmt.Errorf("unable to decode inputChatThemeUniqueGift#87e5dfe4: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *InputChatThemeUniqueGift) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputChatThemeUniqueGift#87e5dfe4 to nil")
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode inputChatThemeUniqueGift#87e5dfe4: field slug: %w", err)
}
i.Slug = value
}
return nil
}
// GetSlug returns value of Slug field.
func (i *InputChatThemeUniqueGift) GetSlug() (value string) {
if i == nil {
return
}
return i.Slug
}
// InputChatThemeClassName is schema name of InputChatThemeClass.
const InputChatThemeClassName = "InputChatTheme"
// InputChatThemeClass represents InputChatTheme generic type.
//
// See https://core.telegram.org/type/InputChatTheme for reference.
//
// Example:
//
// g, err := tg.DecodeInputChatTheme(buf)
// if err != nil {
// panic(err)
// }
// switch v := g.(type) {
// case *tg.InputChatThemeEmpty: // inputChatThemeEmpty#83268483
// case *tg.InputChatTheme: // inputChatTheme#c93de95c
// case *tg.InputChatThemeUniqueGift: // inputChatThemeUniqueGift#87e5dfe4
// default: panic(v)
// }
type InputChatThemeClass interface {
bin.Encoder
bin.Decoder
bin.BareEncoder
bin.BareDecoder
construct() InputChatThemeClass
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
TypeID() uint32
// TypeName returns name of type in TL schema.
TypeName() string
// String implements fmt.Stringer.
String() string
// Zero returns true if current object has a zero value.
Zero() bool
}
// DecodeInputChatTheme implements binary de-serialization for InputChatThemeClass.
func DecodeInputChatTheme(buf *bin.Buffer) (InputChatThemeClass, error) {
id, err := buf.PeekID()
if err != nil {
return nil, err
}
switch id {
case InputChatThemeEmptyTypeID:
// Decoding inputChatThemeEmpty#83268483.
v := InputChatThemeEmpty{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode InputChatThemeClass: %w", err)
}
return &v, nil
case InputChatThemeTypeID:
// Decoding inputChatTheme#c93de95c.
v := InputChatTheme{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode InputChatThemeClass: %w", err)
}
return &v, nil
case InputChatThemeUniqueGiftTypeID:
// Decoding inputChatThemeUniqueGift#87e5dfe4.
v := InputChatThemeUniqueGift{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode InputChatThemeClass: %w", err)
}
return &v, nil
default:
return nil, fmt.Errorf("unable to decode InputChatThemeClass: %w", bin.NewUnexpectedID(id))
}
}
// InputChatTheme boxes the InputChatThemeClass providing a helper.
type InputChatThemeBox struct {
InputChatTheme InputChatThemeClass
}
// Decode implements bin.Decoder for InputChatThemeBox.
func (b *InputChatThemeBox) Decode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("unable to decode InputChatThemeBox to nil")
}
v, err := DecodeInputChatTheme(buf)
if err != nil {
return fmt.Errorf("unable to decode boxed value: %w", err)
}
b.InputChatTheme = v
return nil
}
// Encode implements bin.Encode for InputChatThemeBox.
func (b *InputChatThemeBox) Encode(buf *bin.Buffer) error {
if b == nil || b.InputChatTheme == nil {
return fmt.Errorf("unable to encode InputChatThemeClass as nil")
}
return b.InputChatTheme.Encode(buf)
}