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 ChatlistsJoinChatlistInviteRequest struct {
Slug string
Peers []InputPeerClass
}
const ChatlistsJoinChatlistInviteRequestTypeID = 0xa6b1e39a
var (
_ bin .Encoder = &ChatlistsJoinChatlistInviteRequest {}
_ bin .Decoder = &ChatlistsJoinChatlistInviteRequest {}
_ bin .BareEncoder = &ChatlistsJoinChatlistInviteRequest {}
_ bin .BareDecoder = &ChatlistsJoinChatlistInviteRequest {}
)
func (j *ChatlistsJoinChatlistInviteRequest ) Zero () bool {
if j == nil {
return true
}
if !(j .Slug == "" ) {
return false
}
if !(j .Peers == nil ) {
return false
}
return true
}
func (j *ChatlistsJoinChatlistInviteRequest ) String () string {
if j == nil {
return "ChatlistsJoinChatlistInviteRequest(nil)"
}
type Alias ChatlistsJoinChatlistInviteRequest
return fmt .Sprintf ("ChatlistsJoinChatlistInviteRequest%+v" , Alias (*j ))
}
func (j *ChatlistsJoinChatlistInviteRequest ) FillFrom (from interface {
GetSlug () (value string )
GetPeers () (value []InputPeerClass )
}) {
j .Slug = from .GetSlug ()
j .Peers = from .GetPeers ()
}
func (*ChatlistsJoinChatlistInviteRequest ) TypeID () uint32 {
return ChatlistsJoinChatlistInviteRequestTypeID
}
func (*ChatlistsJoinChatlistInviteRequest ) TypeName () string {
return "chatlists.joinChatlistInvite"
}
func (j *ChatlistsJoinChatlistInviteRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chatlists.joinChatlistInvite" ,
ID : ChatlistsJoinChatlistInviteRequestTypeID ,
}
if j == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Slug" ,
SchemaName : "slug" ,
},
{
Name : "Peers" ,
SchemaName : "peers" ,
},
}
return typ
}
func (j *ChatlistsJoinChatlistInviteRequest ) Encode (b *bin .Buffer ) error {
if j == nil {
return fmt .Errorf ("can't encode chatlists.joinChatlistInvite#a6b1e39a as nil" )
}
b .PutID (ChatlistsJoinChatlistInviteRequestTypeID )
return j .EncodeBare (b )
}
func (j *ChatlistsJoinChatlistInviteRequest ) EncodeBare (b *bin .Buffer ) error {
if j == nil {
return fmt .Errorf ("can't encode chatlists.joinChatlistInvite#a6b1e39a as nil" )
}
b .PutString (j .Slug )
b .PutVectorHeader (len (j .Peers ))
for idx , v := range j .Peers {
if v == nil {
return fmt .Errorf ("unable to encode chatlists.joinChatlistInvite#a6b1e39a: field peers element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chatlists.joinChatlistInvite#a6b1e39a: field peers element with index %d: %w" , idx , err )
}
}
return nil
}
func (j *ChatlistsJoinChatlistInviteRequest ) Decode (b *bin .Buffer ) error {
if j == nil {
return fmt .Errorf ("can't decode chatlists.joinChatlistInvite#a6b1e39a to nil" )
}
if err := b .ConsumeID (ChatlistsJoinChatlistInviteRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode chatlists.joinChatlistInvite#a6b1e39a: %w" , err )
}
return j .DecodeBare (b )
}
func (j *ChatlistsJoinChatlistInviteRequest ) DecodeBare (b *bin .Buffer ) error {
if j == nil {
return fmt .Errorf ("can't decode chatlists.joinChatlistInvite#a6b1e39a to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode chatlists.joinChatlistInvite#a6b1e39a: field slug: %w" , err )
}
j .Slug = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode chatlists.joinChatlistInvite#a6b1e39a: field peers: %w" , err )
}
if headerLen > 0 {
j .Peers = make ([]InputPeerClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode chatlists.joinChatlistInvite#a6b1e39a: field peers: %w" , err )
}
j .Peers = append (j .Peers , value )
}
}
return nil
}
func (j *ChatlistsJoinChatlistInviteRequest ) GetSlug () (value string ) {
if j == nil {
return
}
return j .Slug
}
func (j *ChatlistsJoinChatlistInviteRequest ) GetPeers () (value []InputPeerClass ) {
if j == nil {
return
}
return j .Peers
}
func (j *ChatlistsJoinChatlistInviteRequest ) MapPeers () (value InputPeerClassArray ) {
return InputPeerClassArray (j .Peers )
}
func (c *Client ) ChatlistsJoinChatlistInvite (ctx context .Context , request *ChatlistsJoinChatlistInviteRequest ) (UpdatesClass , error ) {
var result UpdatesBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .Updates , nil
}
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 .