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 MessagesMessageReactionsList struct {
Flags bin .Fields
Count int
Reactions []MessagePeerReaction
Chats []ChatClass
Users []UserClass
NextOffset string
}
const MessagesMessageReactionsListTypeID = 0x31bd492d
var (
_ bin .Encoder = &MessagesMessageReactionsList {}
_ bin .Decoder = &MessagesMessageReactionsList {}
_ bin .BareEncoder = &MessagesMessageReactionsList {}
_ bin .BareDecoder = &MessagesMessageReactionsList {}
)
func (m *MessagesMessageReactionsList ) Zero () bool {
if m == nil {
return true
}
if !(m .Flags .Zero ()) {
return false
}
if !(m .Count == 0 ) {
return false
}
if !(m .Reactions == nil ) {
return false
}
if !(m .Chats == nil ) {
return false
}
if !(m .Users == nil ) {
return false
}
if !(m .NextOffset == "" ) {
return false
}
return true
}
func (m *MessagesMessageReactionsList ) String () string {
if m == nil {
return "MessagesMessageReactionsList(nil)"
}
type Alias MessagesMessageReactionsList
return fmt .Sprintf ("MessagesMessageReactionsList%+v" , Alias (*m ))
}
func (m *MessagesMessageReactionsList ) FillFrom (from interface {
GetCount () (value int )
GetReactions () (value []MessagePeerReaction )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
GetNextOffset () (value string , ok bool )
}) {
m .Count = from .GetCount ()
m .Reactions = from .GetReactions ()
m .Chats = from .GetChats ()
m .Users = from .GetUsers ()
if val , ok := from .GetNextOffset (); ok {
m .NextOffset = val
}
}
func (*MessagesMessageReactionsList ) TypeID () uint32 {
return MessagesMessageReactionsListTypeID
}
func (*MessagesMessageReactionsList ) TypeName () string {
return "messages.messageReactionsList"
}
func (m *MessagesMessageReactionsList ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.messageReactionsList" ,
ID : MessagesMessageReactionsListTypeID ,
}
if m == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Count" ,
SchemaName : "count" ,
},
{
Name : "Reactions" ,
SchemaName : "reactions" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
{
Name : "NextOffset" ,
SchemaName : "next_offset" ,
Null : !m .Flags .Has (0 ),
},
}
return typ
}
func (m *MessagesMessageReactionsList ) SetFlags () {
if !(m .NextOffset == "" ) {
m .Flags .Set (0 )
}
}
func (m *MessagesMessageReactionsList ) Encode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode messages.messageReactionsList#31bd492d as nil" )
}
b .PutID (MessagesMessageReactionsListTypeID )
return m .EncodeBare (b )
}
func (m *MessagesMessageReactionsList ) EncodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode messages.messageReactionsList#31bd492d as nil" )
}
m .SetFlags ()
if err := m .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.messageReactionsList#31bd492d: field flags: %w" , err )
}
b .PutInt (m .Count )
b .PutVectorHeader (len (m .Reactions ))
for idx , v := range m .Reactions {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.messageReactionsList#31bd492d: field reactions element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (m .Chats ))
for idx , v := range m .Chats {
if v == nil {
return fmt .Errorf ("unable to encode messages.messageReactionsList#31bd492d: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.messageReactionsList#31bd492d: field chats element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (m .Users ))
for idx , v := range m .Users {
if v == nil {
return fmt .Errorf ("unable to encode messages.messageReactionsList#31bd492d: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.messageReactionsList#31bd492d: field users element with index %d: %w" , idx , err )
}
}
if m .Flags .Has (0 ) {
b .PutString (m .NextOffset )
}
return nil
}
func (m *MessagesMessageReactionsList ) Decode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode messages.messageReactionsList#31bd492d to nil" )
}
if err := b .ConsumeID (MessagesMessageReactionsListTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.messageReactionsList#31bd492d: %w" , err )
}
return m .DecodeBare (b )
}
func (m *MessagesMessageReactionsList ) DecodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode messages.messageReactionsList#31bd492d to nil" )
}
{
if err := m .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.messageReactionsList#31bd492d: field flags: %w" , err )
}
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.messageReactionsList#31bd492d: field count: %w" , err )
}
m .Count = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.messageReactionsList#31bd492d: field reactions: %w" , err )
}
if headerLen > 0 {
m .Reactions = make ([]MessagePeerReaction , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value MessagePeerReaction
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.messageReactionsList#31bd492d: field reactions: %w" , err )
}
m .Reactions = append (m .Reactions , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.messageReactionsList#31bd492d: field chats: %w" , err )
}
if headerLen > 0 {
m .Chats = make ([]ChatClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeChat (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.messageReactionsList#31bd492d: field chats: %w" , err )
}
m .Chats = append (m .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.messageReactionsList#31bd492d: field users: %w" , err )
}
if headerLen > 0 {
m .Users = make ([]UserClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeUser (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.messageReactionsList#31bd492d: field users: %w" , err )
}
m .Users = append (m .Users , value )
}
}
if m .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.messageReactionsList#31bd492d: field next_offset: %w" , err )
}
m .NextOffset = value
}
return nil
}
func (m *MessagesMessageReactionsList ) GetCount () (value int ) {
if m == nil {
return
}
return m .Count
}
func (m *MessagesMessageReactionsList ) GetReactions () (value []MessagePeerReaction ) {
if m == nil {
return
}
return m .Reactions
}
func (m *MessagesMessageReactionsList ) GetChats () (value []ChatClass ) {
if m == nil {
return
}
return m .Chats
}
func (m *MessagesMessageReactionsList ) GetUsers () (value []UserClass ) {
if m == nil {
return
}
return m .Users
}
func (m *MessagesMessageReactionsList ) SetNextOffset (value string ) {
m .Flags .Set (0 )
m .NextOffset = value
}
func (m *MessagesMessageReactionsList ) GetNextOffset () (value string , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (0 ) {
return value , false
}
return m .NextOffset , true
}
func (m *MessagesMessageReactionsList ) MapChats () (value ChatClassArray ) {
return ChatClassArray (m .Chats )
}
func (m *MessagesMessageReactionsList ) MapUsers () (value UserClassArray ) {
return UserClassArray (m .Users )
}
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 .