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 ChatInviteAlready struct {
Chat ChatClass
}
const ChatInviteAlreadyTypeID = 0x5a686d7c
func (c ChatInviteAlready ) construct () ChatInviteClass { return &c }
var (
_ bin .Encoder = &ChatInviteAlready {}
_ bin .Decoder = &ChatInviteAlready {}
_ bin .BareEncoder = &ChatInviteAlready {}
_ bin .BareDecoder = &ChatInviteAlready {}
_ ChatInviteClass = &ChatInviteAlready {}
)
func (c *ChatInviteAlready ) Zero () bool {
if c == nil {
return true
}
if !(c .Chat == nil ) {
return false
}
return true
}
func (c *ChatInviteAlready ) String () string {
if c == nil {
return "ChatInviteAlready(nil)"
}
type Alias ChatInviteAlready
return fmt .Sprintf ("ChatInviteAlready%+v" , Alias (*c ))
}
func (c *ChatInviteAlready ) FillFrom (from interface {
GetChat () (value ChatClass )
}) {
c .Chat = from .GetChat ()
}
func (*ChatInviteAlready ) TypeID () uint32 {
return ChatInviteAlreadyTypeID
}
func (*ChatInviteAlready ) TypeName () string {
return "chatInviteAlready"
}
func (c *ChatInviteAlready ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chatInviteAlready" ,
ID : ChatInviteAlreadyTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Chat" ,
SchemaName : "chat" ,
},
}
return typ
}
func (c *ChatInviteAlready ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatInviteAlready#5a686d7c as nil" )
}
b .PutID (ChatInviteAlreadyTypeID )
return c .EncodeBare (b )
}
func (c *ChatInviteAlready ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatInviteAlready#5a686d7c as nil" )
}
if c .Chat == nil {
return fmt .Errorf ("unable to encode chatInviteAlready#5a686d7c: field chat is nil" )
}
if err := c .Chat .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chatInviteAlready#5a686d7c: field chat: %w" , err )
}
return nil
}
func (c *ChatInviteAlready ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatInviteAlready#5a686d7c to nil" )
}
if err := b .ConsumeID (ChatInviteAlreadyTypeID ); err != nil {
return fmt .Errorf ("unable to decode chatInviteAlready#5a686d7c: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChatInviteAlready ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatInviteAlready#5a686d7c to nil" )
}
{
value , err := DecodeChat (b )
if err != nil {
return fmt .Errorf ("unable to decode chatInviteAlready#5a686d7c: field chat: %w" , err )
}
c .Chat = value
}
return nil
}
func (c *ChatInviteAlready ) GetChat () (value ChatClass ) {
if c == nil {
return
}
return c .Chat
}
type ChatInvite struct {
Flags bin .Fields
Channel bool
Broadcast bool
Public bool
Megagroup bool
RequestNeeded bool
Verified bool
Scam bool
Fake bool
Title string
About string
Photo PhotoClass
ParticipantsCount int
Participants []UserClass
Color int
}
const ChatInviteTypeID = 0xcde0ec40
func (c ChatInvite ) construct () ChatInviteClass { return &c }
var (
_ bin .Encoder = &ChatInvite {}
_ bin .Decoder = &ChatInvite {}
_ bin .BareEncoder = &ChatInvite {}
_ bin .BareDecoder = &ChatInvite {}
_ ChatInviteClass = &ChatInvite {}
)
func (c *ChatInvite ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .Channel == false ) {
return false
}
if !(c .Broadcast == false ) {
return false
}
if !(c .Public == false ) {
return false
}
if !(c .Megagroup == false ) {
return false
}
if !(c .RequestNeeded == false ) {
return false
}
if !(c .Verified == false ) {
return false
}
if !(c .Scam == false ) {
return false
}
if !(c .Fake == false ) {
return false
}
if !(c .Title == "" ) {
return false
}
if !(c .About == "" ) {
return false
}
if !(c .Photo == nil ) {
return false
}
if !(c .ParticipantsCount == 0 ) {
return false
}
if !(c .Participants == nil ) {
return false
}
if !(c .Color == 0 ) {
return false
}
return true
}
func (c *ChatInvite ) String () string {
if c == nil {
return "ChatInvite(nil)"
}
type Alias ChatInvite
return fmt .Sprintf ("ChatInvite%+v" , Alias (*c ))
}
func (c *ChatInvite ) FillFrom (from interface {
GetChannel () (value bool )
GetBroadcast () (value bool )
GetPublic () (value bool )
GetMegagroup () (value bool )
GetRequestNeeded () (value bool )
GetVerified () (value bool )
GetScam () (value bool )
GetFake () (value bool )
GetTitle () (value string )
GetAbout () (value string , ok bool )
GetPhoto () (value PhotoClass )
GetParticipantsCount () (value int )
GetParticipants () (value []UserClass , ok bool )
GetColor () (value int )
}) {
c .Channel = from .GetChannel ()
c .Broadcast = from .GetBroadcast ()
c .Public = from .GetPublic ()
c .Megagroup = from .GetMegagroup ()
c .RequestNeeded = from .GetRequestNeeded ()
c .Verified = from .GetVerified ()
c .Scam = from .GetScam ()
c .Fake = from .GetFake ()
c .Title = from .GetTitle ()
if val , ok := from .GetAbout (); ok {
c .About = val
}
c .Photo = from .GetPhoto ()
c .ParticipantsCount = from .GetParticipantsCount ()
if val , ok := from .GetParticipants (); ok {
c .Participants = val
}
c .Color = from .GetColor ()
}
func (*ChatInvite ) TypeID () uint32 {
return ChatInviteTypeID
}
func (*ChatInvite ) TypeName () string {
return "chatInvite"
}
func (c *ChatInvite ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chatInvite" ,
ID : ChatInviteTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Channel" ,
SchemaName : "channel" ,
Null : !c .Flags .Has (0 ),
},
{
Name : "Broadcast" ,
SchemaName : "broadcast" ,
Null : !c .Flags .Has (1 ),
},
{
Name : "Public" ,
SchemaName : "public" ,
Null : !c .Flags .Has (2 ),
},
{
Name : "Megagroup" ,
SchemaName : "megagroup" ,
Null : !c .Flags .Has (3 ),
},
{
Name : "RequestNeeded" ,
SchemaName : "request_needed" ,
Null : !c .Flags .Has (6 ),
},
{
Name : "Verified" ,
SchemaName : "verified" ,
Null : !c .Flags .Has (7 ),
},
{
Name : "Scam" ,
SchemaName : "scam" ,
Null : !c .Flags .Has (8 ),
},
{
Name : "Fake" ,
SchemaName : "fake" ,
Null : !c .Flags .Has (9 ),
},
{
Name : "Title" ,
SchemaName : "title" ,
},
{
Name : "About" ,
SchemaName : "about" ,
Null : !c .Flags .Has (5 ),
},
{
Name : "Photo" ,
SchemaName : "photo" ,
},
{
Name : "ParticipantsCount" ,
SchemaName : "participants_count" ,
},
{
Name : "Participants" ,
SchemaName : "participants" ,
Null : !c .Flags .Has (4 ),
},
{
Name : "Color" ,
SchemaName : "color" ,
},
}
return typ
}
func (c *ChatInvite ) SetFlags () {
if !(c .Channel == false ) {
c .Flags .Set (0 )
}
if !(c .Broadcast == false ) {
c .Flags .Set (1 )
}
if !(c .Public == false ) {
c .Flags .Set (2 )
}
if !(c .Megagroup == false ) {
c .Flags .Set (3 )
}
if !(c .RequestNeeded == false ) {
c .Flags .Set (6 )
}
if !(c .Verified == false ) {
c .Flags .Set (7 )
}
if !(c .Scam == false ) {
c .Flags .Set (8 )
}
if !(c .Fake == false ) {
c .Flags .Set (9 )
}
if !(c .About == "" ) {
c .Flags .Set (5 )
}
if !(c .Participants == nil ) {
c .Flags .Set (4 )
}
}
func (c *ChatInvite ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatInvite#cde0ec40 as nil" )
}
b .PutID (ChatInviteTypeID )
return c .EncodeBare (b )
}
func (c *ChatInvite ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatInvite#cde0ec40 as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chatInvite#cde0ec40: field flags: %w" , err )
}
b .PutString (c .Title )
if c .Flags .Has (5 ) {
b .PutString (c .About )
}
if c .Photo == nil {
return fmt .Errorf ("unable to encode chatInvite#cde0ec40: field photo is nil" )
}
if err := c .Photo .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chatInvite#cde0ec40: field photo: %w" , err )
}
b .PutInt (c .ParticipantsCount )
if c .Flags .Has (4 ) {
b .PutVectorHeader (len (c .Participants ))
for idx , v := range c .Participants {
if v == nil {
return fmt .Errorf ("unable to encode chatInvite#cde0ec40: field participants element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chatInvite#cde0ec40: field participants element with index %d: %w" , idx , err )
}
}
}
b .PutInt (c .Color )
return nil
}
func (c *ChatInvite ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatInvite#cde0ec40 to nil" )
}
if err := b .ConsumeID (ChatInviteTypeID ); err != nil {
return fmt .Errorf ("unable to decode chatInvite#cde0ec40: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChatInvite ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatInvite#cde0ec40 to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode chatInvite#cde0ec40: field flags: %w" , err )
}
}
c .Channel = c .Flags .Has (0 )
c .Broadcast = c .Flags .Has (1 )
c .Public = c .Flags .Has (2 )
c .Megagroup = c .Flags .Has (3 )
c .RequestNeeded = c .Flags .Has (6 )
c .Verified = c .Flags .Has (7 )
c .Scam = c .Flags .Has (8 )
c .Fake = c .Flags .Has (9 )
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode chatInvite#cde0ec40: field title: %w" , err )
}
c .Title = value
}
if c .Flags .Has (5 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode chatInvite#cde0ec40: field about: %w" , err )
}
c .About = value
}
{
value , err := DecodePhoto (b )
if err != nil {
return fmt .Errorf ("unable to decode chatInvite#cde0ec40: field photo: %w" , err )
}
c .Photo = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode chatInvite#cde0ec40: field participants_count: %w" , err )
}
c .ParticipantsCount = value
}
if c .Flags .Has (4 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode chatInvite#cde0ec40: field participants: %w" , err )
}
if headerLen > 0 {
c .Participants = 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 chatInvite#cde0ec40: field participants: %w" , err )
}
c .Participants = append (c .Participants , value )
}
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode chatInvite#cde0ec40: field color: %w" , err )
}
c .Color = value
}
return nil
}
func (c *ChatInvite ) SetChannel (value bool ) {
if value {
c .Flags .Set (0 )
c .Channel = true
} else {
c .Flags .Unset (0 )
c .Channel = false
}
}
func (c *ChatInvite ) GetChannel () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (0 )
}
func (c *ChatInvite ) SetBroadcast (value bool ) {
if value {
c .Flags .Set (1 )
c .Broadcast = true
} else {
c .Flags .Unset (1 )
c .Broadcast = false
}
}
func (c *ChatInvite ) GetBroadcast () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (1 )
}
func (c *ChatInvite ) SetPublic (value bool ) {
if value {
c .Flags .Set (2 )
c .Public = true
} else {
c .Flags .Unset (2 )
c .Public = false
}
}
func (c *ChatInvite ) GetPublic () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (2 )
}
func (c *ChatInvite ) SetMegagroup (value bool ) {
if value {
c .Flags .Set (3 )
c .Megagroup = true
} else {
c .Flags .Unset (3 )
c .Megagroup = false
}
}
func (c *ChatInvite ) GetMegagroup () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (3 )
}
func (c *ChatInvite ) SetRequestNeeded (value bool ) {
if value {
c .Flags .Set (6 )
c .RequestNeeded = true
} else {
c .Flags .Unset (6 )
c .RequestNeeded = false
}
}
func (c *ChatInvite ) GetRequestNeeded () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (6 )
}
func (c *ChatInvite ) SetVerified (value bool ) {
if value {
c .Flags .Set (7 )
c .Verified = true
} else {
c .Flags .Unset (7 )
c .Verified = false
}
}
func (c *ChatInvite ) GetVerified () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (7 )
}
func (c *ChatInvite ) SetScam (value bool ) {
if value {
c .Flags .Set (8 )
c .Scam = true
} else {
c .Flags .Unset (8 )
c .Scam = false
}
}
func (c *ChatInvite ) GetScam () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (8 )
}
func (c *ChatInvite ) SetFake (value bool ) {
if value {
c .Flags .Set (9 )
c .Fake = true
} else {
c .Flags .Unset (9 )
c .Fake = false
}
}
func (c *ChatInvite ) GetFake () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (9 )
}
func (c *ChatInvite ) GetTitle () (value string ) {
if c == nil {
return
}
return c .Title
}
func (c *ChatInvite ) SetAbout (value string ) {
c .Flags .Set (5 )
c .About = value
}
func (c *ChatInvite ) GetAbout () (value string , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (5 ) {
return value , false
}
return c .About , true
}
func (c *ChatInvite ) GetPhoto () (value PhotoClass ) {
if c == nil {
return
}
return c .Photo
}
func (c *ChatInvite ) GetParticipantsCount () (value int ) {
if c == nil {
return
}
return c .ParticipantsCount
}
func (c *ChatInvite ) SetParticipants (value []UserClass ) {
c .Flags .Set (4 )
c .Participants = value
}
func (c *ChatInvite ) GetParticipants () (value []UserClass , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (4 ) {
return value , false
}
return c .Participants , true
}
func (c *ChatInvite ) GetColor () (value int ) {
if c == nil {
return
}
return c .Color
}
func (c *ChatInvite ) MapParticipants () (value UserClassArray , ok bool ) {
if !c .Flags .Has (4 ) {
return value , false
}
return UserClassArray (c .Participants ), true
}
type ChatInvitePeek struct {
Chat ChatClass
Expires int
}
const ChatInvitePeekTypeID = 0x61695cb0
func (c ChatInvitePeek ) construct () ChatInviteClass { return &c }
var (
_ bin .Encoder = &ChatInvitePeek {}
_ bin .Decoder = &ChatInvitePeek {}
_ bin .BareEncoder = &ChatInvitePeek {}
_ bin .BareDecoder = &ChatInvitePeek {}
_ ChatInviteClass = &ChatInvitePeek {}
)
func (c *ChatInvitePeek ) Zero () bool {
if c == nil {
return true
}
if !(c .Chat == nil ) {
return false
}
if !(c .Expires == 0 ) {
return false
}
return true
}
func (c *ChatInvitePeek ) String () string {
if c == nil {
return "ChatInvitePeek(nil)"
}
type Alias ChatInvitePeek
return fmt .Sprintf ("ChatInvitePeek%+v" , Alias (*c ))
}
func (c *ChatInvitePeek ) FillFrom (from interface {
GetChat () (value ChatClass )
GetExpires () (value int )
}) {
c .Chat = from .GetChat ()
c .Expires = from .GetExpires ()
}
func (*ChatInvitePeek ) TypeID () uint32 {
return ChatInvitePeekTypeID
}
func (*ChatInvitePeek ) TypeName () string {
return "chatInvitePeek"
}
func (c *ChatInvitePeek ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chatInvitePeek" ,
ID : ChatInvitePeekTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Chat" ,
SchemaName : "chat" ,
},
{
Name : "Expires" ,
SchemaName : "expires" ,
},
}
return typ
}
func (c *ChatInvitePeek ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatInvitePeek#61695cb0 as nil" )
}
b .PutID (ChatInvitePeekTypeID )
return c .EncodeBare (b )
}
func (c *ChatInvitePeek ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatInvitePeek#61695cb0 as nil" )
}
if c .Chat == nil {
return fmt .Errorf ("unable to encode chatInvitePeek#61695cb0: field chat is nil" )
}
if err := c .Chat .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chatInvitePeek#61695cb0: field chat: %w" , err )
}
b .PutInt (c .Expires )
return nil
}
func (c *ChatInvitePeek ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatInvitePeek#61695cb0 to nil" )
}
if err := b .ConsumeID (ChatInvitePeekTypeID ); err != nil {
return fmt .Errorf ("unable to decode chatInvitePeek#61695cb0: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChatInvitePeek ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatInvitePeek#61695cb0 to nil" )
}
{
value , err := DecodeChat (b )
if err != nil {
return fmt .Errorf ("unable to decode chatInvitePeek#61695cb0: field chat: %w" , err )
}
c .Chat = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode chatInvitePeek#61695cb0: field expires: %w" , err )
}
c .Expires = value
}
return nil
}
func (c *ChatInvitePeek ) GetChat () (value ChatClass ) {
if c == nil {
return
}
return c .Chat
}
func (c *ChatInvitePeek ) GetExpires () (value int ) {
if c == nil {
return
}
return c .Expires
}
const ChatInviteClassName = "ChatInvite"
type ChatInviteClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () ChatInviteClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeChatInvite (buf *bin .Buffer ) (ChatInviteClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case ChatInviteAlreadyTypeID :
v := ChatInviteAlready {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ChatInviteClass: %w" , err )
}
return &v , nil
case ChatInviteTypeID :
v := ChatInvite {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ChatInviteClass: %w" , err )
}
return &v , nil
case ChatInvitePeekTypeID :
v := ChatInvitePeek {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ChatInviteClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode ChatInviteClass: %w" , bin .NewUnexpectedID (id ))
}
}
type ChatInviteBox struct {
ChatInvite ChatInviteClass
}
func (b *ChatInviteBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode ChatInviteBox to nil" )
}
v , err := DecodeChatInvite (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .ChatInvite = v
return nil
}
func (b *ChatInviteBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .ChatInvite == nil {
return fmt .Errorf ("unable to encode ChatInviteClass as nil" )
}
return b .ChatInvite .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 .