package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type ChatTheme struct {
Emoticon string
}
const ChatThemeTypeID = 0xc3dffc04
func (c ChatTheme ) construct () ChatThemeClass { return &c }
var (
_ bin .Encoder = &ChatTheme {}
_ bin .Decoder = &ChatTheme {}
_ bin .BareEncoder = &ChatTheme {}
_ bin .BareDecoder = &ChatTheme {}
_ ChatThemeClass = &ChatTheme {}
)
func (c *ChatTheme ) Zero () bool {
if c == nil {
return true
}
if !(c .Emoticon == "" ) {
return false
}
return true
}
func (c *ChatTheme ) String () string {
if c == nil {
return "ChatTheme(nil)"
}
type Alias ChatTheme
return fmt .Sprintf ("ChatTheme%+v" , Alias (*c ))
}
func (c *ChatTheme ) FillFrom (from interface {
GetEmoticon () (value string )
}) {
c .Emoticon = from .GetEmoticon ()
}
func (*ChatTheme ) TypeID () uint32 {
return ChatThemeTypeID
}
func (*ChatTheme ) TypeName () string {
return "chatTheme"
}
func (c *ChatTheme ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chatTheme" ,
ID : ChatThemeTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Emoticon" ,
SchemaName : "emoticon" ,
},
}
return typ
}
func (c *ChatTheme ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatTheme#c3dffc04 as nil" )
}
b .PutID (ChatThemeTypeID )
return c .EncodeBare (b )
}
func (c *ChatTheme ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatTheme#c3dffc04 as nil" )
}
b .PutString (c .Emoticon )
return nil
}
func (c *ChatTheme ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatTheme#c3dffc04 to nil" )
}
if err := b .ConsumeID (ChatThemeTypeID ); err != nil {
return fmt .Errorf ("unable to decode chatTheme#c3dffc04: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChatTheme ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatTheme#c3dffc04 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode chatTheme#c3dffc04: field emoticon: %w" , err )
}
c .Emoticon = value
}
return nil
}
func (c *ChatTheme ) GetEmoticon () (value string ) {
if c == nil {
return
}
return c .Emoticon
}
type ChatThemeUniqueGift struct {
Gift StarGiftClass
ThemeSettings []ThemeSettings
}
const ChatThemeUniqueGiftTypeID = 0x3458f9c8
func (c ChatThemeUniqueGift ) construct () ChatThemeClass { return &c }
var (
_ bin .Encoder = &ChatThemeUniqueGift {}
_ bin .Decoder = &ChatThemeUniqueGift {}
_ bin .BareEncoder = &ChatThemeUniqueGift {}
_ bin .BareDecoder = &ChatThemeUniqueGift {}
_ ChatThemeClass = &ChatThemeUniqueGift {}
)
func (c *ChatThemeUniqueGift ) Zero () bool {
if c == nil {
return true
}
if !(c .Gift == nil ) {
return false
}
if !(c .ThemeSettings == nil ) {
return false
}
return true
}
func (c *ChatThemeUniqueGift ) String () string {
if c == nil {
return "ChatThemeUniqueGift(nil)"
}
type Alias ChatThemeUniqueGift
return fmt .Sprintf ("ChatThemeUniqueGift%+v" , Alias (*c ))
}
func (c *ChatThemeUniqueGift ) FillFrom (from interface {
GetGift () (value StarGiftClass )
GetThemeSettings () (value []ThemeSettings )
}) {
c .Gift = from .GetGift ()
c .ThemeSettings = from .GetThemeSettings ()
}
func (*ChatThemeUniqueGift ) TypeID () uint32 {
return ChatThemeUniqueGiftTypeID
}
func (*ChatThemeUniqueGift ) TypeName () string {
return "chatThemeUniqueGift"
}
func (c *ChatThemeUniqueGift ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chatThemeUniqueGift" ,
ID : ChatThemeUniqueGiftTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Gift" ,
SchemaName : "gift" ,
},
{
Name : "ThemeSettings" ,
SchemaName : "theme_settings" ,
},
}
return typ
}
func (c *ChatThemeUniqueGift ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatThemeUniqueGift#3458f9c8 as nil" )
}
b .PutID (ChatThemeUniqueGiftTypeID )
return c .EncodeBare (b )
}
func (c *ChatThemeUniqueGift ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatThemeUniqueGift#3458f9c8 as nil" )
}
if c .Gift == nil {
return fmt .Errorf ("unable to encode chatThemeUniqueGift#3458f9c8: field gift is nil" )
}
if err := c .Gift .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chatThemeUniqueGift#3458f9c8: field gift: %w" , err )
}
b .PutVectorHeader (len (c .ThemeSettings ))
for idx , v := range c .ThemeSettings {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chatThemeUniqueGift#3458f9c8: field theme_settings element with index %d: %w" , idx , err )
}
}
return nil
}
func (c *ChatThemeUniqueGift ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatThemeUniqueGift#3458f9c8 to nil" )
}
if err := b .ConsumeID (ChatThemeUniqueGiftTypeID ); err != nil {
return fmt .Errorf ("unable to decode chatThemeUniqueGift#3458f9c8: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChatThemeUniqueGift ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatThemeUniqueGift#3458f9c8 to nil" )
}
{
value , err := DecodeStarGift (b )
if err != nil {
return fmt .Errorf ("unable to decode chatThemeUniqueGift#3458f9c8: field gift: %w" , err )
}
c .Gift = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode chatThemeUniqueGift#3458f9c8: field theme_settings: %w" , err )
}
if headerLen > 0 {
c .ThemeSettings = make ([]ThemeSettings , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value ThemeSettings
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode chatThemeUniqueGift#3458f9c8: field theme_settings: %w" , err )
}
c .ThemeSettings = append (c .ThemeSettings , value )
}
}
return nil
}
func (c *ChatThemeUniqueGift ) GetGift () (value StarGiftClass ) {
if c == nil {
return
}
return c .Gift
}
func (c *ChatThemeUniqueGift ) GetThemeSettings () (value []ThemeSettings ) {
if c == nil {
return
}
return c .ThemeSettings
}
const ChatThemeClassName = "ChatTheme"
type ChatThemeClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () ChatThemeClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func (c *ChatTheme ) AsInput () *InputChatTheme {
value := new (InputChatTheme )
value .Emoticon = c .GetEmoticon ()
return value
}
func DecodeChatTheme (buf *bin .Buffer ) (ChatThemeClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case ChatThemeTypeID :
v := ChatTheme {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ChatThemeClass: %w" , err )
}
return &v , nil
case ChatThemeUniqueGiftTypeID :
v := ChatThemeUniqueGift {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ChatThemeClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode ChatThemeClass: %w" , bin .NewUnexpectedID (id ))
}
}
type ChatThemeBox struct {
ChatTheme ChatThemeClass
}
func (b *ChatThemeBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode ChatThemeBox to nil" )
}
v , err := DecodeChatTheme (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .ChatTheme = v
return nil
}
func (b *ChatThemeBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .ChatTheme == nil {
return fmt .Errorf ("unable to encode ChatThemeClass as nil" )
}
return b .ChatTheme .Encode (buf )
}
The pages are generated with Golds v0.8.4 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .