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 CommunitiesParticipantJoinedChats struct {
CreatorChatIDs []int64
JoinedChatIDs []int64
Chats []ChatClass
Users []UserClass
}
const CommunitiesParticipantJoinedChatsTypeID = 0x8d78512a
var (
_ bin .Encoder = &CommunitiesParticipantJoinedChats {}
_ bin .Decoder = &CommunitiesParticipantJoinedChats {}
_ bin .BareEncoder = &CommunitiesParticipantJoinedChats {}
_ bin .BareDecoder = &CommunitiesParticipantJoinedChats {}
)
func (p *CommunitiesParticipantJoinedChats ) Zero () bool {
if p == nil {
return true
}
if !(p .CreatorChatIDs == nil ) {
return false
}
if !(p .JoinedChatIDs == nil ) {
return false
}
if !(p .Chats == nil ) {
return false
}
if !(p .Users == nil ) {
return false
}
return true
}
func (p *CommunitiesParticipantJoinedChats ) String () string {
if p == nil {
return "CommunitiesParticipantJoinedChats(nil)"
}
type Alias CommunitiesParticipantJoinedChats
return fmt .Sprintf ("CommunitiesParticipantJoinedChats%+v" , Alias (*p ))
}
func (p *CommunitiesParticipantJoinedChats ) FillFrom (from interface {
GetCreatorChatIDs () (value []int64 )
GetJoinedChatIDs () (value []int64 )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
p .CreatorChatIDs = from .GetCreatorChatIDs ()
p .JoinedChatIDs = from .GetJoinedChatIDs ()
p .Chats = from .GetChats ()
p .Users = from .GetUsers ()
}
func (*CommunitiesParticipantJoinedChats ) TypeID () uint32 {
return CommunitiesParticipantJoinedChatsTypeID
}
func (*CommunitiesParticipantJoinedChats ) TypeName () string {
return "communities.participantJoinedChats"
}
func (p *CommunitiesParticipantJoinedChats ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "communities.participantJoinedChats" ,
ID : CommunitiesParticipantJoinedChatsTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "CreatorChatIDs" ,
SchemaName : "creator_chat_ids" ,
},
{
Name : "JoinedChatIDs" ,
SchemaName : "joined_chat_ids" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (p *CommunitiesParticipantJoinedChats ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode communities.participantJoinedChats#8d78512a as nil" )
}
b .PutID (CommunitiesParticipantJoinedChatsTypeID )
return p .EncodeBare (b )
}
func (p *CommunitiesParticipantJoinedChats ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode communities.participantJoinedChats#8d78512a as nil" )
}
b .PutVectorHeader (len (p .CreatorChatIDs ))
for _ , v := range p .CreatorChatIDs {
b .PutLong (v )
}
b .PutVectorHeader (len (p .JoinedChatIDs ))
for _ , v := range p .JoinedChatIDs {
b .PutLong (v )
}
b .PutVectorHeader (len (p .Chats ))
for idx , v := range p .Chats {
if v == nil {
return fmt .Errorf ("unable to encode communities.participantJoinedChats#8d78512a: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode communities.participantJoinedChats#8d78512a: field chats element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (p .Users ))
for idx , v := range p .Users {
if v == nil {
return fmt .Errorf ("unable to encode communities.participantJoinedChats#8d78512a: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode communities.participantJoinedChats#8d78512a: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (p *CommunitiesParticipantJoinedChats ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode communities.participantJoinedChats#8d78512a to nil" )
}
if err := b .ConsumeID (CommunitiesParticipantJoinedChatsTypeID ); err != nil {
return fmt .Errorf ("unable to decode communities.participantJoinedChats#8d78512a: %w" , err )
}
return p .DecodeBare (b )
}
func (p *CommunitiesParticipantJoinedChats ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode communities.participantJoinedChats#8d78512a to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode communities.participantJoinedChats#8d78512a: field creator_chat_ids: %w" , err )
}
if headerLen > 0 {
p .CreatorChatIDs = make ([]int64 , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode communities.participantJoinedChats#8d78512a: field creator_chat_ids: %w" , err )
}
p .CreatorChatIDs = append (p .CreatorChatIDs , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode communities.participantJoinedChats#8d78512a: field joined_chat_ids: %w" , err )
}
if headerLen > 0 {
p .JoinedChatIDs = make ([]int64 , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode communities.participantJoinedChats#8d78512a: field joined_chat_ids: %w" , err )
}
p .JoinedChatIDs = append (p .JoinedChatIDs , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode communities.participantJoinedChats#8d78512a: field chats: %w" , err )
}
if headerLen > 0 {
p .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 communities.participantJoinedChats#8d78512a: field chats: %w" , err )
}
p .Chats = append (p .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode communities.participantJoinedChats#8d78512a: field users: %w" , err )
}
if headerLen > 0 {
p .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 communities.participantJoinedChats#8d78512a: field users: %w" , err )
}
p .Users = append (p .Users , value )
}
}
return nil
}
func (p *CommunitiesParticipantJoinedChats ) GetCreatorChatIDs () (value []int64 ) {
if p == nil {
return
}
return p .CreatorChatIDs
}
func (p *CommunitiesParticipantJoinedChats ) GetJoinedChatIDs () (value []int64 ) {
if p == nil {
return
}
return p .JoinedChatIDs
}
func (p *CommunitiesParticipantJoinedChats ) GetChats () (value []ChatClass ) {
if p == nil {
return
}
return p .Chats
}
func (p *CommunitiesParticipantJoinedChats ) GetUsers () (value []UserClass ) {
if p == nil {
return
}
return p .Users
}
func (p *CommunitiesParticipantJoinedChats ) MapChats () (value ChatClassArray ) {
return ChatClassArray (p .Chats )
}
func (p *CommunitiesParticipantJoinedChats ) MapUsers () (value UserClassArray ) {
return UserClassArray (p .Users )
}
The pages are generated with Golds v0.8.4 . (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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .