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 ChatParticipantsForbidden struct {
Flags bin .Fields
ChatID int64
SelfParticipant ChatParticipantClass
}
const ChatParticipantsForbiddenTypeID = 0x8763d3e1
func (c ChatParticipantsForbidden ) construct () ChatParticipantsClass { return &c }
var (
_ bin .Encoder = &ChatParticipantsForbidden {}
_ bin .Decoder = &ChatParticipantsForbidden {}
_ bin .BareEncoder = &ChatParticipantsForbidden {}
_ bin .BareDecoder = &ChatParticipantsForbidden {}
_ ChatParticipantsClass = &ChatParticipantsForbidden {}
)
func (c *ChatParticipantsForbidden ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .ChatID == 0 ) {
return false
}
if !(c .SelfParticipant == nil ) {
return false
}
return true
}
func (c *ChatParticipantsForbidden ) String () string {
if c == nil {
return "ChatParticipantsForbidden(nil)"
}
type Alias ChatParticipantsForbidden
return fmt .Sprintf ("ChatParticipantsForbidden%+v" , Alias (*c ))
}
func (c *ChatParticipantsForbidden ) FillFrom (from interface {
GetChatID () (value int64 )
GetSelfParticipant () (value ChatParticipantClass , ok bool )
}) {
c .ChatID = from .GetChatID ()
if val , ok := from .GetSelfParticipant (); ok {
c .SelfParticipant = val
}
}
func (*ChatParticipantsForbidden ) TypeID () uint32 {
return ChatParticipantsForbiddenTypeID
}
func (*ChatParticipantsForbidden ) TypeName () string {
return "chatParticipantsForbidden"
}
func (c *ChatParticipantsForbidden ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chatParticipantsForbidden" ,
ID : ChatParticipantsForbiddenTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ChatID" ,
SchemaName : "chat_id" ,
},
{
Name : "SelfParticipant" ,
SchemaName : "self_participant" ,
Null : !c .Flags .Has (0 ),
},
}
return typ
}
func (c *ChatParticipantsForbidden ) SetFlags () {
if !(c .SelfParticipant == nil ) {
c .Flags .Set (0 )
}
}
func (c *ChatParticipantsForbidden ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatParticipantsForbidden#8763d3e1 as nil" )
}
b .PutID (ChatParticipantsForbiddenTypeID )
return c .EncodeBare (b )
}
func (c *ChatParticipantsForbidden ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatParticipantsForbidden#8763d3e1 as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chatParticipantsForbidden#8763d3e1: field flags: %w" , err )
}
b .PutLong (c .ChatID )
if c .Flags .Has (0 ) {
if c .SelfParticipant == nil {
return fmt .Errorf ("unable to encode chatParticipantsForbidden#8763d3e1: field self_participant is nil" )
}
if err := c .SelfParticipant .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chatParticipantsForbidden#8763d3e1: field self_participant: %w" , err )
}
}
return nil
}
func (c *ChatParticipantsForbidden ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatParticipantsForbidden#8763d3e1 to nil" )
}
if err := b .ConsumeID (ChatParticipantsForbiddenTypeID ); err != nil {
return fmt .Errorf ("unable to decode chatParticipantsForbidden#8763d3e1: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChatParticipantsForbidden ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatParticipantsForbidden#8763d3e1 to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode chatParticipantsForbidden#8763d3e1: field flags: %w" , err )
}
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode chatParticipantsForbidden#8763d3e1: field chat_id: %w" , err )
}
c .ChatID = value
}
if c .Flags .Has (0 ) {
value , err := DecodeChatParticipant (b )
if err != nil {
return fmt .Errorf ("unable to decode chatParticipantsForbidden#8763d3e1: field self_participant: %w" , err )
}
c .SelfParticipant = value
}
return nil
}
func (c *ChatParticipantsForbidden ) GetChatID () (value int64 ) {
if c == nil {
return
}
return c .ChatID
}
func (c *ChatParticipantsForbidden ) SetSelfParticipant (value ChatParticipantClass ) {
c .Flags .Set (0 )
c .SelfParticipant = value
}
func (c *ChatParticipantsForbidden ) GetSelfParticipant () (value ChatParticipantClass , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (0 ) {
return value , false
}
return c .SelfParticipant , true
}
type ChatParticipants struct {
ChatID int64
Participants []ChatParticipantClass
Version int
}
const ChatParticipantsTypeID = 0x3cbc93f8
func (c ChatParticipants ) construct () ChatParticipantsClass { return &c }
var (
_ bin .Encoder = &ChatParticipants {}
_ bin .Decoder = &ChatParticipants {}
_ bin .BareEncoder = &ChatParticipants {}
_ bin .BareDecoder = &ChatParticipants {}
_ ChatParticipantsClass = &ChatParticipants {}
)
func (c *ChatParticipants ) Zero () bool {
if c == nil {
return true
}
if !(c .ChatID == 0 ) {
return false
}
if !(c .Participants == nil ) {
return false
}
if !(c .Version == 0 ) {
return false
}
return true
}
func (c *ChatParticipants ) String () string {
if c == nil {
return "ChatParticipants(nil)"
}
type Alias ChatParticipants
return fmt .Sprintf ("ChatParticipants%+v" , Alias (*c ))
}
func (c *ChatParticipants ) FillFrom (from interface {
GetChatID () (value int64 )
GetParticipants () (value []ChatParticipantClass )
GetVersion () (value int )
}) {
c .ChatID = from .GetChatID ()
c .Participants = from .GetParticipants ()
c .Version = from .GetVersion ()
}
func (*ChatParticipants ) TypeID () uint32 {
return ChatParticipantsTypeID
}
func (*ChatParticipants ) TypeName () string {
return "chatParticipants"
}
func (c *ChatParticipants ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chatParticipants" ,
ID : ChatParticipantsTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ChatID" ,
SchemaName : "chat_id" ,
},
{
Name : "Participants" ,
SchemaName : "participants" ,
},
{
Name : "Version" ,
SchemaName : "version" ,
},
}
return typ
}
func (c *ChatParticipants ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatParticipants#3cbc93f8 as nil" )
}
b .PutID (ChatParticipantsTypeID )
return c .EncodeBare (b )
}
func (c *ChatParticipants ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatParticipants#3cbc93f8 as nil" )
}
b .PutLong (c .ChatID )
b .PutVectorHeader (len (c .Participants ))
for idx , v := range c .Participants {
if v == nil {
return fmt .Errorf ("unable to encode chatParticipants#3cbc93f8: field participants element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chatParticipants#3cbc93f8: field participants element with index %d: %w" , idx , err )
}
}
b .PutInt (c .Version )
return nil
}
func (c *ChatParticipants ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatParticipants#3cbc93f8 to nil" )
}
if err := b .ConsumeID (ChatParticipantsTypeID ); err != nil {
return fmt .Errorf ("unable to decode chatParticipants#3cbc93f8: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChatParticipants ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatParticipants#3cbc93f8 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode chatParticipants#3cbc93f8: field chat_id: %w" , err )
}
c .ChatID = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode chatParticipants#3cbc93f8: field participants: %w" , err )
}
if headerLen > 0 {
c .Participants = make ([]ChatParticipantClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeChatParticipant (b )
if err != nil {
return fmt .Errorf ("unable to decode chatParticipants#3cbc93f8: field participants: %w" , err )
}
c .Participants = append (c .Participants , value )
}
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode chatParticipants#3cbc93f8: field version: %w" , err )
}
c .Version = value
}
return nil
}
func (c *ChatParticipants ) GetChatID () (value int64 ) {
if c == nil {
return
}
return c .ChatID
}
func (c *ChatParticipants ) GetParticipants () (value []ChatParticipantClass ) {
if c == nil {
return
}
return c .Participants
}
func (c *ChatParticipants ) GetVersion () (value int ) {
if c == nil {
return
}
return c .Version
}
func (c *ChatParticipants ) MapParticipants () (value ChatParticipantClassArray ) {
return ChatParticipantClassArray (c .Participants )
}
const ChatParticipantsClassName = "ChatParticipants"
type ChatParticipantsClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () ChatParticipantsClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetChatID () (value int64 )
AsNotForbidden () (*ChatParticipants , bool )
}
func (c *ChatParticipantsForbidden ) AsNotForbidden () (*ChatParticipants , bool ) {
return nil , false
}
func (c *ChatParticipants ) AsNotForbidden () (*ChatParticipants , bool ) {
return c , true
}
func DecodeChatParticipants (buf *bin .Buffer ) (ChatParticipantsClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case ChatParticipantsForbiddenTypeID :
v := ChatParticipantsForbidden {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ChatParticipantsClass: %w" , err )
}
return &v , nil
case ChatParticipantsTypeID :
v := ChatParticipants {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ChatParticipantsClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode ChatParticipantsClass: %w" , bin .NewUnexpectedID (id ))
}
}
type ChatParticipantsBox struct {
ChatParticipants ChatParticipantsClass
}
func (b *ChatParticipantsBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode ChatParticipantsBox to nil" )
}
v , err := DecodeChatParticipants (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .ChatParticipants = v
return nil
}
func (b *ChatParticipantsBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .ChatParticipants == nil {
return fmt .Errorf ("unable to encode ChatParticipantsClass as nil" )
}
return b .ChatParticipants .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 .