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 MessagesExportedChatInvite struct {
Invite ExportedChatInviteClass
Users []UserClass
}
const MessagesExportedChatInviteTypeID = 0x1871be50
func (e MessagesExportedChatInvite ) construct () MessagesExportedChatInviteClass { return &e }
var (
_ bin .Encoder = &MessagesExportedChatInvite {}
_ bin .Decoder = &MessagesExportedChatInvite {}
_ bin .BareEncoder = &MessagesExportedChatInvite {}
_ bin .BareDecoder = &MessagesExportedChatInvite {}
_ MessagesExportedChatInviteClass = &MessagesExportedChatInvite {}
)
func (e *MessagesExportedChatInvite ) Zero () bool {
if e == nil {
return true
}
if !(e .Invite == nil ) {
return false
}
if !(e .Users == nil ) {
return false
}
return true
}
func (e *MessagesExportedChatInvite ) String () string {
if e == nil {
return "MessagesExportedChatInvite(nil)"
}
type Alias MessagesExportedChatInvite
return fmt .Sprintf ("MessagesExportedChatInvite%+v" , Alias (*e ))
}
func (e *MessagesExportedChatInvite ) FillFrom (from interface {
GetInvite () (value ExportedChatInviteClass )
GetUsers () (value []UserClass )
}) {
e .Invite = from .GetInvite ()
e .Users = from .GetUsers ()
}
func (*MessagesExportedChatInvite ) TypeID () uint32 {
return MessagesExportedChatInviteTypeID
}
func (*MessagesExportedChatInvite ) TypeName () string {
return "messages.exportedChatInvite"
}
func (e *MessagesExportedChatInvite ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.exportedChatInvite" ,
ID : MessagesExportedChatInviteTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Invite" ,
SchemaName : "invite" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (e *MessagesExportedChatInvite ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode messages.exportedChatInvite#1871be50 as nil" )
}
b .PutID (MessagesExportedChatInviteTypeID )
return e .EncodeBare (b )
}
func (e *MessagesExportedChatInvite ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode messages.exportedChatInvite#1871be50 as nil" )
}
if e .Invite == nil {
return fmt .Errorf ("unable to encode messages.exportedChatInvite#1871be50: field invite is nil" )
}
if err := e .Invite .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.exportedChatInvite#1871be50: field invite: %w" , err )
}
b .PutVectorHeader (len (e .Users ))
for idx , v := range e .Users {
if v == nil {
return fmt .Errorf ("unable to encode messages.exportedChatInvite#1871be50: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.exportedChatInvite#1871be50: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (e *MessagesExportedChatInvite ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode messages.exportedChatInvite#1871be50 to nil" )
}
if err := b .ConsumeID (MessagesExportedChatInviteTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.exportedChatInvite#1871be50: %w" , err )
}
return e .DecodeBare (b )
}
func (e *MessagesExportedChatInvite ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode messages.exportedChatInvite#1871be50 to nil" )
}
{
value , err := DecodeExportedChatInvite (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.exportedChatInvite#1871be50: field invite: %w" , err )
}
e .Invite = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.exportedChatInvite#1871be50: field users: %w" , err )
}
if headerLen > 0 {
e .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.exportedChatInvite#1871be50: field users: %w" , err )
}
e .Users = append (e .Users , value )
}
}
return nil
}
func (e *MessagesExportedChatInvite ) GetInvite () (value ExportedChatInviteClass ) {
if e == nil {
return
}
return e .Invite
}
func (e *MessagesExportedChatInvite ) GetUsers () (value []UserClass ) {
if e == nil {
return
}
return e .Users
}
func (e *MessagesExportedChatInvite ) MapUsers () (value UserClassArray ) {
return UserClassArray (e .Users )
}
type MessagesExportedChatInviteReplaced struct {
Invite ExportedChatInviteClass
NewInvite ExportedChatInviteClass
Users []UserClass
}
const MessagesExportedChatInviteReplacedTypeID = 0x222600ef
func (e MessagesExportedChatInviteReplaced ) construct () MessagesExportedChatInviteClass { return &e }
var (
_ bin .Encoder = &MessagesExportedChatInviteReplaced {}
_ bin .Decoder = &MessagesExportedChatInviteReplaced {}
_ bin .BareEncoder = &MessagesExportedChatInviteReplaced {}
_ bin .BareDecoder = &MessagesExportedChatInviteReplaced {}
_ MessagesExportedChatInviteClass = &MessagesExportedChatInviteReplaced {}
)
func (e *MessagesExportedChatInviteReplaced ) Zero () bool {
if e == nil {
return true
}
if !(e .Invite == nil ) {
return false
}
if !(e .NewInvite == nil ) {
return false
}
if !(e .Users == nil ) {
return false
}
return true
}
func (e *MessagesExportedChatInviteReplaced ) String () string {
if e == nil {
return "MessagesExportedChatInviteReplaced(nil)"
}
type Alias MessagesExportedChatInviteReplaced
return fmt .Sprintf ("MessagesExportedChatInviteReplaced%+v" , Alias (*e ))
}
func (e *MessagesExportedChatInviteReplaced ) FillFrom (from interface {
GetInvite () (value ExportedChatInviteClass )
GetNewInvite () (value ExportedChatInviteClass )
GetUsers () (value []UserClass )
}) {
e .Invite = from .GetInvite ()
e .NewInvite = from .GetNewInvite ()
e .Users = from .GetUsers ()
}
func (*MessagesExportedChatInviteReplaced ) TypeID () uint32 {
return MessagesExportedChatInviteReplacedTypeID
}
func (*MessagesExportedChatInviteReplaced ) TypeName () string {
return "messages.exportedChatInviteReplaced"
}
func (e *MessagesExportedChatInviteReplaced ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.exportedChatInviteReplaced" ,
ID : MessagesExportedChatInviteReplacedTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Invite" ,
SchemaName : "invite" ,
},
{
Name : "NewInvite" ,
SchemaName : "new_invite" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (e *MessagesExportedChatInviteReplaced ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode messages.exportedChatInviteReplaced#222600ef as nil" )
}
b .PutID (MessagesExportedChatInviteReplacedTypeID )
return e .EncodeBare (b )
}
func (e *MessagesExportedChatInviteReplaced ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode messages.exportedChatInviteReplaced#222600ef as nil" )
}
if e .Invite == nil {
return fmt .Errorf ("unable to encode messages.exportedChatInviteReplaced#222600ef: field invite is nil" )
}
if err := e .Invite .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.exportedChatInviteReplaced#222600ef: field invite: %w" , err )
}
if e .NewInvite == nil {
return fmt .Errorf ("unable to encode messages.exportedChatInviteReplaced#222600ef: field new_invite is nil" )
}
if err := e .NewInvite .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.exportedChatInviteReplaced#222600ef: field new_invite: %w" , err )
}
b .PutVectorHeader (len (e .Users ))
for idx , v := range e .Users {
if v == nil {
return fmt .Errorf ("unable to encode messages.exportedChatInviteReplaced#222600ef: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.exportedChatInviteReplaced#222600ef: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (e *MessagesExportedChatInviteReplaced ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode messages.exportedChatInviteReplaced#222600ef to nil" )
}
if err := b .ConsumeID (MessagesExportedChatInviteReplacedTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.exportedChatInviteReplaced#222600ef: %w" , err )
}
return e .DecodeBare (b )
}
func (e *MessagesExportedChatInviteReplaced ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode messages.exportedChatInviteReplaced#222600ef to nil" )
}
{
value , err := DecodeExportedChatInvite (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.exportedChatInviteReplaced#222600ef: field invite: %w" , err )
}
e .Invite = value
}
{
value , err := DecodeExportedChatInvite (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.exportedChatInviteReplaced#222600ef: field new_invite: %w" , err )
}
e .NewInvite = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.exportedChatInviteReplaced#222600ef: field users: %w" , err )
}
if headerLen > 0 {
e .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.exportedChatInviteReplaced#222600ef: field users: %w" , err )
}
e .Users = append (e .Users , value )
}
}
return nil
}
func (e *MessagesExportedChatInviteReplaced ) GetInvite () (value ExportedChatInviteClass ) {
if e == nil {
return
}
return e .Invite
}
func (e *MessagesExportedChatInviteReplaced ) GetNewInvite () (value ExportedChatInviteClass ) {
if e == nil {
return
}
return e .NewInvite
}
func (e *MessagesExportedChatInviteReplaced ) GetUsers () (value []UserClass ) {
if e == nil {
return
}
return e .Users
}
func (e *MessagesExportedChatInviteReplaced ) MapUsers () (value UserClassArray ) {
return UserClassArray (e .Users )
}
const MessagesExportedChatInviteClassName = "messages.ExportedChatInvite"
type MessagesExportedChatInviteClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () MessagesExportedChatInviteClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetInvite () (value ExportedChatInviteClass )
GetUsers () (value []UserClass )
MapUsers () (value UserClassArray )
}
func DecodeMessagesExportedChatInvite (buf *bin .Buffer ) (MessagesExportedChatInviteClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case MessagesExportedChatInviteTypeID :
v := MessagesExportedChatInvite {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessagesExportedChatInviteClass: %w" , err )
}
return &v , nil
case MessagesExportedChatInviteReplacedTypeID :
v := MessagesExportedChatInviteReplaced {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode MessagesExportedChatInviteClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode MessagesExportedChatInviteClass: %w" , bin .NewUnexpectedID (id ))
}
}
type MessagesExportedChatInviteBox struct {
ExportedChatInvite MessagesExportedChatInviteClass
}
func (b *MessagesExportedChatInviteBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode MessagesExportedChatInviteBox to nil" )
}
v , err := DecodeMessagesExportedChatInvite (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .ExportedChatInvite = v
return nil
}
func (b *MessagesExportedChatInviteBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .ExportedChatInvite == nil {
return fmt .Errorf ("unable to encode MessagesExportedChatInviteClass as nil" )
}
return b .ExportedChatInvite .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 .