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 MessagesDialogs struct {
Dialogs []DialogClass
Messages []MessageClass
Chats []ChatClass
Users []UserClass
}
const MessagesDialogsTypeID = 0x15ba6c40
func (d MessagesDialogs ) construct () MessagesDialogsClass { return &d }
var (
_ bin .Encoder = &MessagesDialogs {}
_ bin .Decoder = &MessagesDialogs {}
_ bin .BareEncoder = &MessagesDialogs {}
_ bin .BareDecoder = &MessagesDialogs {}
_ MessagesDialogsClass = &MessagesDialogs {}
)
func (d *MessagesDialogs ) Zero () bool {
if d == nil {
return true
}
if !(d .Dialogs == nil ) {
return false
}
if !(d .Messages == nil ) {
return false
}
if !(d .Chats == nil ) {
return false
}
if !(d .Users == nil ) {
return false
}
return true
}
func (d *MessagesDialogs ) String () string {
if d == nil {
return "MessagesDialogs(nil)"
}
type Alias MessagesDialogs
return fmt .Sprintf ("MessagesDialogs%+v" , Alias (*d ))
}
func (d *MessagesDialogs ) FillFrom (from interface {
GetDialogs () (value []DialogClass )
GetMessages () (value []MessageClass )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
d .Dialogs = from .GetDialogs ()
d .Messages = from .GetMessages ()
d .Chats = from .GetChats ()
d .Users = from .GetUsers ()
}
func (*MessagesDialogs ) TypeID () uint32 {
return MessagesDialogsTypeID
}
func (*MessagesDialogs ) TypeName () string {
return "messages.dialogs"
}
func (d *MessagesDialogs ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.dialogs" ,
ID : MessagesDialogsTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Dialogs" ,
SchemaName : "dialogs" ,
},
{
Name : "Messages" ,
SchemaName : "messages" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (d *MessagesDialogs ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode messages.dialogs#15ba6c40 as nil" )
}
b .PutID (MessagesDialogsTypeID )
return d .EncodeBare (b )
}
func (d *MessagesDialogs ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode messages.dialogs#15ba6c40 as nil" )
}
b .PutVectorHeader (len (d .Dialogs ))
for idx , v := range d .Dialogs {
if v == nil {
return fmt .Errorf ("unable to encode messages.dialogs#15ba6c40: field dialogs element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.dialogs#15ba6c40: field dialogs element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (d .Messages ))
for idx , v := range d .Messages {
if v == nil {
return fmt .Errorf ("unable to encode messages.dialogs#15ba6c40: field messages element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.dialogs#15ba6c40: field messages element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (d .Chats ))
for idx , v := range d .Chats {
if v == nil {
return fmt .Errorf ("unable to encode messages.dialogs#15ba6c40: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.dialogs#15ba6c40: field chats element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (d .Users ))
for idx , v := range d .Users {
if v == nil {
return fmt .Errorf ("unable to encode messages.dialogs#15ba6c40: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.dialogs#15ba6c40: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (d *MessagesDialogs ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode messages.dialogs#15ba6c40 to nil" )
}
if err := b .ConsumeID (MessagesDialogsTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.dialogs#15ba6c40: %w" , err )
}
return d .DecodeBare (b )
}
func (d *MessagesDialogs ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode messages.dialogs#15ba6c40 to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.dialogs#15ba6c40: field dialogs: %w" , err )
}
if headerLen > 0 {
d .Dialogs = make ([]DialogClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeDialog (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.dialogs#15ba6c40: field dialogs: %w" , err )
}
d .Dialogs = append (d .Dialogs , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.dialogs#15ba6c40: field messages: %w" , err )
}
if headerLen > 0 {
d .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.dialogs#15ba6c40: field messages: %w" , err )
}
d .Messages = append (d .Messages , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.dialogs#15ba6c40: field chats: %w" , err )
}
if headerLen > 0 {
d .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.dialogs#15ba6c40: field chats: %w" , err )
}
d .Chats = append (d .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.dialogs#15ba6c40: field users: %w" , err )
}
if headerLen > 0 {
d .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.dialogs#15ba6c40: field users: %w" , err )
}
d .Users = append (d .Users , value )
}
}
return nil
}
func (d *MessagesDialogs ) GetDialogs () (value []DialogClass ) {
if d == nil {
return
}
return d .Dialogs
}
func (d *MessagesDialogs ) GetMessages () (value []MessageClass ) {
if d == nil {
return
}
return d .Messages
}
func (d *MessagesDialogs ) GetChats () (value []ChatClass ) {
if d == nil {
return
}
return d .Chats
}
func (d *MessagesDialogs ) GetUsers () (value []UserClass ) {
if d == nil {
return
}
return d .Users
}
func (d *MessagesDialogs ) MapDialogs () (value DialogClassArray ) {
return DialogClassArray (d .Dialogs )
}
func (d *MessagesDialogs ) MapMessages () (value MessageClassArray ) {
return MessageClassArray (d .Messages )
}
func (d *MessagesDialogs ) MapChats () (value ChatClassArray ) {
return ChatClassArray (d .Chats )
}
func (d *MessagesDialogs ) MapUsers () (value UserClassArray ) {
return UserClassArray (d .Users )
}
type MessagesDialogsSlice struct {
Count int
Dialogs []DialogClass
Messages []MessageClass
Chats []ChatClass
Users []UserClass
}
const MessagesDialogsSliceTypeID = 0x71e094f3
func (d MessagesDialogsSlice ) construct () MessagesDialogsClass { return &d }
var (
_ bin .Encoder = &MessagesDialogsSlice {}
_ bin .Decoder = &MessagesDialogsSlice {}
_ bin .BareEncoder = &MessagesDialogsSlice {}
_ bin .BareDecoder = &MessagesDialogsSlice {}
_ MessagesDialogsClass = &MessagesDialogsSlice {}
)
func (d *MessagesDialogsSlice ) Zero () bool {
if d == nil {
return true
}
if !(d .Count == 0 ) {
return false
}
if !(d .Dialogs == nil ) {
return false
}
if !(d .Messages == nil ) {
return false
}
if !(d .Chats == nil ) {
return false
}
if !(d .Users == nil ) {
return false
}
return true
}
func (d *MessagesDialogsSlice ) String () string {
if d == nil {
return "MessagesDialogsSlice(nil)"
}
type Alias MessagesDialogsSlice
return fmt .Sprintf ("MessagesDialogsSlice%+v" , Alias (*d ))
}
func (d *MessagesDialogsSlice ) FillFrom (from interface {
GetCount () (value int )
GetDialogs () (value []DialogClass )
GetMessages () (value []MessageClass )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
d .Count = from .GetCount ()
d .Dialogs = from .GetDialogs ()
d .Messages = from .GetMessages ()
d .Chats = from .GetChats ()
d .Users = from .GetUsers ()
}
func (*MessagesDialogsSlice ) TypeID () uint32 {
return MessagesDialogsSliceTypeID
}
func (*MessagesDialogsSlice ) TypeName () string {
return "messages.dialogsSlice"
}
func (d *MessagesDialogsSlice ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.dialogsSlice" ,
ID : MessagesDialogsSliceTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Count" ,
SchemaName : "count" ,
},
{
Name : "Dialogs" ,
SchemaName : "dialogs" ,
},
{
Name : "Messages" ,
SchemaName : "messages" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (d *MessagesDialogsSlice ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode messages.dialogsSlice#71e094f3 as nil" )
}
b .PutID (MessagesDialogsSliceTypeID )
return d .EncodeBare (b )
}
func (d *MessagesDialogsSlice ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode messages.dialogsSlice#71e094f3 as nil" )
}
b .PutInt (d .Count )
b .PutVectorHeader (len (d .Dialogs ))
for idx , v := range d .Dialogs {
if v == nil {
return fmt .Errorf ("unable to encode messages.dialogsSlice#71e094f3: field dialogs element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.dialogsSlice#71e094f3: field dialogs element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (d .Messages ))
for idx , v := range d .Messages {
if v == nil {
return fmt .Errorf ("unable to encode messages.dialogsSlice#71e094f3: field messages element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.dialogsSlice#71e094f3: field messages element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (d .Chats ))
for idx , v := range d .Chats {
if v == nil {
return fmt .Errorf ("unable to encode messages.dialogsSlice#71e094f3: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.dialogsSlice#71e094f3: field chats element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (d .Users ))
for idx , v := range d .Users {
if v == nil {
return fmt .Errorf ("unable to encode messages.dialogsSlice#71e094f3: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.dialogsSlice#71e094f3: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (d *MessagesDialogsSlice ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode messages.dialogsSlice#71e094f3 to nil" )
}
if err := b .ConsumeID (MessagesDialogsSliceTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.dialogsSlice#71e094f3: %w" , err )
}
return d .DecodeBare (b )
}
func (d *MessagesDialogsSlice ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode messages.dialogsSlice#71e094f3 to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.dialogsSlice#71e094f3: field count: %w" , err )
}
d .Count = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.dialogsSlice#71e094f3: field dialogs: %w" , err )
}
if headerLen > 0 {
d .Dialogs = make ([]DialogClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeDialog (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.dialogsSlice#71e094f3: field dialogs: %w" , err )
}
d .Dialogs = append (d .Dialogs , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.dialogsSlice#71e094f3: field messages: %w" , err )
}
if headerLen > 0 {
d .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.dialogsSlice#71e094f3: field messages: %w" , err )
}
d .Messages = append (d .Messages , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.dialogsSlice#71e094f3: field chats: %w" , err )
}
if headerLen > 0 {
d .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.dialogsSlice#71e094f3: field chats: %w" , err )
}
d .Chats = append (d .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.dialogsSlice#71e094f3: field users: %w" , err )
}
if headerLen > 0 {
d .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.dialogsSlice#71e094f3: field users: %w" , err )
}
d .Users = append (d .Users , value )
}
}
return nil
}
func (d *MessagesDialogsSlice ) GetCount () (value int ) {
if d == nil {
return
}
return d .Count
}
func (d *MessagesDialogsSlice ) GetDialogs () (value []DialogClass ) {
if d == nil {
return
}
return d .Dialogs
}
func (d *MessagesDialogsSlice ) GetMessages () (value []MessageClass ) {
if d == nil {
return
}
return d .Messages
}
func (d *MessagesDialogsSlice ) GetChats () (value []ChatClass ) {
if d == nil {
return
}
return d .Chats
}
func (d *MessagesDialogsSlice ) GetUsers () (value []UserClass ) {
if d == nil {
return
}
return d .Users
}
func (d *MessagesDialogsSlice ) MapDialogs () (value DialogClassArray ) {
return DialogClassArray (d .Dialogs )
}
func (d *MessagesDialogsSlice ) MapMessages () (value MessageClassArray ) {
return MessageClassArray (d .Messages )
}
func (d *MessagesDialogsSlice ) MapChats () (value ChatClassArray ) {
return ChatClassArray (d .Chats )
}
func (d *MessagesDialogsSlice ) MapUsers () (value UserClassArray ) {
return UserClassArray (d .Users )
}
type MessagesDialogsNotModified struct {
Count int
}
const MessagesDialogsNotModifiedTypeID = 0xf0e3e596
func (d MessagesDialogsNotModified ) construct () MessagesDialogsClass { return &d }
var (
_ bin .Encoder = &MessagesDialogsNotModified {}
_ bin .Decoder = &MessagesDialogsNotModified {}
_ bin .BareEncoder = &MessagesDialogsNotModified {}
_ bin .BareDecoder = &MessagesDialogsNotModified {}
_ MessagesDialogsClass = &MessagesDialogsNotModified {}
)
func (d *MessagesDialogsNotModified ) Zero () bool {
if d == nil {
return true
}
if !(d .Count == 0 ) {
return false
}
return true
}
func (d *MessagesDialogsNotModified ) String () string {
if d == nil {
return "MessagesDialogsNotModified(nil)"
}
type Alias MessagesDialogsNotModified
return fmt .Sprintf ("MessagesDialogsNotModified%+v" , Alias (*d ))
}
func (d *MessagesDialogsNotModified ) FillFrom (from interface {
GetCount () (value int )
}) {
d .Count = from .GetCount ()
}
func (*MessagesDialogsNotModified ) TypeID () uint32 {
return MessagesDialogsNotModifiedTypeID
}
func (*MessagesDialogsNotModified ) TypeName () string {
return "messages.dialogsNotModified"
}
func (d *MessagesDialogsNotModified ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.dialogsNotModified" ,
ID : MessagesDialogsNotModifiedTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Count" ,
SchemaName : "count" ,
},
}
return typ
}
func (d *MessagesDialogsNotModified ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode messages.dialogsNotModified#f0e3e596 as nil" )
}
b .PutID (MessagesDialogsNotModifiedTypeID )
return d .EncodeBare (b )
}
func (d *MessagesDialogsNotModified ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode messages.dialogsNotModified#f0e3e596 as nil" )
}
b .PutInt (d .Count )
return nil
}
func (d *MessagesDialogsNotModified ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode messages.dialogsNotModified#f0e3e596 to nil" )
}
if err := b .ConsumeID (MessagesDialogsNotModifiedTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.dialogsNotModified#f0e3e596: %w" , err )
}
return d .DecodeBare (b )
}
func (d *MessagesDialogsNotModified ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode messages.dialogsNotModified#f0e3e596 to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.dialogsNotModified#f0e3e596: field count: %w" , err )
}
d .Count = value
}
return nil
}
func (d *MessagesDialogsNotModified ) GetCount () (value int ) {
if d == nil {
return
}
return d .Count
}
const MessagesDialogsClassName = "messages.Dialogs"
type MessagesDialogsClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () MessagesDialogsClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsModified () (ModifiedMessagesDialogs , bool )
}
type ModifiedMessagesDialogs interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () MessagesDialogsClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetDialogs () (value []DialogClass )
GetMessages () (value []MessageClass )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}
func (d *MessagesDialogs ) AsModified () (ModifiedMessagesDialogs , bool ) {
value , ok := (MessagesDialogsClass (d )).(ModifiedMessagesDialogs )
return value , ok
}
func (d *MessagesDialogsSlice ) AsModified () (ModifiedMessagesDialogs , bool ) {
value , ok := (MessagesDialogsClass (d )).(ModifiedMessagesDialogs )
return value , ok
}
func (d *MessagesDialogsNotModified ) AsModified () (ModifiedMessagesDialogs , bool ) {
value , ok := (MessagesDialogsClass (d )).(ModifiedMessagesDialogs )
return value , ok
}
func DecodeMessagesDialogs (buf *bin .Buffer ) (MessagesDialogsClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case MessagesDialogsTypeID :
v := MessagesDialogs {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessagesDialogsClass: %w" , err )
}
return &v , nil
case MessagesDialogsSliceTypeID :
v := MessagesDialogsSlice {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessagesDialogsClass: %w" , err )
}
return &v , nil
case MessagesDialogsNotModifiedTypeID :
v := MessagesDialogsNotModified {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessagesDialogsClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode MessagesDialogsClass: %w" , bin .NewUnexpectedID (id ))
}
}
type MessagesDialogsBox struct {
Dialogs MessagesDialogsClass
}
func (b *MessagesDialogsBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode MessagesDialogsBox to nil" )
}
v , err := DecodeMessagesDialogs (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .Dialogs = v
return nil
}
func (b *MessagesDialogsBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .Dialogs == nil {
return fmt .Errorf ("unable to encode MessagesDialogsClass as nil" )
}
return b .Dialogs .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 .