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

229 lines
5.4 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{}
)
// ChatFolderName represents TL type `chatFolderName#ec4d3d9e`.
type ChatFolderName struct {
// The text of the chat folder name; 1-12 characters without line feeds. May contain only
// CustomEmoji entities
Text FormattedText
// True, if custom emoji in the name must be animated
AnimateCustomEmoji bool
}
// ChatFolderNameTypeID is TL type id of ChatFolderName.
const ChatFolderNameTypeID = 0xec4d3d9e
// Ensuring interfaces in compile-time for ChatFolderName.
var (
_ bin.Encoder = &ChatFolderName{}
_ bin.Decoder = &ChatFolderName{}
_ bin.BareEncoder = &ChatFolderName{}
_ bin.BareDecoder = &ChatFolderName{}
)
func (c *ChatFolderName) Zero() bool {
if c == nil {
return true
}
if !(c.Text.Zero()) {
return false
}
if !(c.AnimateCustomEmoji == false) {
return false
}
return true
}
// String implements fmt.Stringer.
func (c *ChatFolderName) String() string {
if c == nil {
return "ChatFolderName(nil)"
}
type Alias ChatFolderName
return fmt.Sprintf("ChatFolderName%+v", Alias(*c))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*ChatFolderName) TypeID() uint32 {
return ChatFolderNameTypeID
}
// TypeName returns name of type in TL schema.
func (*ChatFolderName) TypeName() string {
return "chatFolderName"
}
// TypeInfo returns info about TL type.
func (c *ChatFolderName) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "chatFolderName",
ID: ChatFolderNameTypeID,
}
if c == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Text",
SchemaName: "text",
},
{
Name: "AnimateCustomEmoji",
SchemaName: "animate_custom_emoji",
},
}
return typ
}
// Encode implements bin.Encoder.
func (c *ChatFolderName) Encode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode chatFolderName#ec4d3d9e as nil")
}
b.PutID(ChatFolderNameTypeID)
return c.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (c *ChatFolderName) EncodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode chatFolderName#ec4d3d9e as nil")
}
if err := c.Text.Encode(b); err != nil {
return fmt.Errorf("unable to encode chatFolderName#ec4d3d9e: field text: %w", err)
}
b.PutBool(c.AnimateCustomEmoji)
return nil
}
// Decode implements bin.Decoder.
func (c *ChatFolderName) Decode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode chatFolderName#ec4d3d9e to nil")
}
if err := b.ConsumeID(ChatFolderNameTypeID); err != nil {
return fmt.Errorf("unable to decode chatFolderName#ec4d3d9e: %w", err)
}
return c.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (c *ChatFolderName) DecodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode chatFolderName#ec4d3d9e to nil")
}
{
if err := c.Text.Decode(b); err != nil {
return fmt.Errorf("unable to decode chatFolderName#ec4d3d9e: field text: %w", err)
}
}
{
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode chatFolderName#ec4d3d9e: field animate_custom_emoji: %w", err)
}
c.AnimateCustomEmoji = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *ChatFolderName) EncodeTDLibJSON(b tdjson.Encoder) error {
if c == nil {
return fmt.Errorf("can't encode chatFolderName#ec4d3d9e as nil")
}
b.ObjStart()
b.PutID("chatFolderName")
b.Comma()
b.FieldStart("text")
if err := c.Text.EncodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to encode chatFolderName#ec4d3d9e: field text: %w", err)
}
b.Comma()
b.FieldStart("animate_custom_emoji")
b.PutBool(c.AnimateCustomEmoji)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *ChatFolderName) DecodeTDLibJSON(b tdjson.Decoder) error {
if c == nil {
return fmt.Errorf("can't decode chatFolderName#ec4d3d9e to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("chatFolderName"); err != nil {
return fmt.Errorf("unable to decode chatFolderName#ec4d3d9e: %w", err)
}
case "text":
if err := c.Text.DecodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to decode chatFolderName#ec4d3d9e: field text: %w", err)
}
case "animate_custom_emoji":
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode chatFolderName#ec4d3d9e: field animate_custom_emoji: %w", err)
}
c.AnimateCustomEmoji = value
default:
return b.Skip()
}
return nil
})
}
// GetText returns value of Text field.
func (c *ChatFolderName) GetText() (value FormattedText) {
if c == nil {
return
}
return c.Text
}
// GetAnimateCustomEmoji returns value of AnimateCustomEmoji field.
func (c *ChatFolderName) GetAnimateCustomEmoji() (value bool) {
if c == nil {
return
}
return c.AnimateCustomEmoji
}