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 PhoneGroupParticipants struct {
Count int
Participants []GroupCallParticipant
NextOffset string
Chats []ChatClass
Users []UserClass
Version int
}
const PhoneGroupParticipantsTypeID = 0xf47751b6
var (
_ bin .Encoder = &PhoneGroupParticipants {}
_ bin .Decoder = &PhoneGroupParticipants {}
_ bin .BareEncoder = &PhoneGroupParticipants {}
_ bin .BareDecoder = &PhoneGroupParticipants {}
)
func (g *PhoneGroupParticipants ) Zero () bool {
if g == nil {
return true
}
if !(g .Count == 0 ) {
return false
}
if !(g .Participants == nil ) {
return false
}
if !(g .NextOffset == "" ) {
return false
}
if !(g .Chats == nil ) {
return false
}
if !(g .Users == nil ) {
return false
}
if !(g .Version == 0 ) {
return false
}
return true
}
func (g *PhoneGroupParticipants ) String () string {
if g == nil {
return "PhoneGroupParticipants(nil)"
}
type Alias PhoneGroupParticipants
return fmt .Sprintf ("PhoneGroupParticipants%+v" , Alias (*g ))
}
func (g *PhoneGroupParticipants ) FillFrom (from interface {
GetCount () (value int )
GetParticipants () (value []GroupCallParticipant )
GetNextOffset () (value string )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
GetVersion () (value int )
}) {
g .Count = from .GetCount ()
g .Participants = from .GetParticipants ()
g .NextOffset = from .GetNextOffset ()
g .Chats = from .GetChats ()
g .Users = from .GetUsers ()
g .Version = from .GetVersion ()
}
func (*PhoneGroupParticipants ) TypeID () uint32 {
return PhoneGroupParticipantsTypeID
}
func (*PhoneGroupParticipants ) TypeName () string {
return "phone.groupParticipants"
}
func (g *PhoneGroupParticipants ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "phone.groupParticipants" ,
ID : PhoneGroupParticipantsTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Count" ,
SchemaName : "count" ,
},
{
Name : "Participants" ,
SchemaName : "participants" ,
},
{
Name : "NextOffset" ,
SchemaName : "next_offset" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
{
Name : "Version" ,
SchemaName : "version" ,
},
}
return typ
}
func (g *PhoneGroupParticipants ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode phone.groupParticipants#f47751b6 as nil" )
}
b .PutID (PhoneGroupParticipantsTypeID )
return g .EncodeBare (b )
}
func (g *PhoneGroupParticipants ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode phone.groupParticipants#f47751b6 as nil" )
}
b .PutInt (g .Count )
b .PutVectorHeader (len (g .Participants ))
for idx , v := range g .Participants {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode phone.groupParticipants#f47751b6: field participants element with index %d: %w" , idx , err )
}
}
b .PutString (g .NextOffset )
b .PutVectorHeader (len (g .Chats ))
for idx , v := range g .Chats {
if v == nil {
return fmt .Errorf ("unable to encode phone.groupParticipants#f47751b6: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode phone.groupParticipants#f47751b6: field chats element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (g .Users ))
for idx , v := range g .Users {
if v == nil {
return fmt .Errorf ("unable to encode phone.groupParticipants#f47751b6: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode phone.groupParticipants#f47751b6: field users element with index %d: %w" , idx , err )
}
}
b .PutInt (g .Version )
return nil
}
func (g *PhoneGroupParticipants ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode phone.groupParticipants#f47751b6 to nil" )
}
if err := b .ConsumeID (PhoneGroupParticipantsTypeID ); err != nil {
return fmt .Errorf ("unable to decode phone.groupParticipants#f47751b6: %w" , err )
}
return g .DecodeBare (b )
}
func (g *PhoneGroupParticipants ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode phone.groupParticipants#f47751b6 to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode phone.groupParticipants#f47751b6: field count: %w" , err )
}
g .Count = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode phone.groupParticipants#f47751b6: field participants: %w" , err )
}
if headerLen > 0 {
g .Participants = make ([]GroupCallParticipant , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value GroupCallParticipant
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode phone.groupParticipants#f47751b6: field participants: %w" , err )
}
g .Participants = append (g .Participants , value )
}
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode phone.groupParticipants#f47751b6: field next_offset: %w" , err )
}
g .NextOffset = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode phone.groupParticipants#f47751b6: field chats: %w" , err )
}
if headerLen > 0 {
g .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 phone.groupParticipants#f47751b6: field chats: %w" , err )
}
g .Chats = append (g .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode phone.groupParticipants#f47751b6: field users: %w" , err )
}
if headerLen > 0 {
g .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 phone.groupParticipants#f47751b6: field users: %w" , err )
}
g .Users = append (g .Users , value )
}
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode phone.groupParticipants#f47751b6: field version: %w" , err )
}
g .Version = value
}
return nil
}
func (g *PhoneGroupParticipants ) GetCount () (value int ) {
if g == nil {
return
}
return g .Count
}
func (g *PhoneGroupParticipants ) GetParticipants () (value []GroupCallParticipant ) {
if g == nil {
return
}
return g .Participants
}
func (g *PhoneGroupParticipants ) GetNextOffset () (value string ) {
if g == nil {
return
}
return g .NextOffset
}
func (g *PhoneGroupParticipants ) GetChats () (value []ChatClass ) {
if g == nil {
return
}
return g .Chats
}
func (g *PhoneGroupParticipants ) GetUsers () (value []UserClass ) {
if g == nil {
return
}
return g .Users
}
func (g *PhoneGroupParticipants ) GetVersion () (value int ) {
if g == nil {
return
}
return g .Version
}
func (g *PhoneGroupParticipants ) MapChats () (value ChatClassArray ) {
return ChatClassArray (g .Chats )
}
func (g *PhoneGroupParticipants ) MapUsers () (value UserClassArray ) {
return UserClassArray (g .Users )
}
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 .