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 PhoneGroupCallStars struct {
TotalStars int64
TopDonors []GroupCallDonor
Chats []ChatClass
Users []UserClass
}
const PhoneGroupCallStarsTypeID = 0x9d1dbd26
var (
_ bin .Encoder = &PhoneGroupCallStars {}
_ bin .Decoder = &PhoneGroupCallStars {}
_ bin .BareEncoder = &PhoneGroupCallStars {}
_ bin .BareDecoder = &PhoneGroupCallStars {}
)
func (g *PhoneGroupCallStars ) Zero () bool {
if g == nil {
return true
}
if !(g .TotalStars == 0 ) {
return false
}
if !(g .TopDonors == nil ) {
return false
}
if !(g .Chats == nil ) {
return false
}
if !(g .Users == nil ) {
return false
}
return true
}
func (g *PhoneGroupCallStars ) String () string {
if g == nil {
return "PhoneGroupCallStars(nil)"
}
type Alias PhoneGroupCallStars
return fmt .Sprintf ("PhoneGroupCallStars%+v" , Alias (*g ))
}
func (g *PhoneGroupCallStars ) FillFrom (from interface {
GetTotalStars () (value int64 )
GetTopDonors () (value []GroupCallDonor )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
g .TotalStars = from .GetTotalStars ()
g .TopDonors = from .GetTopDonors ()
g .Chats = from .GetChats ()
g .Users = from .GetUsers ()
}
func (*PhoneGroupCallStars ) TypeID () uint32 {
return PhoneGroupCallStarsTypeID
}
func (*PhoneGroupCallStars ) TypeName () string {
return "phone.groupCallStars"
}
func (g *PhoneGroupCallStars ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "phone.groupCallStars" ,
ID : PhoneGroupCallStarsTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "TotalStars" ,
SchemaName : "total_stars" ,
},
{
Name : "TopDonors" ,
SchemaName : "top_donors" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (g *PhoneGroupCallStars ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode phone.groupCallStars#9d1dbd26 as nil" )
}
b .PutID (PhoneGroupCallStarsTypeID )
return g .EncodeBare (b )
}
func (g *PhoneGroupCallStars ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode phone.groupCallStars#9d1dbd26 as nil" )
}
b .PutLong (g .TotalStars )
b .PutVectorHeader (len (g .TopDonors ))
for idx , v := range g .TopDonors {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode phone.groupCallStars#9d1dbd26: field top_donors element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (g .Chats ))
for idx , v := range g .Chats {
if v == nil {
return fmt .Errorf ("unable to encode phone.groupCallStars#9d1dbd26: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode phone.groupCallStars#9d1dbd26: 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.groupCallStars#9d1dbd26: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode phone.groupCallStars#9d1dbd26: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (g *PhoneGroupCallStars ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode phone.groupCallStars#9d1dbd26 to nil" )
}
if err := b .ConsumeID (PhoneGroupCallStarsTypeID ); err != nil {
return fmt .Errorf ("unable to decode phone.groupCallStars#9d1dbd26: %w" , err )
}
return g .DecodeBare (b )
}
func (g *PhoneGroupCallStars ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode phone.groupCallStars#9d1dbd26 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode phone.groupCallStars#9d1dbd26: field total_stars: %w" , err )
}
g .TotalStars = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode phone.groupCallStars#9d1dbd26: field top_donors: %w" , err )
}
if headerLen > 0 {
g .TopDonors = make ([]GroupCallDonor , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value GroupCallDonor
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode phone.groupCallStars#9d1dbd26: field top_donors: %w" , err )
}
g .TopDonors = append (g .TopDonors , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode phone.groupCallStars#9d1dbd26: 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.groupCallStars#9d1dbd26: field chats: %w" , err )
}
g .Chats = append (g .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode phone.groupCallStars#9d1dbd26: 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.groupCallStars#9d1dbd26: field users: %w" , err )
}
g .Users = append (g .Users , value )
}
}
return nil
}
func (g *PhoneGroupCallStars ) GetTotalStars () (value int64 ) {
if g == nil {
return
}
return g .TotalStars
}
func (g *PhoneGroupCallStars ) GetTopDonors () (value []GroupCallDonor ) {
if g == nil {
return
}
return g .TopDonors
}
func (g *PhoneGroupCallStars ) GetChats () (value []ChatClass ) {
if g == nil {
return
}
return g .Chats
}
func (g *PhoneGroupCallStars ) GetUsers () (value []UserClass ) {
if g == nil {
return
}
return g .Users
}
func (g *PhoneGroupCallStars ) MapChats () (value ChatClassArray ) {
return ChatClassArray (g .Chats )
}
func (g *PhoneGroupCallStars ) MapUsers () (value UserClassArray ) {
return UserClassArray (g .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 .