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 MessagesAvailableReactionsNotModified struct {
}
const MessagesAvailableReactionsNotModifiedTypeID = 0x9f071957
func (a MessagesAvailableReactionsNotModified ) construct () MessagesAvailableReactionsClass { return &a }
var (
_ bin .Encoder = &MessagesAvailableReactionsNotModified {}
_ bin .Decoder = &MessagesAvailableReactionsNotModified {}
_ bin .BareEncoder = &MessagesAvailableReactionsNotModified {}
_ bin .BareDecoder = &MessagesAvailableReactionsNotModified {}
_ MessagesAvailableReactionsClass = &MessagesAvailableReactionsNotModified {}
)
func (a *MessagesAvailableReactionsNotModified ) Zero () bool {
if a == nil {
return true
}
return true
}
func (a *MessagesAvailableReactionsNotModified ) String () string {
if a == nil {
return "MessagesAvailableReactionsNotModified(nil)"
}
type Alias MessagesAvailableReactionsNotModified
return fmt .Sprintf ("MessagesAvailableReactionsNotModified%+v" , Alias (*a ))
}
func (*MessagesAvailableReactionsNotModified ) TypeID () uint32 {
return MessagesAvailableReactionsNotModifiedTypeID
}
func (*MessagesAvailableReactionsNotModified ) TypeName () string {
return "messages.availableReactionsNotModified"
}
func (a *MessagesAvailableReactionsNotModified ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.availableReactionsNotModified" ,
ID : MessagesAvailableReactionsNotModifiedTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (a *MessagesAvailableReactionsNotModified ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode messages.availableReactionsNotModified#9f071957 as nil" )
}
b .PutID (MessagesAvailableReactionsNotModifiedTypeID )
return a .EncodeBare (b )
}
func (a *MessagesAvailableReactionsNotModified ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode messages.availableReactionsNotModified#9f071957 as nil" )
}
return nil
}
func (a *MessagesAvailableReactionsNotModified ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode messages.availableReactionsNotModified#9f071957 to nil" )
}
if err := b .ConsumeID (MessagesAvailableReactionsNotModifiedTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.availableReactionsNotModified#9f071957: %w" , err )
}
return a .DecodeBare (b )
}
func (a *MessagesAvailableReactionsNotModified ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode messages.availableReactionsNotModified#9f071957 to nil" )
}
return nil
}
type MessagesAvailableReactions struct {
Hash int
Reactions []AvailableReaction
}
const MessagesAvailableReactionsTypeID = 0x768e3aad
func (a MessagesAvailableReactions ) construct () MessagesAvailableReactionsClass { return &a }
var (
_ bin .Encoder = &MessagesAvailableReactions {}
_ bin .Decoder = &MessagesAvailableReactions {}
_ bin .BareEncoder = &MessagesAvailableReactions {}
_ bin .BareDecoder = &MessagesAvailableReactions {}
_ MessagesAvailableReactionsClass = &MessagesAvailableReactions {}
)
func (a *MessagesAvailableReactions ) Zero () bool {
if a == nil {
return true
}
if !(a .Hash == 0 ) {
return false
}
if !(a .Reactions == nil ) {
return false
}
return true
}
func (a *MessagesAvailableReactions ) String () string {
if a == nil {
return "MessagesAvailableReactions(nil)"
}
type Alias MessagesAvailableReactions
return fmt .Sprintf ("MessagesAvailableReactions%+v" , Alias (*a ))
}
func (a *MessagesAvailableReactions ) FillFrom (from interface {
GetHash () (value int )
GetReactions () (value []AvailableReaction )
}) {
a .Hash = from .GetHash ()
a .Reactions = from .GetReactions ()
}
func (*MessagesAvailableReactions ) TypeID () uint32 {
return MessagesAvailableReactionsTypeID
}
func (*MessagesAvailableReactions ) TypeName () string {
return "messages.availableReactions"
}
func (a *MessagesAvailableReactions ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.availableReactions" ,
ID : MessagesAvailableReactionsTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Hash" ,
SchemaName : "hash" ,
},
{
Name : "Reactions" ,
SchemaName : "reactions" ,
},
}
return typ
}
func (a *MessagesAvailableReactions ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode messages.availableReactions#768e3aad as nil" )
}
b .PutID (MessagesAvailableReactionsTypeID )
return a .EncodeBare (b )
}
func (a *MessagesAvailableReactions ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode messages.availableReactions#768e3aad as nil" )
}
b .PutInt (a .Hash )
b .PutVectorHeader (len (a .Reactions ))
for idx , v := range a .Reactions {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.availableReactions#768e3aad: field reactions element with index %d: %w" , idx , err )
}
}
return nil
}
func (a *MessagesAvailableReactions ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode messages.availableReactions#768e3aad to nil" )
}
if err := b .ConsumeID (MessagesAvailableReactionsTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.availableReactions#768e3aad: %w" , err )
}
return a .DecodeBare (b )
}
func (a *MessagesAvailableReactions ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode messages.availableReactions#768e3aad to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.availableReactions#768e3aad: field hash: %w" , err )
}
a .Hash = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.availableReactions#768e3aad: field reactions: %w" , err )
}
if headerLen > 0 {
a .Reactions = make ([]AvailableReaction , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value AvailableReaction
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.availableReactions#768e3aad: field reactions: %w" , err )
}
a .Reactions = append (a .Reactions , value )
}
}
return nil
}
func (a *MessagesAvailableReactions ) GetHash () (value int ) {
if a == nil {
return
}
return a .Hash
}
func (a *MessagesAvailableReactions ) GetReactions () (value []AvailableReaction ) {
if a == nil {
return
}
return a .Reactions
}
const MessagesAvailableReactionsClassName = "messages.AvailableReactions"
type MessagesAvailableReactionsClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () MessagesAvailableReactionsClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsModified () (*MessagesAvailableReactions , bool )
}
func (a *MessagesAvailableReactionsNotModified ) AsModified () (*MessagesAvailableReactions , bool ) {
return nil , false
}
func (a *MessagesAvailableReactions ) AsModified () (*MessagesAvailableReactions , bool ) {
return a , true
}
func DecodeMessagesAvailableReactions (buf *bin .Buffer ) (MessagesAvailableReactionsClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case MessagesAvailableReactionsNotModifiedTypeID :
v := MessagesAvailableReactionsNotModified {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessagesAvailableReactionsClass: %w" , err )
}
return &v , nil
case MessagesAvailableReactionsTypeID :
v := MessagesAvailableReactions {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessagesAvailableReactionsClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode MessagesAvailableReactionsClass: %w" , bin .NewUnexpectedID (id ))
}
}
type MessagesAvailableReactionsBox struct {
AvailableReactions MessagesAvailableReactionsClass
}
func (b *MessagesAvailableReactionsBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode MessagesAvailableReactionsBox to nil" )
}
v , err := DecodeMessagesAvailableReactions (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .AvailableReactions = v
return nil
}
func (b *MessagesAvailableReactionsBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .AvailableReactions == nil {
return fmt .Errorf ("unable to encode MessagesAvailableReactionsClass as nil" )
}
return b .AvailableReactions .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 .