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 MessagesMessages struct {
Messages []MessageClass
Chats []ChatClass
Users []UserClass
}
const MessagesMessagesTypeID = 0x8c718e87
func (m MessagesMessages ) construct () MessagesMessagesClass { return &m }
var (
_ bin .Encoder = &MessagesMessages {}
_ bin .Decoder = &MessagesMessages {}
_ bin .BareEncoder = &MessagesMessages {}
_ bin .BareDecoder = &MessagesMessages {}
_ MessagesMessagesClass = &MessagesMessages {}
)
func (m *MessagesMessages ) Zero () bool {
if m == nil {
return true
}
if !(m .Messages == nil ) {
return false
}
if !(m .Chats == nil ) {
return false
}
if !(m .Users == nil ) {
return false
}
return true
}
func (m *MessagesMessages ) String () string {
if m == nil {
return "MessagesMessages(nil)"
}
type Alias MessagesMessages
return fmt .Sprintf ("MessagesMessages%+v" , Alias (*m ))
}
func (m *MessagesMessages ) FillFrom (from interface {
GetMessages () (value []MessageClass )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
m .Messages = from .GetMessages ()
m .Chats = from .GetChats ()
m .Users = from .GetUsers ()
}
func (*MessagesMessages ) TypeID () uint32 {
return MessagesMessagesTypeID
}
func (*MessagesMessages ) TypeName () string {
return "messages.messages"
}
func (m *MessagesMessages ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.messages" ,
ID : MessagesMessagesTypeID ,
}
if m == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Messages" ,
SchemaName : "messages" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (m *MessagesMessages ) Encode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode messages.messages#8c718e87 as nil" )
}
b .PutID (MessagesMessagesTypeID )
return m .EncodeBare (b )
}
func (m *MessagesMessages ) EncodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode messages.messages#8c718e87 as nil" )
}
b .PutVectorHeader (len (m .Messages ))
for idx , v := range m .Messages {
if v == nil {
return fmt .Errorf ("unable to encode messages.messages#8c718e87: field messages element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.messages#8c718e87: field messages 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.messages#8c718e87: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.messages#8c718e87: 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.messages#8c718e87: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.messages#8c718e87: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (m *MessagesMessages ) Decode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode messages.messages#8c718e87 to nil" )
}
if err := b .ConsumeID (MessagesMessagesTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.messages#8c718e87: %w" , err )
}
return m .DecodeBare (b )
}
func (m *MessagesMessages ) DecodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode messages.messages#8c718e87 to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.messages#8c718e87: field messages: %w" , err )
}
if headerLen > 0 {
m .Messages = make ([]MessageClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeMessage (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.messages#8c718e87: field messages: %w" , err )
}
m .Messages = append (m .Messages , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.messages#8c718e87: 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.messages#8c718e87: field chats: %w" , err )
}
m .Chats = append (m .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.messages#8c718e87: 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.messages#8c718e87: field users: %w" , err )
}
m .Users = append (m .Users , value )
}
}
return nil
}
func (m *MessagesMessages ) GetMessages () (value []MessageClass ) {
if m == nil {
return
}
return m .Messages
}
func (m *MessagesMessages ) GetChats () (value []ChatClass ) {
if m == nil {
return
}
return m .Chats
}
func (m *MessagesMessages ) GetUsers () (value []UserClass ) {
if m == nil {
return
}
return m .Users
}
func (m *MessagesMessages ) MapMessages () (value MessageClassArray ) {
return MessageClassArray (m .Messages )
}
func (m *MessagesMessages ) MapChats () (value ChatClassArray ) {
return ChatClassArray (m .Chats )
}
func (m *MessagesMessages ) MapUsers () (value UserClassArray ) {
return UserClassArray (m .Users )
}
type MessagesMessagesSlice struct {
Flags bin .Fields
Inexact bool
Count int
NextRate int
OffsetIDOffset int
Messages []MessageClass
Chats []ChatClass
Users []UserClass
}
const MessagesMessagesSliceTypeID = 0x3a54685e
func (m MessagesMessagesSlice ) construct () MessagesMessagesClass { return &m }
var (
_ bin .Encoder = &MessagesMessagesSlice {}
_ bin .Decoder = &MessagesMessagesSlice {}
_ bin .BareEncoder = &MessagesMessagesSlice {}
_ bin .BareDecoder = &MessagesMessagesSlice {}
_ MessagesMessagesClass = &MessagesMessagesSlice {}
)
func (m *MessagesMessagesSlice ) Zero () bool {
if m == nil {
return true
}
if !(m .Flags .Zero ()) {
return false
}
if !(m .Inexact == false ) {
return false
}
if !(m .Count == 0 ) {
return false
}
if !(m .NextRate == 0 ) {
return false
}
if !(m .OffsetIDOffset == 0 ) {
return false
}
if !(m .Messages == nil ) {
return false
}
if !(m .Chats == nil ) {
return false
}
if !(m .Users == nil ) {
return false
}
return true
}
func (m *MessagesMessagesSlice ) String () string {
if m == nil {
return "MessagesMessagesSlice(nil)"
}
type Alias MessagesMessagesSlice
return fmt .Sprintf ("MessagesMessagesSlice%+v" , Alias (*m ))
}
func (m *MessagesMessagesSlice ) FillFrom (from interface {
GetInexact () (value bool )
GetCount () (value int )
GetNextRate () (value int , ok bool )
GetOffsetIDOffset () (value int , ok bool )
GetMessages () (value []MessageClass )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
m .Inexact = from .GetInexact ()
m .Count = from .GetCount ()
if val , ok := from .GetNextRate (); ok {
m .NextRate = val
}
if val , ok := from .GetOffsetIDOffset (); ok {
m .OffsetIDOffset = val
}
m .Messages = from .GetMessages ()
m .Chats = from .GetChats ()
m .Users = from .GetUsers ()
}
func (*MessagesMessagesSlice ) TypeID () uint32 {
return MessagesMessagesSliceTypeID
}
func (*MessagesMessagesSlice ) TypeName () string {
return "messages.messagesSlice"
}
func (m *MessagesMessagesSlice ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.messagesSlice" ,
ID : MessagesMessagesSliceTypeID ,
}
if m == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Inexact" ,
SchemaName : "inexact" ,
Null : !m .Flags .Has (1 ),
},
{
Name : "Count" ,
SchemaName : "count" ,
},
{
Name : "NextRate" ,
SchemaName : "next_rate" ,
Null : !m .Flags .Has (0 ),
},
{
Name : "OffsetIDOffset" ,
SchemaName : "offset_id_offset" ,
Null : !m .Flags .Has (2 ),
},
{
Name : "Messages" ,
SchemaName : "messages" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (m *MessagesMessagesSlice ) SetFlags () {
if !(m .Inexact == false ) {
m .Flags .Set (1 )
}
if !(m .NextRate == 0 ) {
m .Flags .Set (0 )
}
if !(m .OffsetIDOffset == 0 ) {
m .Flags .Set (2 )
}
}
func (m *MessagesMessagesSlice ) Encode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode messages.messagesSlice#3a54685e as nil" )
}
b .PutID (MessagesMessagesSliceTypeID )
return m .EncodeBare (b )
}
func (m *MessagesMessagesSlice ) EncodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode messages.messagesSlice#3a54685e as nil" )
}
m .SetFlags ()
if err := m .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.messagesSlice#3a54685e: field flags: %w" , err )
}
b .PutInt (m .Count )
if m .Flags .Has (0 ) {
b .PutInt (m .NextRate )
}
if m .Flags .Has (2 ) {
b .PutInt (m .OffsetIDOffset )
}
b .PutVectorHeader (len (m .Messages ))
for idx , v := range m .Messages {
if v == nil {
return fmt .Errorf ("unable to encode messages.messagesSlice#3a54685e: field messages element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.messagesSlice#3a54685e: field messages 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.messagesSlice#3a54685e: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.messagesSlice#3a54685e: 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.messagesSlice#3a54685e: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.messagesSlice#3a54685e: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (m *MessagesMessagesSlice ) Decode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode messages.messagesSlice#3a54685e to nil" )
}
if err := b .ConsumeID (MessagesMessagesSliceTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.messagesSlice#3a54685e: %w" , err )
}
return m .DecodeBare (b )
}
func (m *MessagesMessagesSlice ) DecodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode messages.messagesSlice#3a54685e to nil" )
}
{
if err := m .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.messagesSlice#3a54685e: field flags: %w" , err )
}
}
m .Inexact = m .Flags .Has (1 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.messagesSlice#3a54685e: field count: %w" , err )
}
m .Count = value
}
if m .Flags .Has (0 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.messagesSlice#3a54685e: field next_rate: %w" , err )
}
m .NextRate = value
}
if m .Flags .Has (2 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.messagesSlice#3a54685e: field offset_id_offset: %w" , err )
}
m .OffsetIDOffset = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.messagesSlice#3a54685e: field messages: %w" , err )
}
if headerLen > 0 {
m .Messages = make ([]MessageClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeMessage (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.messagesSlice#3a54685e: field messages: %w" , err )
}
m .Messages = append (m .Messages , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.messagesSlice#3a54685e: 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.messagesSlice#3a54685e: field chats: %w" , err )
}
m .Chats = append (m .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.messagesSlice#3a54685e: 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.messagesSlice#3a54685e: field users: %w" , err )
}
m .Users = append (m .Users , value )
}
}
return nil
}
func (m *MessagesMessagesSlice ) SetInexact (value bool ) {
if value {
m .Flags .Set (1 )
m .Inexact = true
} else {
m .Flags .Unset (1 )
m .Inexact = false
}
}
func (m *MessagesMessagesSlice ) GetInexact () (value bool ) {
if m == nil {
return
}
return m .Flags .Has (1 )
}
func (m *MessagesMessagesSlice ) GetCount () (value int ) {
if m == nil {
return
}
return m .Count
}
func (m *MessagesMessagesSlice ) SetNextRate (value int ) {
m .Flags .Set (0 )
m .NextRate = value
}
func (m *MessagesMessagesSlice ) GetNextRate () (value int , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (0 ) {
return value , false
}
return m .NextRate , true
}
func (m *MessagesMessagesSlice ) SetOffsetIDOffset (value int ) {
m .Flags .Set (2 )
m .OffsetIDOffset = value
}
func (m *MessagesMessagesSlice ) GetOffsetIDOffset () (value int , ok bool ) {
if m == nil {
return
}
if !m .Flags .Has (2 ) {
return value , false
}
return m .OffsetIDOffset , true
}
func (m *MessagesMessagesSlice ) GetMessages () (value []MessageClass ) {
if m == nil {
return
}
return m .Messages
}
func (m *MessagesMessagesSlice ) GetChats () (value []ChatClass ) {
if m == nil {
return
}
return m .Chats
}
func (m *MessagesMessagesSlice ) GetUsers () (value []UserClass ) {
if m == nil {
return
}
return m .Users
}
func (m *MessagesMessagesSlice ) MapMessages () (value MessageClassArray ) {
return MessageClassArray (m .Messages )
}
func (m *MessagesMessagesSlice ) MapChats () (value ChatClassArray ) {
return ChatClassArray (m .Chats )
}
func (m *MessagesMessagesSlice ) MapUsers () (value UserClassArray ) {
return UserClassArray (m .Users )
}
type MessagesChannelMessages struct {
Flags bin .Fields
Inexact bool
Pts int
Count int
OffsetIDOffset int
Messages []MessageClass
Topics []ForumTopicClass
Chats []ChatClass
Users []UserClass
}
const MessagesChannelMessagesTypeID = 0xc776ba4e
func (c MessagesChannelMessages ) construct () MessagesMessagesClass { return &c }
var (
_ bin .Encoder = &MessagesChannelMessages {}
_ bin .Decoder = &MessagesChannelMessages {}
_ bin .BareEncoder = &MessagesChannelMessages {}
_ bin .BareDecoder = &MessagesChannelMessages {}
_ MessagesMessagesClass = &MessagesChannelMessages {}
)
func (c *MessagesChannelMessages ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .Inexact == false ) {
return false
}
if !(c .Pts == 0 ) {
return false
}
if !(c .Count == 0 ) {
return false
}
if !(c .OffsetIDOffset == 0 ) {
return false
}
if !(c .Messages == nil ) {
return false
}
if !(c .Topics == nil ) {
return false
}
if !(c .Chats == nil ) {
return false
}
if !(c .Users == nil ) {
return false
}
return true
}
func (c *MessagesChannelMessages ) String () string {
if c == nil {
return "MessagesChannelMessages(nil)"
}
type Alias MessagesChannelMessages
return fmt .Sprintf ("MessagesChannelMessages%+v" , Alias (*c ))
}
func (c *MessagesChannelMessages ) FillFrom (from interface {
GetInexact () (value bool )
GetPts () (value int )
GetCount () (value int )
GetOffsetIDOffset () (value int , ok bool )
GetMessages () (value []MessageClass )
GetTopics () (value []ForumTopicClass )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
c .Inexact = from .GetInexact ()
c .Pts = from .GetPts ()
c .Count = from .GetCount ()
if val , ok := from .GetOffsetIDOffset (); ok {
c .OffsetIDOffset = val
}
c .Messages = from .GetMessages ()
c .Topics = from .GetTopics ()
c .Chats = from .GetChats ()
c .Users = from .GetUsers ()
}
func (*MessagesChannelMessages ) TypeID () uint32 {
return MessagesChannelMessagesTypeID
}
func (*MessagesChannelMessages ) TypeName () string {
return "messages.channelMessages"
}
func (c *MessagesChannelMessages ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.channelMessages" ,
ID : MessagesChannelMessagesTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Inexact" ,
SchemaName : "inexact" ,
Null : !c .Flags .Has (1 ),
},
{
Name : "Pts" ,
SchemaName : "pts" ,
},
{
Name : "Count" ,
SchemaName : "count" ,
},
{
Name : "OffsetIDOffset" ,
SchemaName : "offset_id_offset" ,
Null : !c .Flags .Has (2 ),
},
{
Name : "Messages" ,
SchemaName : "messages" ,
},
{
Name : "Topics" ,
SchemaName : "topics" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (c *MessagesChannelMessages ) SetFlags () {
if !(c .Inexact == false ) {
c .Flags .Set (1 )
}
if !(c .OffsetIDOffset == 0 ) {
c .Flags .Set (2 )
}
}
func (c *MessagesChannelMessages ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode messages.channelMessages#c776ba4e as nil" )
}
b .PutID (MessagesChannelMessagesTypeID )
return c .EncodeBare (b )
}
func (c *MessagesChannelMessages ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode messages.channelMessages#c776ba4e as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.channelMessages#c776ba4e: field flags: %w" , err )
}
b .PutInt (c .Pts )
b .PutInt (c .Count )
if c .Flags .Has (2 ) {
b .PutInt (c .OffsetIDOffset )
}
b .PutVectorHeader (len (c .Messages ))
for idx , v := range c .Messages {
if v == nil {
return fmt .Errorf ("unable to encode messages.channelMessages#c776ba4e: field messages element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.channelMessages#c776ba4e: field messages element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (c .Topics ))
for idx , v := range c .Topics {
if v == nil {
return fmt .Errorf ("unable to encode messages.channelMessages#c776ba4e: field topics element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.channelMessages#c776ba4e: field topics element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (c .Chats ))
for idx , v := range c .Chats {
if v == nil {
return fmt .Errorf ("unable to encode messages.channelMessages#c776ba4e: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.channelMessages#c776ba4e: field chats element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (c .Users ))
for idx , v := range c .Users {
if v == nil {
return fmt .Errorf ("unable to encode messages.channelMessages#c776ba4e: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.channelMessages#c776ba4e: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (c *MessagesChannelMessages ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode messages.channelMessages#c776ba4e to nil" )
}
if err := b .ConsumeID (MessagesChannelMessagesTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.channelMessages#c776ba4e: %w" , err )
}
return c .DecodeBare (b )
}
func (c *MessagesChannelMessages ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode messages.channelMessages#c776ba4e to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.channelMessages#c776ba4e: field flags: %w" , err )
}
}
c .Inexact = c .Flags .Has (1 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.channelMessages#c776ba4e: field pts: %w" , err )
}
c .Pts = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.channelMessages#c776ba4e: field count: %w" , err )
}
c .Count = value
}
if c .Flags .Has (2 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.channelMessages#c776ba4e: field offset_id_offset: %w" , err )
}
c .OffsetIDOffset = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.channelMessages#c776ba4e: field messages: %w" , err )
}
if headerLen > 0 {
c .Messages = make ([]MessageClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeMessage (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.channelMessages#c776ba4e: field messages: %w" , err )
}
c .Messages = append (c .Messages , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.channelMessages#c776ba4e: field topics: %w" , err )
}
if headerLen > 0 {
c .Topics = make ([]ForumTopicClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeForumTopic (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.channelMessages#c776ba4e: field topics: %w" , err )
}
c .Topics = append (c .Topics , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.channelMessages#c776ba4e: field chats: %w" , err )
}
if headerLen > 0 {
c .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.channelMessages#c776ba4e: field chats: %w" , err )
}
c .Chats = append (c .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.channelMessages#c776ba4e: field users: %w" , err )
}
if headerLen > 0 {
c .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.channelMessages#c776ba4e: field users: %w" , err )
}
c .Users = append (c .Users , value )
}
}
return nil
}
func (c *MessagesChannelMessages ) SetInexact (value bool ) {
if value {
c .Flags .Set (1 )
c .Inexact = true
} else {
c .Flags .Unset (1 )
c .Inexact = false
}
}
func (c *MessagesChannelMessages ) GetInexact () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (1 )
}
func (c *MessagesChannelMessages ) GetPts () (value int ) {
if c == nil {
return
}
return c .Pts
}
func (c *MessagesChannelMessages ) GetCount () (value int ) {
if c == nil {
return
}
return c .Count
}
func (c *MessagesChannelMessages ) SetOffsetIDOffset (value int ) {
c .Flags .Set (2 )
c .OffsetIDOffset = value
}
func (c *MessagesChannelMessages ) GetOffsetIDOffset () (value int , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (2 ) {
return value , false
}
return c .OffsetIDOffset , true
}
func (c *MessagesChannelMessages ) GetMessages () (value []MessageClass ) {
if c == nil {
return
}
return c .Messages
}
func (c *MessagesChannelMessages ) GetTopics () (value []ForumTopicClass ) {
if c == nil {
return
}
return c .Topics
}
func (c *MessagesChannelMessages ) GetChats () (value []ChatClass ) {
if c == nil {
return
}
return c .Chats
}
func (c *MessagesChannelMessages ) GetUsers () (value []UserClass ) {
if c == nil {
return
}
return c .Users
}
func (c *MessagesChannelMessages ) MapMessages () (value MessageClassArray ) {
return MessageClassArray (c .Messages )
}
func (c *MessagesChannelMessages ) MapTopics () (value ForumTopicClassArray ) {
return ForumTopicClassArray (c .Topics )
}
func (c *MessagesChannelMessages ) MapChats () (value ChatClassArray ) {
return ChatClassArray (c .Chats )
}
func (c *MessagesChannelMessages ) MapUsers () (value UserClassArray ) {
return UserClassArray (c .Users )
}
type MessagesMessagesNotModified struct {
Count int
}
const MessagesMessagesNotModifiedTypeID = 0x74535f21
func (m MessagesMessagesNotModified ) construct () MessagesMessagesClass { return &m }
var (
_ bin .Encoder = &MessagesMessagesNotModified {}
_ bin .Decoder = &MessagesMessagesNotModified {}
_ bin .BareEncoder = &MessagesMessagesNotModified {}
_ bin .BareDecoder = &MessagesMessagesNotModified {}
_ MessagesMessagesClass = &MessagesMessagesNotModified {}
)
func (m *MessagesMessagesNotModified ) Zero () bool {
if m == nil {
return true
}
if !(m .Count == 0 ) {
return false
}
return true
}
func (m *MessagesMessagesNotModified ) String () string {
if m == nil {
return "MessagesMessagesNotModified(nil)"
}
type Alias MessagesMessagesNotModified
return fmt .Sprintf ("MessagesMessagesNotModified%+v" , Alias (*m ))
}
func (m *MessagesMessagesNotModified ) FillFrom (from interface {
GetCount () (value int )
}) {
m .Count = from .GetCount ()
}
func (*MessagesMessagesNotModified ) TypeID () uint32 {
return MessagesMessagesNotModifiedTypeID
}
func (*MessagesMessagesNotModified ) TypeName () string {
return "messages.messagesNotModified"
}
func (m *MessagesMessagesNotModified ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.messagesNotModified" ,
ID : MessagesMessagesNotModifiedTypeID ,
}
if m == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Count" ,
SchemaName : "count" ,
},
}
return typ
}
func (m *MessagesMessagesNotModified ) Encode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode messages.messagesNotModified#74535f21 as nil" )
}
b .PutID (MessagesMessagesNotModifiedTypeID )
return m .EncodeBare (b )
}
func (m *MessagesMessagesNotModified ) EncodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't encode messages.messagesNotModified#74535f21 as nil" )
}
b .PutInt (m .Count )
return nil
}
func (m *MessagesMessagesNotModified ) Decode (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode messages.messagesNotModified#74535f21 to nil" )
}
if err := b .ConsumeID (MessagesMessagesNotModifiedTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.messagesNotModified#74535f21: %w" , err )
}
return m .DecodeBare (b )
}
func (m *MessagesMessagesNotModified ) DecodeBare (b *bin .Buffer ) error {
if m == nil {
return fmt .Errorf ("can't decode messages.messagesNotModified#74535f21 to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.messagesNotModified#74535f21: field count: %w" , err )
}
m .Count = value
}
return nil
}
func (m *MessagesMessagesNotModified ) GetCount () (value int ) {
if m == nil {
return
}
return m .Count
}
const MessagesMessagesClassName = "messages.Messages"
type MessagesMessagesClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () MessagesMessagesClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsModified () (ModifiedMessagesMessages , bool )
}
type ModifiedMessagesMessages interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () MessagesMessagesClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetMessages () (value []MessageClass )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}
func (m *MessagesMessages ) AsModified () (ModifiedMessagesMessages , bool ) {
value , ok := (MessagesMessagesClass (m )).(ModifiedMessagesMessages )
return value , ok
}
func (m *MessagesMessagesSlice ) AsModified () (ModifiedMessagesMessages , bool ) {
value , ok := (MessagesMessagesClass (m )).(ModifiedMessagesMessages )
return value , ok
}
func (c *MessagesChannelMessages ) AsModified () (ModifiedMessagesMessages , bool ) {
value , ok := (MessagesMessagesClass (c )).(ModifiedMessagesMessages )
return value , ok
}
func (m *MessagesMessagesNotModified ) AsModified () (ModifiedMessagesMessages , bool ) {
value , ok := (MessagesMessagesClass (m )).(ModifiedMessagesMessages )
return value , ok
}
func DecodeMessagesMessages (buf *bin .Buffer ) (MessagesMessagesClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case MessagesMessagesTypeID :
v := MessagesMessages {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessagesMessagesClass: %w" , err )
}
return &v , nil
case MessagesMessagesSliceTypeID :
v := MessagesMessagesSlice {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessagesMessagesClass: %w" , err )
}
return &v , nil
case MessagesChannelMessagesTypeID :
v := MessagesChannelMessages {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessagesMessagesClass: %w" , err )
}
return &v , nil
case MessagesMessagesNotModifiedTypeID :
v := MessagesMessagesNotModified {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessagesMessagesClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode MessagesMessagesClass: %w" , bin .NewUnexpectedID (id ))
}
}
type MessagesMessagesBox struct {
Messages MessagesMessagesClass
}
func (b *MessagesMessagesBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode MessagesMessagesBox to nil" )
}
v , err := DecodeMessagesMessages (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .Messages = v
return nil
}
func (b *MessagesMessagesBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .Messages == nil {
return fmt .Errorf ("unable to encode MessagesMessagesClass as nil" )
}
return b .Messages .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 .