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 ChatReactionsNone struct {
}
const ChatReactionsNoneTypeID = 0xeafc32bc
func (c ChatReactionsNone ) construct () ChatReactionsClass { return &c }
var (
_ bin .Encoder = &ChatReactionsNone {}
_ bin .Decoder = &ChatReactionsNone {}
_ bin .BareEncoder = &ChatReactionsNone {}
_ bin .BareDecoder = &ChatReactionsNone {}
_ ChatReactionsClass = &ChatReactionsNone {}
)
func (c *ChatReactionsNone ) Zero () bool {
if c == nil {
return true
}
return true
}
func (c *ChatReactionsNone ) String () string {
if c == nil {
return "ChatReactionsNone(nil)"
}
type Alias ChatReactionsNone
return fmt .Sprintf ("ChatReactionsNone%+v" , Alias (*c ))
}
func (*ChatReactionsNone ) TypeID () uint32 {
return ChatReactionsNoneTypeID
}
func (*ChatReactionsNone ) TypeName () string {
return "chatReactionsNone"
}
func (c *ChatReactionsNone ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chatReactionsNone" ,
ID : ChatReactionsNoneTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (c *ChatReactionsNone ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatReactionsNone#eafc32bc as nil" )
}
b .PutID (ChatReactionsNoneTypeID )
return c .EncodeBare (b )
}
func (c *ChatReactionsNone ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatReactionsNone#eafc32bc as nil" )
}
return nil
}
func (c *ChatReactionsNone ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatReactionsNone#eafc32bc to nil" )
}
if err := b .ConsumeID (ChatReactionsNoneTypeID ); err != nil {
return fmt .Errorf ("unable to decode chatReactionsNone#eafc32bc: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChatReactionsNone ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatReactionsNone#eafc32bc to nil" )
}
return nil
}
type ChatReactionsAll struct {
Flags bin .Fields
AllowCustom bool
}
const ChatReactionsAllTypeID = 0x52928bca
func (c ChatReactionsAll ) construct () ChatReactionsClass { return &c }
var (
_ bin .Encoder = &ChatReactionsAll {}
_ bin .Decoder = &ChatReactionsAll {}
_ bin .BareEncoder = &ChatReactionsAll {}
_ bin .BareDecoder = &ChatReactionsAll {}
_ ChatReactionsClass = &ChatReactionsAll {}
)
func (c *ChatReactionsAll ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .AllowCustom == false ) {
return false
}
return true
}
func (c *ChatReactionsAll ) String () string {
if c == nil {
return "ChatReactionsAll(nil)"
}
type Alias ChatReactionsAll
return fmt .Sprintf ("ChatReactionsAll%+v" , Alias (*c ))
}
func (c *ChatReactionsAll ) FillFrom (from interface {
GetAllowCustom () (value bool )
}) {
c .AllowCustom = from .GetAllowCustom ()
}
func (*ChatReactionsAll ) TypeID () uint32 {
return ChatReactionsAllTypeID
}
func (*ChatReactionsAll ) TypeName () string {
return "chatReactionsAll"
}
func (c *ChatReactionsAll ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chatReactionsAll" ,
ID : ChatReactionsAllTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "AllowCustom" ,
SchemaName : "allow_custom" ,
Null : !c .Flags .Has (0 ),
},
}
return typ
}
func (c *ChatReactionsAll ) SetFlags () {
if !(c .AllowCustom == false ) {
c .Flags .Set (0 )
}
}
func (c *ChatReactionsAll ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatReactionsAll#52928bca as nil" )
}
b .PutID (ChatReactionsAllTypeID )
return c .EncodeBare (b )
}
func (c *ChatReactionsAll ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatReactionsAll#52928bca as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chatReactionsAll#52928bca: field flags: %w" , err )
}
return nil
}
func (c *ChatReactionsAll ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatReactionsAll#52928bca to nil" )
}
if err := b .ConsumeID (ChatReactionsAllTypeID ); err != nil {
return fmt .Errorf ("unable to decode chatReactionsAll#52928bca: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChatReactionsAll ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatReactionsAll#52928bca to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode chatReactionsAll#52928bca: field flags: %w" , err )
}
}
c .AllowCustom = c .Flags .Has (0 )
return nil
}
func (c *ChatReactionsAll ) SetAllowCustom (value bool ) {
if value {
c .Flags .Set (0 )
c .AllowCustom = true
} else {
c .Flags .Unset (0 )
c .AllowCustom = false
}
}
func (c *ChatReactionsAll ) GetAllowCustom () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (0 )
}
type ChatReactionsSome struct {
Reactions []ReactionClass
}
const ChatReactionsSomeTypeID = 0x661d4037
func (c ChatReactionsSome ) construct () ChatReactionsClass { return &c }
var (
_ bin .Encoder = &ChatReactionsSome {}
_ bin .Decoder = &ChatReactionsSome {}
_ bin .BareEncoder = &ChatReactionsSome {}
_ bin .BareDecoder = &ChatReactionsSome {}
_ ChatReactionsClass = &ChatReactionsSome {}
)
func (c *ChatReactionsSome ) Zero () bool {
if c == nil {
return true
}
if !(c .Reactions == nil ) {
return false
}
return true
}
func (c *ChatReactionsSome ) String () string {
if c == nil {
return "ChatReactionsSome(nil)"
}
type Alias ChatReactionsSome
return fmt .Sprintf ("ChatReactionsSome%+v" , Alias (*c ))
}
func (c *ChatReactionsSome ) FillFrom (from interface {
GetReactions () (value []ReactionClass )
}) {
c .Reactions = from .GetReactions ()
}
func (*ChatReactionsSome ) TypeID () uint32 {
return ChatReactionsSomeTypeID
}
func (*ChatReactionsSome ) TypeName () string {
return "chatReactionsSome"
}
func (c *ChatReactionsSome ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chatReactionsSome" ,
ID : ChatReactionsSomeTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Reactions" ,
SchemaName : "reactions" ,
},
}
return typ
}
func (c *ChatReactionsSome ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatReactionsSome#661d4037 as nil" )
}
b .PutID (ChatReactionsSomeTypeID )
return c .EncodeBare (b )
}
func (c *ChatReactionsSome ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatReactionsSome#661d4037 as nil" )
}
b .PutVectorHeader (len (c .Reactions ))
for idx , v := range c .Reactions {
if v == nil {
return fmt .Errorf ("unable to encode chatReactionsSome#661d4037: field reactions element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chatReactionsSome#661d4037: field reactions element with index %d: %w" , idx , err )
}
}
return nil
}
func (c *ChatReactionsSome ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatReactionsSome#661d4037 to nil" )
}
if err := b .ConsumeID (ChatReactionsSomeTypeID ); err != nil {
return fmt .Errorf ("unable to decode chatReactionsSome#661d4037: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChatReactionsSome ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatReactionsSome#661d4037 to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode chatReactionsSome#661d4037: field reactions: %w" , err )
}
if headerLen > 0 {
c .Reactions = make ([]ReactionClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeReaction (b )
if err != nil {
return fmt .Errorf ("unable to decode chatReactionsSome#661d4037: field reactions: %w" , err )
}
c .Reactions = append (c .Reactions , value )
}
}
return nil
}
func (c *ChatReactionsSome ) GetReactions () (value []ReactionClass ) {
if c == nil {
return
}
return c .Reactions
}
func (c *ChatReactionsSome ) MapReactions () (value ReactionClassArray ) {
return ReactionClassArray (c .Reactions )
}
const ChatReactionsClassName = "ChatReactions"
type ChatReactionsClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () ChatReactionsClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeChatReactions (buf *bin .Buffer ) (ChatReactionsClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case ChatReactionsNoneTypeID :
v := ChatReactionsNone {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ChatReactionsClass: %w" , err )
}
return &v , nil
case ChatReactionsAllTypeID :
v := ChatReactionsAll {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ChatReactionsClass: %w" , err )
}
return &v , nil
case ChatReactionsSomeTypeID :
v := ChatReactionsSome {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ChatReactionsClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode ChatReactionsClass: %w" , bin .NewUnexpectedID (id ))
}
}
type ChatReactionsBox struct {
ChatReactions ChatReactionsClass
}
func (b *ChatReactionsBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode ChatReactionsBox to nil" )
}
v , err := DecodeChatReactions (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .ChatReactions = v
return nil
}
func (b *ChatReactionsBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .ChatReactions == nil {
return fmt .Errorf ("unable to encode ChatReactionsClass as nil" )
}
return b .ChatReactions .Encode (buf )
}
The pages are generated with Golds v0.6.7 . (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 @Go100and1 (reachable from the left QR code) to get the latest news of Golds .