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 ExportedChatlistInvite struct {
Flags bin .Fields
Title string
URL string
Peers []PeerClass
}
const ExportedChatlistInviteTypeID = 0xc5181ac
var (
_ bin .Encoder = &ExportedChatlistInvite {}
_ bin .Decoder = &ExportedChatlistInvite {}
_ bin .BareEncoder = &ExportedChatlistInvite {}
_ bin .BareDecoder = &ExportedChatlistInvite {}
)
func (e *ExportedChatlistInvite ) Zero () bool {
if e == nil {
return true
}
if !(e .Flags .Zero ()) {
return false
}
if !(e .Title == "" ) {
return false
}
if !(e .URL == "" ) {
return false
}
if !(e .Peers == nil ) {
return false
}
return true
}
func (e *ExportedChatlistInvite ) String () string {
if e == nil {
return "ExportedChatlistInvite(nil)"
}
type Alias ExportedChatlistInvite
return fmt .Sprintf ("ExportedChatlistInvite%+v" , Alias (*e ))
}
func (e *ExportedChatlistInvite ) FillFrom (from interface {
GetTitle () (value string )
GetURL () (value string )
GetPeers () (value []PeerClass )
}) {
e .Title = from .GetTitle ()
e .URL = from .GetURL ()
e .Peers = from .GetPeers ()
}
func (*ExportedChatlistInvite ) TypeID () uint32 {
return ExportedChatlistInviteTypeID
}
func (*ExportedChatlistInvite ) TypeName () string {
return "exportedChatlistInvite"
}
func (e *ExportedChatlistInvite ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "exportedChatlistInvite" ,
ID : ExportedChatlistInviteTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Title" ,
SchemaName : "title" ,
},
{
Name : "URL" ,
SchemaName : "url" ,
},
{
Name : "Peers" ,
SchemaName : "peers" ,
},
}
return typ
}
func (e *ExportedChatlistInvite ) SetFlags () {
}
func (e *ExportedChatlistInvite ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode exportedChatlistInvite#c5181ac as nil" )
}
b .PutID (ExportedChatlistInviteTypeID )
return e .EncodeBare (b )
}
func (e *ExportedChatlistInvite ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode exportedChatlistInvite#c5181ac as nil" )
}
e .SetFlags ()
if err := e .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode exportedChatlistInvite#c5181ac: field flags: %w" , err )
}
b .PutString (e .Title )
b .PutString (e .URL )
b .PutVectorHeader (len (e .Peers ))
for idx , v := range e .Peers {
if v == nil {
return fmt .Errorf ("unable to encode exportedChatlistInvite#c5181ac: field peers element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode exportedChatlistInvite#c5181ac: field peers element with index %d: %w" , idx , err )
}
}
return nil
}
func (e *ExportedChatlistInvite ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode exportedChatlistInvite#c5181ac to nil" )
}
if err := b .ConsumeID (ExportedChatlistInviteTypeID ); err != nil {
return fmt .Errorf ("unable to decode exportedChatlistInvite#c5181ac: %w" , err )
}
return e .DecodeBare (b )
}
func (e *ExportedChatlistInvite ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode exportedChatlistInvite#c5181ac to nil" )
}
{
if err := e .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode exportedChatlistInvite#c5181ac: field flags: %w" , err )
}
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode exportedChatlistInvite#c5181ac: field title: %w" , err )
}
e .Title = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode exportedChatlistInvite#c5181ac: field url: %w" , err )
}
e .URL = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode exportedChatlistInvite#c5181ac: field peers: %w" , err )
}
if headerLen > 0 {
e .Peers = make ([]PeerClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodePeer (b )
if err != nil {
return fmt .Errorf ("unable to decode exportedChatlistInvite#c5181ac: field peers: %w" , err )
}
e .Peers = append (e .Peers , value )
}
}
return nil
}
func (e *ExportedChatlistInvite ) GetTitle () (value string ) {
if e == nil {
return
}
return e .Title
}
func (e *ExportedChatlistInvite ) GetURL () (value string ) {
if e == nil {
return
}
return e .URL
}
func (e *ExportedChatlistInvite ) GetPeers () (value []PeerClass ) {
if e == nil {
return
}
return e .Peers
}
func (e *ExportedChatlistInvite ) MapPeers () (value PeerClassArray ) {
return PeerClassArray (e .Peers )
}
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 .