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 ChatInviteExported struct {
Flags bin .Fields
Revoked bool
Permanent bool
RequestNeeded bool
Link string
AdminID int64
Date int
StartDate int
ExpireDate int
UsageLimit int
Usage int
Requested int
SubscriptionExpired int
Title string
SubscriptionPricing StarsSubscriptionPricing
}
const ChatInviteExportedTypeID = 0xa22cbd96
func (c ChatInviteExported ) construct () ExportedChatInviteClass { return &c }
var (
_ bin .Encoder = &ChatInviteExported {}
_ bin .Decoder = &ChatInviteExported {}
_ bin .BareEncoder = &ChatInviteExported {}
_ bin .BareDecoder = &ChatInviteExported {}
_ ExportedChatInviteClass = &ChatInviteExported {}
)
func (c *ChatInviteExported ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .Revoked == false ) {
return false
}
if !(c .Permanent == false ) {
return false
}
if !(c .RequestNeeded == false ) {
return false
}
if !(c .Link == "" ) {
return false
}
if !(c .AdminID == 0 ) {
return false
}
if !(c .Date == 0 ) {
return false
}
if !(c .StartDate == 0 ) {
return false
}
if !(c .ExpireDate == 0 ) {
return false
}
if !(c .UsageLimit == 0 ) {
return false
}
if !(c .Usage == 0 ) {
return false
}
if !(c .Requested == 0 ) {
return false
}
if !(c .SubscriptionExpired == 0 ) {
return false
}
if !(c .Title == "" ) {
return false
}
if !(c .SubscriptionPricing .Zero ()) {
return false
}
return true
}
func (c *ChatInviteExported ) String () string {
if c == nil {
return "ChatInviteExported(nil)"
}
type Alias ChatInviteExported
return fmt .Sprintf ("ChatInviteExported%+v" , Alias (*c ))
}
func (c *ChatInviteExported ) FillFrom (from interface {
GetRevoked () (value bool )
GetPermanent () (value bool )
GetRequestNeeded () (value bool )
GetLink () (value string )
GetAdminID () (value int64 )
GetDate () (value int )
GetStartDate () (value int , ok bool )
GetExpireDate () (value int , ok bool )
GetUsageLimit () (value int , ok bool )
GetUsage () (value int , ok bool )
GetRequested () (value int , ok bool )
GetSubscriptionExpired () (value int , ok bool )
GetTitle () (value string , ok bool )
GetSubscriptionPricing () (value StarsSubscriptionPricing , ok bool )
}) {
c .Revoked = from .GetRevoked ()
c .Permanent = from .GetPermanent ()
c .RequestNeeded = from .GetRequestNeeded ()
c .Link = from .GetLink ()
c .AdminID = from .GetAdminID ()
c .Date = from .GetDate ()
if val , ok := from .GetStartDate (); ok {
c .StartDate = val
}
if val , ok := from .GetExpireDate (); ok {
c .ExpireDate = val
}
if val , ok := from .GetUsageLimit (); ok {
c .UsageLimit = val
}
if val , ok := from .GetUsage (); ok {
c .Usage = val
}
if val , ok := from .GetRequested (); ok {
c .Requested = val
}
if val , ok := from .GetSubscriptionExpired (); ok {
c .SubscriptionExpired = val
}
if val , ok := from .GetTitle (); ok {
c .Title = val
}
if val , ok := from .GetSubscriptionPricing (); ok {
c .SubscriptionPricing = val
}
}
func (*ChatInviteExported ) TypeID () uint32 {
return ChatInviteExportedTypeID
}
func (*ChatInviteExported ) TypeName () string {
return "chatInviteExported"
}
func (c *ChatInviteExported ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chatInviteExported" ,
ID : ChatInviteExportedTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Revoked" ,
SchemaName : "revoked" ,
Null : !c .Flags .Has (0 ),
},
{
Name : "Permanent" ,
SchemaName : "permanent" ,
Null : !c .Flags .Has (5 ),
},
{
Name : "RequestNeeded" ,
SchemaName : "request_needed" ,
Null : !c .Flags .Has (6 ),
},
{
Name : "Link" ,
SchemaName : "link" ,
},
{
Name : "AdminID" ,
SchemaName : "admin_id" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
{
Name : "StartDate" ,
SchemaName : "start_date" ,
Null : !c .Flags .Has (4 ),
},
{
Name : "ExpireDate" ,
SchemaName : "expire_date" ,
Null : !c .Flags .Has (1 ),
},
{
Name : "UsageLimit" ,
SchemaName : "usage_limit" ,
Null : !c .Flags .Has (2 ),
},
{
Name : "Usage" ,
SchemaName : "usage" ,
Null : !c .Flags .Has (3 ),
},
{
Name : "Requested" ,
SchemaName : "requested" ,
Null : !c .Flags .Has (7 ),
},
{
Name : "SubscriptionExpired" ,
SchemaName : "subscription_expired" ,
Null : !c .Flags .Has (10 ),
},
{
Name : "Title" ,
SchemaName : "title" ,
Null : !c .Flags .Has (8 ),
},
{
Name : "SubscriptionPricing" ,
SchemaName : "subscription_pricing" ,
Null : !c .Flags .Has (9 ),
},
}
return typ
}
func (c *ChatInviteExported ) SetFlags () {
if !(c .Revoked == false ) {
c .Flags .Set (0 )
}
if !(c .Permanent == false ) {
c .Flags .Set (5 )
}
if !(c .RequestNeeded == false ) {
c .Flags .Set (6 )
}
if !(c .StartDate == 0 ) {
c .Flags .Set (4 )
}
if !(c .ExpireDate == 0 ) {
c .Flags .Set (1 )
}
if !(c .UsageLimit == 0 ) {
c .Flags .Set (2 )
}
if !(c .Usage == 0 ) {
c .Flags .Set (3 )
}
if !(c .Requested == 0 ) {
c .Flags .Set (7 )
}
if !(c .SubscriptionExpired == 0 ) {
c .Flags .Set (10 )
}
if !(c .Title == "" ) {
c .Flags .Set (8 )
}
if !(c .SubscriptionPricing .Zero ()) {
c .Flags .Set (9 )
}
}
func (c *ChatInviteExported ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatInviteExported#a22cbd96 as nil" )
}
b .PutID (ChatInviteExportedTypeID )
return c .EncodeBare (b )
}
func (c *ChatInviteExported ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatInviteExported#a22cbd96 as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chatInviteExported#a22cbd96: field flags: %w" , err )
}
b .PutString (c .Link )
b .PutLong (c .AdminID )
b .PutInt (c .Date )
if c .Flags .Has (4 ) {
b .PutInt (c .StartDate )
}
if c .Flags .Has (1 ) {
b .PutInt (c .ExpireDate )
}
if c .Flags .Has (2 ) {
b .PutInt (c .UsageLimit )
}
if c .Flags .Has (3 ) {
b .PutInt (c .Usage )
}
if c .Flags .Has (7 ) {
b .PutInt (c .Requested )
}
if c .Flags .Has (10 ) {
b .PutInt (c .SubscriptionExpired )
}
if c .Flags .Has (8 ) {
b .PutString (c .Title )
}
if c .Flags .Has (9 ) {
if err := c .SubscriptionPricing .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chatInviteExported#a22cbd96: field subscription_pricing: %w" , err )
}
}
return nil
}
func (c *ChatInviteExported ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatInviteExported#a22cbd96 to nil" )
}
if err := b .ConsumeID (ChatInviteExportedTypeID ); err != nil {
return fmt .Errorf ("unable to decode chatInviteExported#a22cbd96: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChatInviteExported ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatInviteExported#a22cbd96 to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode chatInviteExported#a22cbd96: field flags: %w" , err )
}
}
c .Revoked = c .Flags .Has (0 )
c .Permanent = c .Flags .Has (5 )
c .RequestNeeded = c .Flags .Has (6 )
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode chatInviteExported#a22cbd96: field link: %w" , err )
}
c .Link = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode chatInviteExported#a22cbd96: field admin_id: %w" , err )
}
c .AdminID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode chatInviteExported#a22cbd96: field date: %w" , err )
}
c .Date = value
}
if c .Flags .Has (4 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode chatInviteExported#a22cbd96: field start_date: %w" , err )
}
c .StartDate = value
}
if c .Flags .Has (1 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode chatInviteExported#a22cbd96: field expire_date: %w" , err )
}
c .ExpireDate = value
}
if c .Flags .Has (2 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode chatInviteExported#a22cbd96: field usage_limit: %w" , err )
}
c .UsageLimit = value
}
if c .Flags .Has (3 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode chatInviteExported#a22cbd96: field usage: %w" , err )
}
c .Usage = value
}
if c .Flags .Has (7 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode chatInviteExported#a22cbd96: field requested: %w" , err )
}
c .Requested = value
}
if c .Flags .Has (10 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode chatInviteExported#a22cbd96: field subscription_expired: %w" , err )
}
c .SubscriptionExpired = value
}
if c .Flags .Has (8 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode chatInviteExported#a22cbd96: field title: %w" , err )
}
c .Title = value
}
if c .Flags .Has (9 ) {
if err := c .SubscriptionPricing .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode chatInviteExported#a22cbd96: field subscription_pricing: %w" , err )
}
}
return nil
}
func (c *ChatInviteExported ) SetRevoked (value bool ) {
if value {
c .Flags .Set (0 )
c .Revoked = true
} else {
c .Flags .Unset (0 )
c .Revoked = false
}
}
func (c *ChatInviteExported ) GetRevoked () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (0 )
}
func (c *ChatInviteExported ) SetPermanent (value bool ) {
if value {
c .Flags .Set (5 )
c .Permanent = true
} else {
c .Flags .Unset (5 )
c .Permanent = false
}
}
func (c *ChatInviteExported ) GetPermanent () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (5 )
}
func (c *ChatInviteExported ) SetRequestNeeded (value bool ) {
if value {
c .Flags .Set (6 )
c .RequestNeeded = true
} else {
c .Flags .Unset (6 )
c .RequestNeeded = false
}
}
func (c *ChatInviteExported ) GetRequestNeeded () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (6 )
}
func (c *ChatInviteExported ) GetLink () (value string ) {
if c == nil {
return
}
return c .Link
}
func (c *ChatInviteExported ) GetAdminID () (value int64 ) {
if c == nil {
return
}
return c .AdminID
}
func (c *ChatInviteExported ) GetDate () (value int ) {
if c == nil {
return
}
return c .Date
}
func (c *ChatInviteExported ) SetStartDate (value int ) {
c .Flags .Set (4 )
c .StartDate = value
}
func (c *ChatInviteExported ) GetStartDate () (value int , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (4 ) {
return value , false
}
return c .StartDate , true
}
func (c *ChatInviteExported ) SetExpireDate (value int ) {
c .Flags .Set (1 )
c .ExpireDate = value
}
func (c *ChatInviteExported ) GetExpireDate () (value int , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (1 ) {
return value , false
}
return c .ExpireDate , true
}
func (c *ChatInviteExported ) SetUsageLimit (value int ) {
c .Flags .Set (2 )
c .UsageLimit = value
}
func (c *ChatInviteExported ) GetUsageLimit () (value int , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (2 ) {
return value , false
}
return c .UsageLimit , true
}
func (c *ChatInviteExported ) SetUsage (value int ) {
c .Flags .Set (3 )
c .Usage = value
}
func (c *ChatInviteExported ) GetUsage () (value int , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (3 ) {
return value , false
}
return c .Usage , true
}
func (c *ChatInviteExported ) SetRequested (value int ) {
c .Flags .Set (7 )
c .Requested = value
}
func (c *ChatInviteExported ) GetRequested () (value int , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (7 ) {
return value , false
}
return c .Requested , true
}
func (c *ChatInviteExported ) SetSubscriptionExpired (value int ) {
c .Flags .Set (10 )
c .SubscriptionExpired = value
}
func (c *ChatInviteExported ) GetSubscriptionExpired () (value int , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (10 ) {
return value , false
}
return c .SubscriptionExpired , true
}
func (c *ChatInviteExported ) SetTitle (value string ) {
c .Flags .Set (8 )
c .Title = value
}
func (c *ChatInviteExported ) GetTitle () (value string , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (8 ) {
return value , false
}
return c .Title , true
}
func (c *ChatInviteExported ) SetSubscriptionPricing (value StarsSubscriptionPricing ) {
c .Flags .Set (9 )
c .SubscriptionPricing = value
}
func (c *ChatInviteExported ) GetSubscriptionPricing () (value StarsSubscriptionPricing , ok bool ) {
if c == nil {
return
}
if !c .Flags .Has (9 ) {
return value , false
}
return c .SubscriptionPricing , true
}
type ChatInvitePublicJoinRequests struct {
}
const ChatInvitePublicJoinRequestsTypeID = 0xed107ab7
func (c ChatInvitePublicJoinRequests ) construct () ExportedChatInviteClass { return &c }
var (
_ bin .Encoder = &ChatInvitePublicJoinRequests {}
_ bin .Decoder = &ChatInvitePublicJoinRequests {}
_ bin .BareEncoder = &ChatInvitePublicJoinRequests {}
_ bin .BareDecoder = &ChatInvitePublicJoinRequests {}
_ ExportedChatInviteClass = &ChatInvitePublicJoinRequests {}
)
func (c *ChatInvitePublicJoinRequests ) Zero () bool {
if c == nil {
return true
}
return true
}
func (c *ChatInvitePublicJoinRequests ) String () string {
if c == nil {
return "ChatInvitePublicJoinRequests(nil)"
}
type Alias ChatInvitePublicJoinRequests
return fmt .Sprintf ("ChatInvitePublicJoinRequests%+v" , Alias (*c ))
}
func (*ChatInvitePublicJoinRequests ) TypeID () uint32 {
return ChatInvitePublicJoinRequestsTypeID
}
func (*ChatInvitePublicJoinRequests ) TypeName () string {
return "chatInvitePublicJoinRequests"
}
func (c *ChatInvitePublicJoinRequests ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chatInvitePublicJoinRequests" ,
ID : ChatInvitePublicJoinRequestsTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (c *ChatInvitePublicJoinRequests ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatInvitePublicJoinRequests#ed107ab7 as nil" )
}
b .PutID (ChatInvitePublicJoinRequestsTypeID )
return c .EncodeBare (b )
}
func (c *ChatInvitePublicJoinRequests ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatInvitePublicJoinRequests#ed107ab7 as nil" )
}
return nil
}
func (c *ChatInvitePublicJoinRequests ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatInvitePublicJoinRequests#ed107ab7 to nil" )
}
if err := b .ConsumeID (ChatInvitePublicJoinRequestsTypeID ); err != nil {
return fmt .Errorf ("unable to decode chatInvitePublicJoinRequests#ed107ab7: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChatInvitePublicJoinRequests ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatInvitePublicJoinRequests#ed107ab7 to nil" )
}
return nil
}
const ExportedChatInviteClassName = "ExportedChatInvite"
type ExportedChatInviteClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () ExportedChatInviteClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeExportedChatInvite (buf *bin .Buffer ) (ExportedChatInviteClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case ChatInviteExportedTypeID :
v := ChatInviteExported {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ExportedChatInviteClass: %w" , err )
}
return &v , nil
case ChatInvitePublicJoinRequestsTypeID :
v := ChatInvitePublicJoinRequests {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ExportedChatInviteClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode ExportedChatInviteClass: %w" , bin .NewUnexpectedID (id ))
}
}
type ExportedChatInviteBox struct {
ExportedChatInvite ExportedChatInviteClass
}
func (b *ExportedChatInviteBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode ExportedChatInviteBox to nil" )
}
v , err := DecodeExportedChatInvite (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .ExportedChatInvite = v
return nil
}
func (b *ExportedChatInviteBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .ExportedChatInvite == nil {
return fmt .Errorf ("unable to encode ExportedChatInviteClass as nil" )
}
return b .ExportedChatInvite .Encode (buf )
}
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 .