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 ChannelsChannelParticipants struct {
Count int
Participants []ChannelParticipantClass
Chats []ChatClass
Users []UserClass
}
const ChannelsChannelParticipantsTypeID = 0x9ab0feaf
func (c ChannelsChannelParticipants ) construct () ChannelsChannelParticipantsClass { return &c }
var (
_ bin .Encoder = &ChannelsChannelParticipants {}
_ bin .Decoder = &ChannelsChannelParticipants {}
_ bin .BareEncoder = &ChannelsChannelParticipants {}
_ bin .BareDecoder = &ChannelsChannelParticipants {}
_ ChannelsChannelParticipantsClass = &ChannelsChannelParticipants {}
)
func (c *ChannelsChannelParticipants ) Zero () bool {
if c == nil {
return true
}
if !(c .Count == 0 ) {
return false
}
if !(c .Participants == nil ) {
return false
}
if !(c .Chats == nil ) {
return false
}
if !(c .Users == nil ) {
return false
}
return true
}
func (c *ChannelsChannelParticipants ) String () string {
if c == nil {
return "ChannelsChannelParticipants(nil)"
}
type Alias ChannelsChannelParticipants
return fmt .Sprintf ("ChannelsChannelParticipants%+v" , Alias (*c ))
}
func (c *ChannelsChannelParticipants ) FillFrom (from interface {
GetCount () (value int )
GetParticipants () (value []ChannelParticipantClass )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
c .Count = from .GetCount ()
c .Participants = from .GetParticipants ()
c .Chats = from .GetChats ()
c .Users = from .GetUsers ()
}
func (*ChannelsChannelParticipants ) TypeID () uint32 {
return ChannelsChannelParticipantsTypeID
}
func (*ChannelsChannelParticipants ) TypeName () string {
return "channels.channelParticipants"
}
func (c *ChannelsChannelParticipants ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "channels.channelParticipants" ,
ID : ChannelsChannelParticipantsTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Count" ,
SchemaName : "count" ,
},
{
Name : "Participants" ,
SchemaName : "participants" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (c *ChannelsChannelParticipants ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode channels.channelParticipants#9ab0feaf as nil" )
}
b .PutID (ChannelsChannelParticipantsTypeID )
return c .EncodeBare (b )
}
func (c *ChannelsChannelParticipants ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode channels.channelParticipants#9ab0feaf as nil" )
}
b .PutInt (c .Count )
b .PutVectorHeader (len (c .Participants ))
for idx , v := range c .Participants {
if v == nil {
return fmt .Errorf ("unable to encode channels.channelParticipants#9ab0feaf: field participants element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.channelParticipants#9ab0feaf: field participants element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (c .Chats ))
for idx , v := range c .Chats {
if v == nil {
return fmt .Errorf ("unable to encode channels.channelParticipants#9ab0feaf: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.channelParticipants#9ab0feaf: field chats element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (c .Users ))
for idx , v := range c .Users {
if v == nil {
return fmt .Errorf ("unable to encode channels.channelParticipants#9ab0feaf: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.channelParticipants#9ab0feaf: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (c *ChannelsChannelParticipants ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode channels.channelParticipants#9ab0feaf to nil" )
}
if err := b .ConsumeID (ChannelsChannelParticipantsTypeID ); err != nil {
return fmt .Errorf ("unable to decode channels.channelParticipants#9ab0feaf: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChannelsChannelParticipants ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode channels.channelParticipants#9ab0feaf to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode channels.channelParticipants#9ab0feaf: field count: %w" , err )
}
c .Count = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode channels.channelParticipants#9ab0feaf: field participants: %w" , err )
}
if headerLen > 0 {
c .Participants = make ([]ChannelParticipantClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeChannelParticipant (b )
if err != nil {
return fmt .Errorf ("unable to decode channels.channelParticipants#9ab0feaf: field participants: %w" , err )
}
c .Participants = append (c .Participants , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode channels.channelParticipants#9ab0feaf: field chats: %w" , err )
}
if headerLen > 0 {
c .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 channels.channelParticipants#9ab0feaf: field chats: %w" , err )
}
c .Chats = append (c .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode channels.channelParticipants#9ab0feaf: field users: %w" , err )
}
if headerLen > 0 {
c .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 channels.channelParticipants#9ab0feaf: field users: %w" , err )
}
c .Users = append (c .Users , value )
}
}
return nil
}
func (c *ChannelsChannelParticipants ) GetCount () (value int ) {
if c == nil {
return
}
return c .Count
}
func (c *ChannelsChannelParticipants ) GetParticipants () (value []ChannelParticipantClass ) {
if c == nil {
return
}
return c .Participants
}
func (c *ChannelsChannelParticipants ) GetChats () (value []ChatClass ) {
if c == nil {
return
}
return c .Chats
}
func (c *ChannelsChannelParticipants ) GetUsers () (value []UserClass ) {
if c == nil {
return
}
return c .Users
}
func (c *ChannelsChannelParticipants ) MapParticipants () (value ChannelParticipantClassArray ) {
return ChannelParticipantClassArray (c .Participants )
}
func (c *ChannelsChannelParticipants ) MapChats () (value ChatClassArray ) {
return ChatClassArray (c .Chats )
}
func (c *ChannelsChannelParticipants ) MapUsers () (value UserClassArray ) {
return UserClassArray (c .Users )
}
type ChannelsChannelParticipantsNotModified struct {
}
const ChannelsChannelParticipantsNotModifiedTypeID = 0xf0173fe9
func (c ChannelsChannelParticipantsNotModified ) construct () ChannelsChannelParticipantsClass {
return &c
}
var (
_ bin .Encoder = &ChannelsChannelParticipantsNotModified {}
_ bin .Decoder = &ChannelsChannelParticipantsNotModified {}
_ bin .BareEncoder = &ChannelsChannelParticipantsNotModified {}
_ bin .BareDecoder = &ChannelsChannelParticipantsNotModified {}
_ ChannelsChannelParticipantsClass = &ChannelsChannelParticipantsNotModified {}
)
func (c *ChannelsChannelParticipantsNotModified ) Zero () bool {
if c == nil {
return true
}
return true
}
func (c *ChannelsChannelParticipantsNotModified ) String () string {
if c == nil {
return "ChannelsChannelParticipantsNotModified(nil)"
}
type Alias ChannelsChannelParticipantsNotModified
return fmt .Sprintf ("ChannelsChannelParticipantsNotModified%+v" , Alias (*c ))
}
func (*ChannelsChannelParticipantsNotModified ) TypeID () uint32 {
return ChannelsChannelParticipantsNotModifiedTypeID
}
func (*ChannelsChannelParticipantsNotModified ) TypeName () string {
return "channels.channelParticipantsNotModified"
}
func (c *ChannelsChannelParticipantsNotModified ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "channels.channelParticipantsNotModified" ,
ID : ChannelsChannelParticipantsNotModifiedTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (c *ChannelsChannelParticipantsNotModified ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode channels.channelParticipantsNotModified#f0173fe9 as nil" )
}
b .PutID (ChannelsChannelParticipantsNotModifiedTypeID )
return c .EncodeBare (b )
}
func (c *ChannelsChannelParticipantsNotModified ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode channels.channelParticipantsNotModified#f0173fe9 as nil" )
}
return nil
}
func (c *ChannelsChannelParticipantsNotModified ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode channels.channelParticipantsNotModified#f0173fe9 to nil" )
}
if err := b .ConsumeID (ChannelsChannelParticipantsNotModifiedTypeID ); err != nil {
return fmt .Errorf ("unable to decode channels.channelParticipantsNotModified#f0173fe9: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChannelsChannelParticipantsNotModified ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode channels.channelParticipantsNotModified#f0173fe9 to nil" )
}
return nil
}
const ChannelsChannelParticipantsClassName = "channels.ChannelParticipants"
type ChannelsChannelParticipantsClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () ChannelsChannelParticipantsClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsModified () (*ChannelsChannelParticipants , bool )
}
func (c *ChannelsChannelParticipants ) AsModified () (*ChannelsChannelParticipants , bool ) {
return c , true
}
func (c *ChannelsChannelParticipantsNotModified ) AsModified () (*ChannelsChannelParticipants , bool ) {
return nil , false
}
func DecodeChannelsChannelParticipants (buf *bin .Buffer ) (ChannelsChannelParticipantsClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case ChannelsChannelParticipantsTypeID :
v := ChannelsChannelParticipants {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ChannelsChannelParticipantsClass: %w" , err )
}
return &v , nil
case ChannelsChannelParticipantsNotModifiedTypeID :
v := ChannelsChannelParticipantsNotModified {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ChannelsChannelParticipantsClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode ChannelsChannelParticipantsClass: %w" , bin .NewUnexpectedID (id ))
}
}
type ChannelsChannelParticipantsBox struct {
ChannelParticipants ChannelsChannelParticipantsClass
}
func (b *ChannelsChannelParticipantsBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode ChannelsChannelParticipantsBox to nil" )
}
v , err := DecodeChannelsChannelParticipants (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .ChannelParticipants = v
return nil
}
func (b *ChannelsChannelParticipantsBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .ChannelParticipants == nil {
return fmt .Errorf ("unable to encode ChannelsChannelParticipantsClass as nil" )
}
return b .ChannelParticipants .Encode (buf )
}
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 .