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 UpdatesTooLong struct {
}
const UpdatesTooLongTypeID = 0xe317af7e
func (u UpdatesTooLong ) construct () UpdatesClass { return &u }
var (
_ bin .Encoder = &UpdatesTooLong {}
_ bin .Decoder = &UpdatesTooLong {}
_ bin .BareEncoder = &UpdatesTooLong {}
_ bin .BareDecoder = &UpdatesTooLong {}
_ UpdatesClass = &UpdatesTooLong {}
)
func (u *UpdatesTooLong ) Zero () bool {
if u == nil {
return true
}
return true
}
func (u *UpdatesTooLong ) String () string {
if u == nil {
return "UpdatesTooLong(nil)"
}
type Alias UpdatesTooLong
return fmt .Sprintf ("UpdatesTooLong%+v" , Alias (*u ))
}
func (*UpdatesTooLong ) TypeID () uint32 {
return UpdatesTooLongTypeID
}
func (*UpdatesTooLong ) TypeName () string {
return "updatesTooLong"
}
func (u *UpdatesTooLong ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "updatesTooLong" ,
ID : UpdatesTooLongTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (u *UpdatesTooLong ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode updatesTooLong#e317af7e as nil" )
}
b .PutID (UpdatesTooLongTypeID )
return u .EncodeBare (b )
}
func (u *UpdatesTooLong ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode updatesTooLong#e317af7e as nil" )
}
return nil
}
func (u *UpdatesTooLong ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode updatesTooLong#e317af7e to nil" )
}
if err := b .ConsumeID (UpdatesTooLongTypeID ); err != nil {
return fmt .Errorf ("unable to decode updatesTooLong#e317af7e: %w" , err )
}
return u .DecodeBare (b )
}
func (u *UpdatesTooLong ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode updatesTooLong#e317af7e to nil" )
}
return nil
}
type UpdateShortMessage struct {
Flags bin .Fields
Out bool
Mentioned bool
MediaUnread bool
Silent bool
ID int
UserID int64
Message string
Pts int
PtsCount int
Date int
FwdFrom MessageFwdHeader
ViaBotID int64
ReplyTo MessageReplyHeaderClass
Entities []MessageEntityClass
TTLPeriod int
}
const UpdateShortMessageTypeID = 0x313bc7f8
func (u UpdateShortMessage ) construct () UpdatesClass { return &u }
var (
_ bin .Encoder = &UpdateShortMessage {}
_ bin .Decoder = &UpdateShortMessage {}
_ bin .BareEncoder = &UpdateShortMessage {}
_ bin .BareDecoder = &UpdateShortMessage {}
_ UpdatesClass = &UpdateShortMessage {}
)
func (u *UpdateShortMessage ) Zero () bool {
if u == nil {
return true
}
if !(u .Flags .Zero ()) {
return false
}
if !(u .Out == false ) {
return false
}
if !(u .Mentioned == false ) {
return false
}
if !(u .MediaUnread == false ) {
return false
}
if !(u .Silent == false ) {
return false
}
if !(u .ID == 0 ) {
return false
}
if !(u .UserID == 0 ) {
return false
}
if !(u .Message == "" ) {
return false
}
if !(u .Pts == 0 ) {
return false
}
if !(u .PtsCount == 0 ) {
return false
}
if !(u .Date == 0 ) {
return false
}
if !(u .FwdFrom .Zero ()) {
return false
}
if !(u .ViaBotID == 0 ) {
return false
}
if !(u .ReplyTo == nil ) {
return false
}
if !(u .Entities == nil ) {
return false
}
if !(u .TTLPeriod == 0 ) {
return false
}
return true
}
func (u *UpdateShortMessage ) String () string {
if u == nil {
return "UpdateShortMessage(nil)"
}
type Alias UpdateShortMessage
return fmt .Sprintf ("UpdateShortMessage%+v" , Alias (*u ))
}
func (u *UpdateShortMessage ) FillFrom (from interface {
GetOut () (value bool )
GetMentioned () (value bool )
GetMediaUnread () (value bool )
GetSilent () (value bool )
GetID () (value int )
GetUserID () (value int64 )
GetMessage () (value string )
GetPts () (value int )
GetPtsCount () (value int )
GetDate () (value int )
GetFwdFrom () (value MessageFwdHeader , ok bool )
GetViaBotID () (value int64 , ok bool )
GetReplyTo () (value MessageReplyHeaderClass , ok bool )
GetEntities () (value []MessageEntityClass , ok bool )
GetTTLPeriod () (value int , ok bool )
}) {
u .Out = from .GetOut ()
u .Mentioned = from .GetMentioned ()
u .MediaUnread = from .GetMediaUnread ()
u .Silent = from .GetSilent ()
u .ID = from .GetID ()
u .UserID = from .GetUserID ()
u .Message = from .GetMessage ()
u .Pts = from .GetPts ()
u .PtsCount = from .GetPtsCount ()
u .Date = from .GetDate ()
if val , ok := from .GetFwdFrom (); ok {
u .FwdFrom = val
}
if val , ok := from .GetViaBotID (); ok {
u .ViaBotID = val
}
if val , ok := from .GetReplyTo (); ok {
u .ReplyTo = val
}
if val , ok := from .GetEntities (); ok {
u .Entities = val
}
if val , ok := from .GetTTLPeriod (); ok {
u .TTLPeriod = val
}
}
func (*UpdateShortMessage ) TypeID () uint32 {
return UpdateShortMessageTypeID
}
func (*UpdateShortMessage ) TypeName () string {
return "updateShortMessage"
}
func (u *UpdateShortMessage ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "updateShortMessage" ,
ID : UpdateShortMessageTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Out" ,
SchemaName : "out" ,
Null : !u .Flags .Has (1 ),
},
{
Name : "Mentioned" ,
SchemaName : "mentioned" ,
Null : !u .Flags .Has (4 ),
},
{
Name : "MediaUnread" ,
SchemaName : "media_unread" ,
Null : !u .Flags .Has (5 ),
},
{
Name : "Silent" ,
SchemaName : "silent" ,
Null : !u .Flags .Has (13 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "UserID" ,
SchemaName : "user_id" ,
},
{
Name : "Message" ,
SchemaName : "message" ,
},
{
Name : "Pts" ,
SchemaName : "pts" ,
},
{
Name : "PtsCount" ,
SchemaName : "pts_count" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
{
Name : "FwdFrom" ,
SchemaName : "fwd_from" ,
Null : !u .Flags .Has (2 ),
},
{
Name : "ViaBotID" ,
SchemaName : "via_bot_id" ,
Null : !u .Flags .Has (11 ),
},
{
Name : "ReplyTo" ,
SchemaName : "reply_to" ,
Null : !u .Flags .Has (3 ),
},
{
Name : "Entities" ,
SchemaName : "entities" ,
Null : !u .Flags .Has (7 ),
},
{
Name : "TTLPeriod" ,
SchemaName : "ttl_period" ,
Null : !u .Flags .Has (25 ),
},
}
return typ
}
func (u *UpdateShortMessage ) SetFlags () {
if !(u .Out == false ) {
u .Flags .Set (1 )
}
if !(u .Mentioned == false ) {
u .Flags .Set (4 )
}
if !(u .MediaUnread == false ) {
u .Flags .Set (5 )
}
if !(u .Silent == false ) {
u .Flags .Set (13 )
}
if !(u .FwdFrom .Zero ()) {
u .Flags .Set (2 )
}
if !(u .ViaBotID == 0 ) {
u .Flags .Set (11 )
}
if !(u .ReplyTo == nil ) {
u .Flags .Set (3 )
}
if !(u .Entities == nil ) {
u .Flags .Set (7 )
}
if !(u .TTLPeriod == 0 ) {
u .Flags .Set (25 )
}
}
func (u *UpdateShortMessage ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode updateShortMessage#313bc7f8 as nil" )
}
b .PutID (UpdateShortMessageTypeID )
return u .EncodeBare (b )
}
func (u *UpdateShortMessage ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode updateShortMessage#313bc7f8 as nil" )
}
u .SetFlags ()
if err := u .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updateShortMessage#313bc7f8: field flags: %w" , err )
}
b .PutInt (u .ID )
b .PutLong (u .UserID )
b .PutString (u .Message )
b .PutInt (u .Pts )
b .PutInt (u .PtsCount )
b .PutInt (u .Date )
if u .Flags .Has (2 ) {
if err := u .FwdFrom .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updateShortMessage#313bc7f8: field fwd_from: %w" , err )
}
}
if u .Flags .Has (11 ) {
b .PutLong (u .ViaBotID )
}
if u .Flags .Has (3 ) {
if u .ReplyTo == nil {
return fmt .Errorf ("unable to encode updateShortMessage#313bc7f8: field reply_to is nil" )
}
if err := u .ReplyTo .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updateShortMessage#313bc7f8: field reply_to: %w" , err )
}
}
if u .Flags .Has (7 ) {
b .PutVectorHeader (len (u .Entities ))
for idx , v := range u .Entities {
if v == nil {
return fmt .Errorf ("unable to encode updateShortMessage#313bc7f8: field entities element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updateShortMessage#313bc7f8: field entities element with index %d: %w" , idx , err )
}
}
}
if u .Flags .Has (25 ) {
b .PutInt (u .TTLPeriod )
}
return nil
}
func (u *UpdateShortMessage ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode updateShortMessage#313bc7f8 to nil" )
}
if err := b .ConsumeID (UpdateShortMessageTypeID ); err != nil {
return fmt .Errorf ("unable to decode updateShortMessage#313bc7f8: %w" , err )
}
return u .DecodeBare (b )
}
func (u *UpdateShortMessage ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode updateShortMessage#313bc7f8 to nil" )
}
{
if err := u .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode updateShortMessage#313bc7f8: field flags: %w" , err )
}
}
u .Out = u .Flags .Has (1 )
u .Mentioned = u .Flags .Has (4 )
u .MediaUnread = u .Flags .Has (5 )
u .Silent = u .Flags .Has (13 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortMessage#313bc7f8: field id: %w" , err )
}
u .ID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortMessage#313bc7f8: field user_id: %w" , err )
}
u .UserID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortMessage#313bc7f8: field message: %w" , err )
}
u .Message = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortMessage#313bc7f8: field pts: %w" , err )
}
u .Pts = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortMessage#313bc7f8: field pts_count: %w" , err )
}
u .PtsCount = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortMessage#313bc7f8: field date: %w" , err )
}
u .Date = value
}
if u .Flags .Has (2 ) {
if err := u .FwdFrom .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode updateShortMessage#313bc7f8: field fwd_from: %w" , err )
}
}
if u .Flags .Has (11 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortMessage#313bc7f8: field via_bot_id: %w" , err )
}
u .ViaBotID = value
}
if u .Flags .Has (3 ) {
value , err := DecodeMessageReplyHeader (b )
if err != nil {
return fmt .Errorf ("unable to decode updateShortMessage#313bc7f8: field reply_to: %w" , err )
}
u .ReplyTo = value
}
if u .Flags .Has (7 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortMessage#313bc7f8: field entities: %w" , err )
}
if headerLen > 0 {
u .Entities = make ([]MessageEntityClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeMessageEntity (b )
if err != nil {
return fmt .Errorf ("unable to decode updateShortMessage#313bc7f8: field entities: %w" , err )
}
u .Entities = append (u .Entities , value )
}
}
if u .Flags .Has (25 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortMessage#313bc7f8: field ttl_period: %w" , err )
}
u .TTLPeriod = value
}
return nil
}
func (u *UpdateShortMessage ) SetOut (value bool ) {
if value {
u .Flags .Set (1 )
u .Out = true
} else {
u .Flags .Unset (1 )
u .Out = false
}
}
func (u *UpdateShortMessage ) GetOut () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (1 )
}
func (u *UpdateShortMessage ) SetMentioned (value bool ) {
if value {
u .Flags .Set (4 )
u .Mentioned = true
} else {
u .Flags .Unset (4 )
u .Mentioned = false
}
}
func (u *UpdateShortMessage ) GetMentioned () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (4 )
}
func (u *UpdateShortMessage ) SetMediaUnread (value bool ) {
if value {
u .Flags .Set (5 )
u .MediaUnread = true
} else {
u .Flags .Unset (5 )
u .MediaUnread = false
}
}
func (u *UpdateShortMessage ) GetMediaUnread () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (5 )
}
func (u *UpdateShortMessage ) SetSilent (value bool ) {
if value {
u .Flags .Set (13 )
u .Silent = true
} else {
u .Flags .Unset (13 )
u .Silent = false
}
}
func (u *UpdateShortMessage ) GetSilent () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (13 )
}
func (u *UpdateShortMessage ) GetID () (value int ) {
if u == nil {
return
}
return u .ID
}
func (u *UpdateShortMessage ) GetUserID () (value int64 ) {
if u == nil {
return
}
return u .UserID
}
func (u *UpdateShortMessage ) GetMessage () (value string ) {
if u == nil {
return
}
return u .Message
}
func (u *UpdateShortMessage ) GetPts () (value int ) {
if u == nil {
return
}
return u .Pts
}
func (u *UpdateShortMessage ) GetPtsCount () (value int ) {
if u == nil {
return
}
return u .PtsCount
}
func (u *UpdateShortMessage ) GetDate () (value int ) {
if u == nil {
return
}
return u .Date
}
func (u *UpdateShortMessage ) SetFwdFrom (value MessageFwdHeader ) {
u .Flags .Set (2 )
u .FwdFrom = value
}
func (u *UpdateShortMessage ) GetFwdFrom () (value MessageFwdHeader , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (2 ) {
return value , false
}
return u .FwdFrom , true
}
func (u *UpdateShortMessage ) SetViaBotID (value int64 ) {
u .Flags .Set (11 )
u .ViaBotID = value
}
func (u *UpdateShortMessage ) GetViaBotID () (value int64 , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (11 ) {
return value , false
}
return u .ViaBotID , true
}
func (u *UpdateShortMessage ) SetReplyTo (value MessageReplyHeaderClass ) {
u .Flags .Set (3 )
u .ReplyTo = value
}
func (u *UpdateShortMessage ) GetReplyTo () (value MessageReplyHeaderClass , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (3 ) {
return value , false
}
return u .ReplyTo , true
}
func (u *UpdateShortMessage ) SetEntities (value []MessageEntityClass ) {
u .Flags .Set (7 )
u .Entities = value
}
func (u *UpdateShortMessage ) GetEntities () (value []MessageEntityClass , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (7 ) {
return value , false
}
return u .Entities , true
}
func (u *UpdateShortMessage ) SetTTLPeriod (value int ) {
u .Flags .Set (25 )
u .TTLPeriod = value
}
func (u *UpdateShortMessage ) GetTTLPeriod () (value int , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (25 ) {
return value , false
}
return u .TTLPeriod , true
}
func (u *UpdateShortMessage ) MapEntities () (value MessageEntityClassArray , ok bool ) {
if !u .Flags .Has (7 ) {
return value , false
}
return MessageEntityClassArray (u .Entities ), true
}
type UpdateShortChatMessage struct {
Flags bin .Fields
Out bool
Mentioned bool
MediaUnread bool
Silent bool
ID int
FromID int64
ChatID int64
Message string
Pts int
PtsCount int
Date int
FwdFrom MessageFwdHeader
ViaBotID int64
ReplyTo MessageReplyHeaderClass
Entities []MessageEntityClass
TTLPeriod int
}
const UpdateShortChatMessageTypeID = 0x4d6deea5
func (u UpdateShortChatMessage ) construct () UpdatesClass { return &u }
var (
_ bin .Encoder = &UpdateShortChatMessage {}
_ bin .Decoder = &UpdateShortChatMessage {}
_ bin .BareEncoder = &UpdateShortChatMessage {}
_ bin .BareDecoder = &UpdateShortChatMessage {}
_ UpdatesClass = &UpdateShortChatMessage {}
)
func (u *UpdateShortChatMessage ) Zero () bool {
if u == nil {
return true
}
if !(u .Flags .Zero ()) {
return false
}
if !(u .Out == false ) {
return false
}
if !(u .Mentioned == false ) {
return false
}
if !(u .MediaUnread == false ) {
return false
}
if !(u .Silent == false ) {
return false
}
if !(u .ID == 0 ) {
return false
}
if !(u .FromID == 0 ) {
return false
}
if !(u .ChatID == 0 ) {
return false
}
if !(u .Message == "" ) {
return false
}
if !(u .Pts == 0 ) {
return false
}
if !(u .PtsCount == 0 ) {
return false
}
if !(u .Date == 0 ) {
return false
}
if !(u .FwdFrom .Zero ()) {
return false
}
if !(u .ViaBotID == 0 ) {
return false
}
if !(u .ReplyTo == nil ) {
return false
}
if !(u .Entities == nil ) {
return false
}
if !(u .TTLPeriod == 0 ) {
return false
}
return true
}
func (u *UpdateShortChatMessage ) String () string {
if u == nil {
return "UpdateShortChatMessage(nil)"
}
type Alias UpdateShortChatMessage
return fmt .Sprintf ("UpdateShortChatMessage%+v" , Alias (*u ))
}
func (u *UpdateShortChatMessage ) FillFrom (from interface {
GetOut () (value bool )
GetMentioned () (value bool )
GetMediaUnread () (value bool )
GetSilent () (value bool )
GetID () (value int )
GetFromID () (value int64 )
GetChatID () (value int64 )
GetMessage () (value string )
GetPts () (value int )
GetPtsCount () (value int )
GetDate () (value int )
GetFwdFrom () (value MessageFwdHeader , ok bool )
GetViaBotID () (value int64 , ok bool )
GetReplyTo () (value MessageReplyHeaderClass , ok bool )
GetEntities () (value []MessageEntityClass , ok bool )
GetTTLPeriod () (value int , ok bool )
}) {
u .Out = from .GetOut ()
u .Mentioned = from .GetMentioned ()
u .MediaUnread = from .GetMediaUnread ()
u .Silent = from .GetSilent ()
u .ID = from .GetID ()
u .FromID = from .GetFromID ()
u .ChatID = from .GetChatID ()
u .Message = from .GetMessage ()
u .Pts = from .GetPts ()
u .PtsCount = from .GetPtsCount ()
u .Date = from .GetDate ()
if val , ok := from .GetFwdFrom (); ok {
u .FwdFrom = val
}
if val , ok := from .GetViaBotID (); ok {
u .ViaBotID = val
}
if val , ok := from .GetReplyTo (); ok {
u .ReplyTo = val
}
if val , ok := from .GetEntities (); ok {
u .Entities = val
}
if val , ok := from .GetTTLPeriod (); ok {
u .TTLPeriod = val
}
}
func (*UpdateShortChatMessage ) TypeID () uint32 {
return UpdateShortChatMessageTypeID
}
func (*UpdateShortChatMessage ) TypeName () string {
return "updateShortChatMessage"
}
func (u *UpdateShortChatMessage ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "updateShortChatMessage" ,
ID : UpdateShortChatMessageTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Out" ,
SchemaName : "out" ,
Null : !u .Flags .Has (1 ),
},
{
Name : "Mentioned" ,
SchemaName : "mentioned" ,
Null : !u .Flags .Has (4 ),
},
{
Name : "MediaUnread" ,
SchemaName : "media_unread" ,
Null : !u .Flags .Has (5 ),
},
{
Name : "Silent" ,
SchemaName : "silent" ,
Null : !u .Flags .Has (13 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "FromID" ,
SchemaName : "from_id" ,
},
{
Name : "ChatID" ,
SchemaName : "chat_id" ,
},
{
Name : "Message" ,
SchemaName : "message" ,
},
{
Name : "Pts" ,
SchemaName : "pts" ,
},
{
Name : "PtsCount" ,
SchemaName : "pts_count" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
{
Name : "FwdFrom" ,
SchemaName : "fwd_from" ,
Null : !u .Flags .Has (2 ),
},
{
Name : "ViaBotID" ,
SchemaName : "via_bot_id" ,
Null : !u .Flags .Has (11 ),
},
{
Name : "ReplyTo" ,
SchemaName : "reply_to" ,
Null : !u .Flags .Has (3 ),
},
{
Name : "Entities" ,
SchemaName : "entities" ,
Null : !u .Flags .Has (7 ),
},
{
Name : "TTLPeriod" ,
SchemaName : "ttl_period" ,
Null : !u .Flags .Has (25 ),
},
}
return typ
}
func (u *UpdateShortChatMessage ) SetFlags () {
if !(u .Out == false ) {
u .Flags .Set (1 )
}
if !(u .Mentioned == false ) {
u .Flags .Set (4 )
}
if !(u .MediaUnread == false ) {
u .Flags .Set (5 )
}
if !(u .Silent == false ) {
u .Flags .Set (13 )
}
if !(u .FwdFrom .Zero ()) {
u .Flags .Set (2 )
}
if !(u .ViaBotID == 0 ) {
u .Flags .Set (11 )
}
if !(u .ReplyTo == nil ) {
u .Flags .Set (3 )
}
if !(u .Entities == nil ) {
u .Flags .Set (7 )
}
if !(u .TTLPeriod == 0 ) {
u .Flags .Set (25 )
}
}
func (u *UpdateShortChatMessage ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode updateShortChatMessage#4d6deea5 as nil" )
}
b .PutID (UpdateShortChatMessageTypeID )
return u .EncodeBare (b )
}
func (u *UpdateShortChatMessage ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode updateShortChatMessage#4d6deea5 as nil" )
}
u .SetFlags ()
if err := u .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updateShortChatMessage#4d6deea5: field flags: %w" , err )
}
b .PutInt (u .ID )
b .PutLong (u .FromID )
b .PutLong (u .ChatID )
b .PutString (u .Message )
b .PutInt (u .Pts )
b .PutInt (u .PtsCount )
b .PutInt (u .Date )
if u .Flags .Has (2 ) {
if err := u .FwdFrom .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updateShortChatMessage#4d6deea5: field fwd_from: %w" , err )
}
}
if u .Flags .Has (11 ) {
b .PutLong (u .ViaBotID )
}
if u .Flags .Has (3 ) {
if u .ReplyTo == nil {
return fmt .Errorf ("unable to encode updateShortChatMessage#4d6deea5: field reply_to is nil" )
}
if err := u .ReplyTo .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updateShortChatMessage#4d6deea5: field reply_to: %w" , err )
}
}
if u .Flags .Has (7 ) {
b .PutVectorHeader (len (u .Entities ))
for idx , v := range u .Entities {
if v == nil {
return fmt .Errorf ("unable to encode updateShortChatMessage#4d6deea5: field entities element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updateShortChatMessage#4d6deea5: field entities element with index %d: %w" , idx , err )
}
}
}
if u .Flags .Has (25 ) {
b .PutInt (u .TTLPeriod )
}
return nil
}
func (u *UpdateShortChatMessage ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode updateShortChatMessage#4d6deea5 to nil" )
}
if err := b .ConsumeID (UpdateShortChatMessageTypeID ); err != nil {
return fmt .Errorf ("unable to decode updateShortChatMessage#4d6deea5: %w" , err )
}
return u .DecodeBare (b )
}
func (u *UpdateShortChatMessage ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode updateShortChatMessage#4d6deea5 to nil" )
}
{
if err := u .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode updateShortChatMessage#4d6deea5: field flags: %w" , err )
}
}
u .Out = u .Flags .Has (1 )
u .Mentioned = u .Flags .Has (4 )
u .MediaUnread = u .Flags .Has (5 )
u .Silent = u .Flags .Has (13 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortChatMessage#4d6deea5: field id: %w" , err )
}
u .ID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortChatMessage#4d6deea5: field from_id: %w" , err )
}
u .FromID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortChatMessage#4d6deea5: field chat_id: %w" , err )
}
u .ChatID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortChatMessage#4d6deea5: field message: %w" , err )
}
u .Message = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortChatMessage#4d6deea5: field pts: %w" , err )
}
u .Pts = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortChatMessage#4d6deea5: field pts_count: %w" , err )
}
u .PtsCount = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortChatMessage#4d6deea5: field date: %w" , err )
}
u .Date = value
}
if u .Flags .Has (2 ) {
if err := u .FwdFrom .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode updateShortChatMessage#4d6deea5: field fwd_from: %w" , err )
}
}
if u .Flags .Has (11 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortChatMessage#4d6deea5: field via_bot_id: %w" , err )
}
u .ViaBotID = value
}
if u .Flags .Has (3 ) {
value , err := DecodeMessageReplyHeader (b )
if err != nil {
return fmt .Errorf ("unable to decode updateShortChatMessage#4d6deea5: field reply_to: %w" , err )
}
u .ReplyTo = value
}
if u .Flags .Has (7 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortChatMessage#4d6deea5: field entities: %w" , err )
}
if headerLen > 0 {
u .Entities = make ([]MessageEntityClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeMessageEntity (b )
if err != nil {
return fmt .Errorf ("unable to decode updateShortChatMessage#4d6deea5: field entities: %w" , err )
}
u .Entities = append (u .Entities , value )
}
}
if u .Flags .Has (25 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortChatMessage#4d6deea5: field ttl_period: %w" , err )
}
u .TTLPeriod = value
}
return nil
}
func (u *UpdateShortChatMessage ) SetOut (value bool ) {
if value {
u .Flags .Set (1 )
u .Out = true
} else {
u .Flags .Unset (1 )
u .Out = false
}
}
func (u *UpdateShortChatMessage ) GetOut () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (1 )
}
func (u *UpdateShortChatMessage ) SetMentioned (value bool ) {
if value {
u .Flags .Set (4 )
u .Mentioned = true
} else {
u .Flags .Unset (4 )
u .Mentioned = false
}
}
func (u *UpdateShortChatMessage ) GetMentioned () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (4 )
}
func (u *UpdateShortChatMessage ) SetMediaUnread (value bool ) {
if value {
u .Flags .Set (5 )
u .MediaUnread = true
} else {
u .Flags .Unset (5 )
u .MediaUnread = false
}
}
func (u *UpdateShortChatMessage ) GetMediaUnread () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (5 )
}
func (u *UpdateShortChatMessage ) SetSilent (value bool ) {
if value {
u .Flags .Set (13 )
u .Silent = true
} else {
u .Flags .Unset (13 )
u .Silent = false
}
}
func (u *UpdateShortChatMessage ) GetSilent () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (13 )
}
func (u *UpdateShortChatMessage ) GetID () (value int ) {
if u == nil {
return
}
return u .ID
}
func (u *UpdateShortChatMessage ) GetFromID () (value int64 ) {
if u == nil {
return
}
return u .FromID
}
func (u *UpdateShortChatMessage ) GetChatID () (value int64 ) {
if u == nil {
return
}
return u .ChatID
}
func (u *UpdateShortChatMessage ) GetMessage () (value string ) {
if u == nil {
return
}
return u .Message
}
func (u *UpdateShortChatMessage ) GetPts () (value int ) {
if u == nil {
return
}
return u .Pts
}
func (u *UpdateShortChatMessage ) GetPtsCount () (value int ) {
if u == nil {
return
}
return u .PtsCount
}
func (u *UpdateShortChatMessage ) GetDate () (value int ) {
if u == nil {
return
}
return u .Date
}
func (u *UpdateShortChatMessage ) SetFwdFrom (value MessageFwdHeader ) {
u .Flags .Set (2 )
u .FwdFrom = value
}
func (u *UpdateShortChatMessage ) GetFwdFrom () (value MessageFwdHeader , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (2 ) {
return value , false
}
return u .FwdFrom , true
}
func (u *UpdateShortChatMessage ) SetViaBotID (value int64 ) {
u .Flags .Set (11 )
u .ViaBotID = value
}
func (u *UpdateShortChatMessage ) GetViaBotID () (value int64 , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (11 ) {
return value , false
}
return u .ViaBotID , true
}
func (u *UpdateShortChatMessage ) SetReplyTo (value MessageReplyHeaderClass ) {
u .Flags .Set (3 )
u .ReplyTo = value
}
func (u *UpdateShortChatMessage ) GetReplyTo () (value MessageReplyHeaderClass , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (3 ) {
return value , false
}
return u .ReplyTo , true
}
func (u *UpdateShortChatMessage ) SetEntities (value []MessageEntityClass ) {
u .Flags .Set (7 )
u .Entities = value
}
func (u *UpdateShortChatMessage ) GetEntities () (value []MessageEntityClass , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (7 ) {
return value , false
}
return u .Entities , true
}
func (u *UpdateShortChatMessage ) SetTTLPeriod (value int ) {
u .Flags .Set (25 )
u .TTLPeriod = value
}
func (u *UpdateShortChatMessage ) GetTTLPeriod () (value int , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (25 ) {
return value , false
}
return u .TTLPeriod , true
}
func (u *UpdateShortChatMessage ) MapEntities () (value MessageEntityClassArray , ok bool ) {
if !u .Flags .Has (7 ) {
return value , false
}
return MessageEntityClassArray (u .Entities ), true
}
type UpdateShort struct {
Update UpdateClass
Date int
}
const UpdateShortTypeID = 0x78d4dec1
func (u UpdateShort ) construct () UpdatesClass { return &u }
var (
_ bin .Encoder = &UpdateShort {}
_ bin .Decoder = &UpdateShort {}
_ bin .BareEncoder = &UpdateShort {}
_ bin .BareDecoder = &UpdateShort {}
_ UpdatesClass = &UpdateShort {}
)
func (u *UpdateShort ) Zero () bool {
if u == nil {
return true
}
if !(u .Update == nil ) {
return false
}
if !(u .Date == 0 ) {
return false
}
return true
}
func (u *UpdateShort ) String () string {
if u == nil {
return "UpdateShort(nil)"
}
type Alias UpdateShort
return fmt .Sprintf ("UpdateShort%+v" , Alias (*u ))
}
func (u *UpdateShort ) FillFrom (from interface {
GetUpdate () (value UpdateClass )
GetDate () (value int )
}) {
u .Update = from .GetUpdate ()
u .Date = from .GetDate ()
}
func (*UpdateShort ) TypeID () uint32 {
return UpdateShortTypeID
}
func (*UpdateShort ) TypeName () string {
return "updateShort"
}
func (u *UpdateShort ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "updateShort" ,
ID : UpdateShortTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Update" ,
SchemaName : "update" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
}
return typ
}
func (u *UpdateShort ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode updateShort#78d4dec1 as nil" )
}
b .PutID (UpdateShortTypeID )
return u .EncodeBare (b )
}
func (u *UpdateShort ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode updateShort#78d4dec1 as nil" )
}
if u .Update == nil {
return fmt .Errorf ("unable to encode updateShort#78d4dec1: field update is nil" )
}
if err := u .Update .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updateShort#78d4dec1: field update: %w" , err )
}
b .PutInt (u .Date )
return nil
}
func (u *UpdateShort ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode updateShort#78d4dec1 to nil" )
}
if err := b .ConsumeID (UpdateShortTypeID ); err != nil {
return fmt .Errorf ("unable to decode updateShort#78d4dec1: %w" , err )
}
return u .DecodeBare (b )
}
func (u *UpdateShort ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode updateShort#78d4dec1 to nil" )
}
{
value , err := DecodeUpdate (b )
if err != nil {
return fmt .Errorf ("unable to decode updateShort#78d4dec1: field update: %w" , err )
}
u .Update = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updateShort#78d4dec1: field date: %w" , err )
}
u .Date = value
}
return nil
}
func (u *UpdateShort ) GetUpdate () (value UpdateClass ) {
if u == nil {
return
}
return u .Update
}
func (u *UpdateShort ) GetDate () (value int ) {
if u == nil {
return
}
return u .Date
}
type UpdatesCombined struct {
Updates []UpdateClass
Users []UserClass
Chats []ChatClass
Date int
SeqStart int
Seq int
}
const UpdatesCombinedTypeID = 0x725b04c3
func (u UpdatesCombined ) construct () UpdatesClass { return &u }
var (
_ bin .Encoder = &UpdatesCombined {}
_ bin .Decoder = &UpdatesCombined {}
_ bin .BareEncoder = &UpdatesCombined {}
_ bin .BareDecoder = &UpdatesCombined {}
_ UpdatesClass = &UpdatesCombined {}
)
func (u *UpdatesCombined ) Zero () bool {
if u == nil {
return true
}
if !(u .Updates == nil ) {
return false
}
if !(u .Users == nil ) {
return false
}
if !(u .Chats == nil ) {
return false
}
if !(u .Date == 0 ) {
return false
}
if !(u .SeqStart == 0 ) {
return false
}
if !(u .Seq == 0 ) {
return false
}
return true
}
func (u *UpdatesCombined ) String () string {
if u == nil {
return "UpdatesCombined(nil)"
}
type Alias UpdatesCombined
return fmt .Sprintf ("UpdatesCombined%+v" , Alias (*u ))
}
func (u *UpdatesCombined ) FillFrom (from interface {
GetUpdates () (value []UpdateClass )
GetUsers () (value []UserClass )
GetChats () (value []ChatClass )
GetDate () (value int )
GetSeqStart () (value int )
GetSeq () (value int )
}) {
u .Updates = from .GetUpdates ()
u .Users = from .GetUsers ()
u .Chats = from .GetChats ()
u .Date = from .GetDate ()
u .SeqStart = from .GetSeqStart ()
u .Seq = from .GetSeq ()
}
func (*UpdatesCombined ) TypeID () uint32 {
return UpdatesCombinedTypeID
}
func (*UpdatesCombined ) TypeName () string {
return "updatesCombined"
}
func (u *UpdatesCombined ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "updatesCombined" ,
ID : UpdatesCombinedTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Updates" ,
SchemaName : "updates" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
{
Name : "SeqStart" ,
SchemaName : "seq_start" ,
},
{
Name : "Seq" ,
SchemaName : "seq" ,
},
}
return typ
}
func (u *UpdatesCombined ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode updatesCombined#725b04c3 as nil" )
}
b .PutID (UpdatesCombinedTypeID )
return u .EncodeBare (b )
}
func (u *UpdatesCombined ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode updatesCombined#725b04c3 as nil" )
}
b .PutVectorHeader (len (u .Updates ))
for idx , v := range u .Updates {
if v == nil {
return fmt .Errorf ("unable to encode updatesCombined#725b04c3: field updates element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updatesCombined#725b04c3: field updates element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (u .Users ))
for idx , v := range u .Users {
if v == nil {
return fmt .Errorf ("unable to encode updatesCombined#725b04c3: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updatesCombined#725b04c3: field users element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (u .Chats ))
for idx , v := range u .Chats {
if v == nil {
return fmt .Errorf ("unable to encode updatesCombined#725b04c3: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updatesCombined#725b04c3: field chats element with index %d: %w" , idx , err )
}
}
b .PutInt (u .Date )
b .PutInt (u .SeqStart )
b .PutInt (u .Seq )
return nil
}
func (u *UpdatesCombined ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode updatesCombined#725b04c3 to nil" )
}
if err := b .ConsumeID (UpdatesCombinedTypeID ); err != nil {
return fmt .Errorf ("unable to decode updatesCombined#725b04c3: %w" , err )
}
return u .DecodeBare (b )
}
func (u *UpdatesCombined ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode updatesCombined#725b04c3 to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode updatesCombined#725b04c3: field updates: %w" , err )
}
if headerLen > 0 {
u .Updates = make ([]UpdateClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeUpdate (b )
if err != nil {
return fmt .Errorf ("unable to decode updatesCombined#725b04c3: field updates: %w" , err )
}
u .Updates = append (u .Updates , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode updatesCombined#725b04c3: field users: %w" , err )
}
if headerLen > 0 {
u .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 updatesCombined#725b04c3: field users: %w" , err )
}
u .Users = append (u .Users , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode updatesCombined#725b04c3: field chats: %w" , err )
}
if headerLen > 0 {
u .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 updatesCombined#725b04c3: field chats: %w" , err )
}
u .Chats = append (u .Chats , value )
}
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updatesCombined#725b04c3: field date: %w" , err )
}
u .Date = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updatesCombined#725b04c3: field seq_start: %w" , err )
}
u .SeqStart = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updatesCombined#725b04c3: field seq: %w" , err )
}
u .Seq = value
}
return nil
}
func (u *UpdatesCombined ) GetUpdates () (value []UpdateClass ) {
if u == nil {
return
}
return u .Updates
}
func (u *UpdatesCombined ) GetUsers () (value []UserClass ) {
if u == nil {
return
}
return u .Users
}
func (u *UpdatesCombined ) GetChats () (value []ChatClass ) {
if u == nil {
return
}
return u .Chats
}
func (u *UpdatesCombined ) GetDate () (value int ) {
if u == nil {
return
}
return u .Date
}
func (u *UpdatesCombined ) GetSeqStart () (value int ) {
if u == nil {
return
}
return u .SeqStart
}
func (u *UpdatesCombined ) GetSeq () (value int ) {
if u == nil {
return
}
return u .Seq
}
func (u *UpdatesCombined ) MapUpdates () (value UpdateClassArray ) {
return UpdateClassArray (u .Updates )
}
func (u *UpdatesCombined ) MapUsers () (value UserClassArray ) {
return UserClassArray (u .Users )
}
func (u *UpdatesCombined ) MapChats () (value ChatClassArray ) {
return ChatClassArray (u .Chats )
}
type Updates struct {
Updates []UpdateClass
Users []UserClass
Chats []ChatClass
Date int
Seq int
}
const UpdatesTypeID = 0x74ae4240
func (u Updates ) construct () UpdatesClass { return &u }
var (
_ bin .Encoder = &Updates {}
_ bin .Decoder = &Updates {}
_ bin .BareEncoder = &Updates {}
_ bin .BareDecoder = &Updates {}
_ UpdatesClass = &Updates {}
)
func (u *Updates ) Zero () bool {
if u == nil {
return true
}
if !(u .Updates == nil ) {
return false
}
if !(u .Users == nil ) {
return false
}
if !(u .Chats == nil ) {
return false
}
if !(u .Date == 0 ) {
return false
}
if !(u .Seq == 0 ) {
return false
}
return true
}
func (u *Updates ) String () string {
if u == nil {
return "Updates(nil)"
}
type Alias Updates
return fmt .Sprintf ("Updates%+v" , Alias (*u ))
}
func (u *Updates ) FillFrom (from interface {
GetUpdates () (value []UpdateClass )
GetUsers () (value []UserClass )
GetChats () (value []ChatClass )
GetDate () (value int )
GetSeq () (value int )
}) {
u .Updates = from .GetUpdates ()
u .Users = from .GetUsers ()
u .Chats = from .GetChats ()
u .Date = from .GetDate ()
u .Seq = from .GetSeq ()
}
func (*Updates ) TypeID () uint32 {
return UpdatesTypeID
}
func (*Updates ) TypeName () string {
return "updates"
}
func (u *Updates ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "updates" ,
ID : UpdatesTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Updates" ,
SchemaName : "updates" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
{
Name : "Seq" ,
SchemaName : "seq" ,
},
}
return typ
}
func (u *Updates ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode updates#74ae4240 as nil" )
}
b .PutID (UpdatesTypeID )
return u .EncodeBare (b )
}
func (u *Updates ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode updates#74ae4240 as nil" )
}
b .PutVectorHeader (len (u .Updates ))
for idx , v := range u .Updates {
if v == nil {
return fmt .Errorf ("unable to encode updates#74ae4240: field updates element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updates#74ae4240: field updates element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (u .Users ))
for idx , v := range u .Users {
if v == nil {
return fmt .Errorf ("unable to encode updates#74ae4240: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updates#74ae4240: field users element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (u .Chats ))
for idx , v := range u .Chats {
if v == nil {
return fmt .Errorf ("unable to encode updates#74ae4240: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updates#74ae4240: field chats element with index %d: %w" , idx , err )
}
}
b .PutInt (u .Date )
b .PutInt (u .Seq )
return nil
}
func (u *Updates ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode updates#74ae4240 to nil" )
}
if err := b .ConsumeID (UpdatesTypeID ); err != nil {
return fmt .Errorf ("unable to decode updates#74ae4240: %w" , err )
}
return u .DecodeBare (b )
}
func (u *Updates ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode updates#74ae4240 to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode updates#74ae4240: field updates: %w" , err )
}
if headerLen > 0 {
u .Updates = make ([]UpdateClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeUpdate (b )
if err != nil {
return fmt .Errorf ("unable to decode updates#74ae4240: field updates: %w" , err )
}
u .Updates = append (u .Updates , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode updates#74ae4240: field users: %w" , err )
}
if headerLen > 0 {
u .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 updates#74ae4240: field users: %w" , err )
}
u .Users = append (u .Users , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode updates#74ae4240: field chats: %w" , err )
}
if headerLen > 0 {
u .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 updates#74ae4240: field chats: %w" , err )
}
u .Chats = append (u .Chats , value )
}
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updates#74ae4240: field date: %w" , err )
}
u .Date = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updates#74ae4240: field seq: %w" , err )
}
u .Seq = value
}
return nil
}
func (u *Updates ) GetUpdates () (value []UpdateClass ) {
if u == nil {
return
}
return u .Updates
}
func (u *Updates ) GetUsers () (value []UserClass ) {
if u == nil {
return
}
return u .Users
}
func (u *Updates ) GetChats () (value []ChatClass ) {
if u == nil {
return
}
return u .Chats
}
func (u *Updates ) GetDate () (value int ) {
if u == nil {
return
}
return u .Date
}
func (u *Updates ) GetSeq () (value int ) {
if u == nil {
return
}
return u .Seq
}
func (u *Updates ) MapUpdates () (value UpdateClassArray ) {
return UpdateClassArray (u .Updates )
}
func (u *Updates ) MapUsers () (value UserClassArray ) {
return UserClassArray (u .Users )
}
func (u *Updates ) MapChats () (value ChatClassArray ) {
return ChatClassArray (u .Chats )
}
type UpdateShortSentMessage struct {
Flags bin .Fields
Out bool
ID int
Pts int
PtsCount int
Date int
Media MessageMediaClass
Entities []MessageEntityClass
TTLPeriod int
}
const UpdateShortSentMessageTypeID = 0x9015e101
func (u UpdateShortSentMessage ) construct () UpdatesClass { return &u }
var (
_ bin .Encoder = &UpdateShortSentMessage {}
_ bin .Decoder = &UpdateShortSentMessage {}
_ bin .BareEncoder = &UpdateShortSentMessage {}
_ bin .BareDecoder = &UpdateShortSentMessage {}
_ UpdatesClass = &UpdateShortSentMessage {}
)
func (u *UpdateShortSentMessage ) Zero () bool {
if u == nil {
return true
}
if !(u .Flags .Zero ()) {
return false
}
if !(u .Out == false ) {
return false
}
if !(u .ID == 0 ) {
return false
}
if !(u .Pts == 0 ) {
return false
}
if !(u .PtsCount == 0 ) {
return false
}
if !(u .Date == 0 ) {
return false
}
if !(u .Media == nil ) {
return false
}
if !(u .Entities == nil ) {
return false
}
if !(u .TTLPeriod == 0 ) {
return false
}
return true
}
func (u *UpdateShortSentMessage ) String () string {
if u == nil {
return "UpdateShortSentMessage(nil)"
}
type Alias UpdateShortSentMessage
return fmt .Sprintf ("UpdateShortSentMessage%+v" , Alias (*u ))
}
func (u *UpdateShortSentMessage ) FillFrom (from interface {
GetOut () (value bool )
GetID () (value int )
GetPts () (value int )
GetPtsCount () (value int )
GetDate () (value int )
GetMedia () (value MessageMediaClass , ok bool )
GetEntities () (value []MessageEntityClass , ok bool )
GetTTLPeriod () (value int , ok bool )
}) {
u .Out = from .GetOut ()
u .ID = from .GetID ()
u .Pts = from .GetPts ()
u .PtsCount = from .GetPtsCount ()
u .Date = from .GetDate ()
if val , ok := from .GetMedia (); ok {
u .Media = val
}
if val , ok := from .GetEntities (); ok {
u .Entities = val
}
if val , ok := from .GetTTLPeriod (); ok {
u .TTLPeriod = val
}
}
func (*UpdateShortSentMessage ) TypeID () uint32 {
return UpdateShortSentMessageTypeID
}
func (*UpdateShortSentMessage ) TypeName () string {
return "updateShortSentMessage"
}
func (u *UpdateShortSentMessage ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "updateShortSentMessage" ,
ID : UpdateShortSentMessageTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Out" ,
SchemaName : "out" ,
Null : !u .Flags .Has (1 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Pts" ,
SchemaName : "pts" ,
},
{
Name : "PtsCount" ,
SchemaName : "pts_count" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
{
Name : "Media" ,
SchemaName : "media" ,
Null : !u .Flags .Has (9 ),
},
{
Name : "Entities" ,
SchemaName : "entities" ,
Null : !u .Flags .Has (7 ),
},
{
Name : "TTLPeriod" ,
SchemaName : "ttl_period" ,
Null : !u .Flags .Has (25 ),
},
}
return typ
}
func (u *UpdateShortSentMessage ) SetFlags () {
if !(u .Out == false ) {
u .Flags .Set (1 )
}
if !(u .Media == nil ) {
u .Flags .Set (9 )
}
if !(u .Entities == nil ) {
u .Flags .Set (7 )
}
if !(u .TTLPeriod == 0 ) {
u .Flags .Set (25 )
}
}
func (u *UpdateShortSentMessage ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode updateShortSentMessage#9015e101 as nil" )
}
b .PutID (UpdateShortSentMessageTypeID )
return u .EncodeBare (b )
}
func (u *UpdateShortSentMessage ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode updateShortSentMessage#9015e101 as nil" )
}
u .SetFlags ()
if err := u .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updateShortSentMessage#9015e101: field flags: %w" , err )
}
b .PutInt (u .ID )
b .PutInt (u .Pts )
b .PutInt (u .PtsCount )
b .PutInt (u .Date )
if u .Flags .Has (9 ) {
if u .Media == nil {
return fmt .Errorf ("unable to encode updateShortSentMessage#9015e101: field media is nil" )
}
if err := u .Media .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updateShortSentMessage#9015e101: field media: %w" , err )
}
}
if u .Flags .Has (7 ) {
b .PutVectorHeader (len (u .Entities ))
for idx , v := range u .Entities {
if v == nil {
return fmt .Errorf ("unable to encode updateShortSentMessage#9015e101: field entities element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode updateShortSentMessage#9015e101: field entities element with index %d: %w" , idx , err )
}
}
}
if u .Flags .Has (25 ) {
b .PutInt (u .TTLPeriod )
}
return nil
}
func (u *UpdateShortSentMessage ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode updateShortSentMessage#9015e101 to nil" )
}
if err := b .ConsumeID (UpdateShortSentMessageTypeID ); err != nil {
return fmt .Errorf ("unable to decode updateShortSentMessage#9015e101: %w" , err )
}
return u .DecodeBare (b )
}
func (u *UpdateShortSentMessage ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode updateShortSentMessage#9015e101 to nil" )
}
{
if err := u .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode updateShortSentMessage#9015e101: field flags: %w" , err )
}
}
u .Out = u .Flags .Has (1 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortSentMessage#9015e101: field id: %w" , err )
}
u .ID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortSentMessage#9015e101: field pts: %w" , err )
}
u .Pts = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortSentMessage#9015e101: field pts_count: %w" , err )
}
u .PtsCount = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortSentMessage#9015e101: field date: %w" , err )
}
u .Date = value
}
if u .Flags .Has (9 ) {
value , err := DecodeMessageMedia (b )
if err != nil {
return fmt .Errorf ("unable to decode updateShortSentMessage#9015e101: field media: %w" , err )
}
u .Media = value
}
if u .Flags .Has (7 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortSentMessage#9015e101: field entities: %w" , err )
}
if headerLen > 0 {
u .Entities = make ([]MessageEntityClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeMessageEntity (b )
if err != nil {
return fmt .Errorf ("unable to decode updateShortSentMessage#9015e101: field entities: %w" , err )
}
u .Entities = append (u .Entities , value )
}
}
if u .Flags .Has (25 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode updateShortSentMessage#9015e101: field ttl_period: %w" , err )
}
u .TTLPeriod = value
}
return nil
}
func (u *UpdateShortSentMessage ) SetOut (value bool ) {
if value {
u .Flags .Set (1 )
u .Out = true
} else {
u .Flags .Unset (1 )
u .Out = false
}
}
func (u *UpdateShortSentMessage ) GetOut () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (1 )
}
func (u *UpdateShortSentMessage ) GetID () (value int ) {
if u == nil {
return
}
return u .ID
}
func (u *UpdateShortSentMessage ) GetPts () (value int ) {
if u == nil {
return
}
return u .Pts
}
func (u *UpdateShortSentMessage ) GetPtsCount () (value int ) {
if u == nil {
return
}
return u .PtsCount
}
func (u *UpdateShortSentMessage ) GetDate () (value int ) {
if u == nil {
return
}
return u .Date
}
func (u *UpdateShortSentMessage ) SetMedia (value MessageMediaClass ) {
u .Flags .Set (9 )
u .Media = value
}
func (u *UpdateShortSentMessage ) GetMedia () (value MessageMediaClass , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (9 ) {
return value , false
}
return u .Media , true
}
func (u *UpdateShortSentMessage ) SetEntities (value []MessageEntityClass ) {
u .Flags .Set (7 )
u .Entities = value
}
func (u *UpdateShortSentMessage ) GetEntities () (value []MessageEntityClass , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (7 ) {
return value , false
}
return u .Entities , true
}
func (u *UpdateShortSentMessage ) SetTTLPeriod (value int ) {
u .Flags .Set (25 )
u .TTLPeriod = value
}
func (u *UpdateShortSentMessage ) GetTTLPeriod () (value int , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (25 ) {
return value , false
}
return u .TTLPeriod , true
}
func (u *UpdateShortSentMessage ) MapEntities () (value MessageEntityClassArray , ok bool ) {
if !u .Flags .Has (7 ) {
return value , false
}
return MessageEntityClassArray (u .Entities ), true
}
const UpdatesClassName = "Updates"
type UpdatesClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () UpdatesClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeUpdates (buf *bin .Buffer ) (UpdatesClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case UpdatesTooLongTypeID :
v := UpdatesTooLong {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode UpdatesClass: %w" , err )
}
return &v , nil
case UpdateShortMessageTypeID :
v := UpdateShortMessage {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode UpdatesClass: %w" , err )
}
return &v , nil
case UpdateShortChatMessageTypeID :
v := UpdateShortChatMessage {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode UpdatesClass: %w" , err )
}
return &v , nil
case UpdateShortTypeID :
v := UpdateShort {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode UpdatesClass: %w" , err )
}
return &v , nil
case UpdatesCombinedTypeID :
v := UpdatesCombined {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode UpdatesClass: %w" , err )
}
return &v , nil
case UpdatesTypeID :
v := Updates {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode UpdatesClass: %w" , err )
}
return &v , nil
case UpdateShortSentMessageTypeID :
v := UpdateShortSentMessage {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode UpdatesClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode UpdatesClass: %w" , bin .NewUnexpectedID (id ))
}
}
type UpdatesBox struct {
Updates UpdatesClass
}
func (b *UpdatesBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode UpdatesBox to nil" )
}
v , err := DecodeUpdates (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .Updates = v
return nil
}
func (b *UpdatesBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .Updates == nil {
return fmt .Errorf ("unable to encode UpdatesClass as nil" )
}
return b .Updates .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 .