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 MessagesExportChatInviteRequest struct {
Flags bin .Fields
LegacyRevokePermanent bool
RequestNeeded bool
Peer InputPeerClass
ExpireDate int
UsageLimit int
Title string
}
const MessagesExportChatInviteRequestTypeID = 0xa02ce5d5
var (
_ bin .Encoder = &MessagesExportChatInviteRequest {}
_ bin .Decoder = &MessagesExportChatInviteRequest {}
_ bin .BareEncoder = &MessagesExportChatInviteRequest {}
_ bin .BareDecoder = &MessagesExportChatInviteRequest {}
)
func (e *MessagesExportChatInviteRequest ) Zero () bool {
if e == nil {
return true
}
if !(e .Flags .Zero ()) {
return false
}
if !(e .LegacyRevokePermanent == false ) {
return false
}
if !(e .RequestNeeded == false ) {
return false
}
if !(e .Peer == nil ) {
return false
}
if !(e .ExpireDate == 0 ) {
return false
}
if !(e .UsageLimit == 0 ) {
return false
}
if !(e .Title == "" ) {
return false
}
return true
}
func (e *MessagesExportChatInviteRequest ) String () string {
if e == nil {
return "MessagesExportChatInviteRequest(nil)"
}
type Alias MessagesExportChatInviteRequest
return fmt .Sprintf ("MessagesExportChatInviteRequest%+v" , Alias (*e ))
}
func (e *MessagesExportChatInviteRequest ) FillFrom (from interface {
GetLegacyRevokePermanent () (value bool )
GetRequestNeeded () (value bool )
GetPeer () (value InputPeerClass )
GetExpireDate () (value int , ok bool )
GetUsageLimit () (value int , ok bool )
GetTitle () (value string , ok bool )
}) {
e .LegacyRevokePermanent = from .GetLegacyRevokePermanent ()
e .RequestNeeded = from .GetRequestNeeded ()
e .Peer = from .GetPeer ()
if val , ok := from .GetExpireDate (); ok {
e .ExpireDate = val
}
if val , ok := from .GetUsageLimit (); ok {
e .UsageLimit = val
}
if val , ok := from .GetTitle (); ok {
e .Title = val
}
}
func (*MessagesExportChatInviteRequest ) TypeID () uint32 {
return MessagesExportChatInviteRequestTypeID
}
func (*MessagesExportChatInviteRequest ) TypeName () string {
return "messages.exportChatInvite"
}
func (e *MessagesExportChatInviteRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.exportChatInvite" ,
ID : MessagesExportChatInviteRequestTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "LegacyRevokePermanent" ,
SchemaName : "legacy_revoke_permanent" ,
Null : !e .Flags .Has (2 ),
},
{
Name : "RequestNeeded" ,
SchemaName : "request_needed" ,
Null : !e .Flags .Has (3 ),
},
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "ExpireDate" ,
SchemaName : "expire_date" ,
Null : !e .Flags .Has (0 ),
},
{
Name : "UsageLimit" ,
SchemaName : "usage_limit" ,
Null : !e .Flags .Has (1 ),
},
{
Name : "Title" ,
SchemaName : "title" ,
Null : !e .Flags .Has (4 ),
},
}
return typ
}
func (e *MessagesExportChatInviteRequest ) SetFlags () {
if !(e .LegacyRevokePermanent == false ) {
e .Flags .Set (2 )
}
if !(e .RequestNeeded == false ) {
e .Flags .Set (3 )
}
if !(e .ExpireDate == 0 ) {
e .Flags .Set (0 )
}
if !(e .UsageLimit == 0 ) {
e .Flags .Set (1 )
}
if !(e .Title == "" ) {
e .Flags .Set (4 )
}
}
func (e *MessagesExportChatInviteRequest ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode messages.exportChatInvite#a02ce5d5 as nil" )
}
b .PutID (MessagesExportChatInviteRequestTypeID )
return e .EncodeBare (b )
}
func (e *MessagesExportChatInviteRequest ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode messages.exportChatInvite#a02ce5d5 as nil" )
}
e .SetFlags ()
if err := e .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.exportChatInvite#a02ce5d5: field flags: %w" , err )
}
if e .Peer == nil {
return fmt .Errorf ("unable to encode messages.exportChatInvite#a02ce5d5: field peer is nil" )
}
if err := e .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.exportChatInvite#a02ce5d5: field peer: %w" , err )
}
if e .Flags .Has (0 ) {
b .PutInt (e .ExpireDate )
}
if e .Flags .Has (1 ) {
b .PutInt (e .UsageLimit )
}
if e .Flags .Has (4 ) {
b .PutString (e .Title )
}
return nil
}
func (e *MessagesExportChatInviteRequest ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode messages.exportChatInvite#a02ce5d5 to nil" )
}
if err := b .ConsumeID (MessagesExportChatInviteRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.exportChatInvite#a02ce5d5: %w" , err )
}
return e .DecodeBare (b )
}
func (e *MessagesExportChatInviteRequest ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode messages.exportChatInvite#a02ce5d5 to nil" )
}
{
if err := e .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.exportChatInvite#a02ce5d5: field flags: %w" , err )
}
}
e .LegacyRevokePermanent = e .Flags .Has (2 )
e .RequestNeeded = e .Flags .Has (3 )
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.exportChatInvite#a02ce5d5: field peer: %w" , err )
}
e .Peer = value
}
if e .Flags .Has (0 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.exportChatInvite#a02ce5d5: field expire_date: %w" , err )
}
e .ExpireDate = value
}
if e .Flags .Has (1 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.exportChatInvite#a02ce5d5: field usage_limit: %w" , err )
}
e .UsageLimit = value
}
if e .Flags .Has (4 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode messages.exportChatInvite#a02ce5d5: field title: %w" , err )
}
e .Title = value
}
return nil
}
func (e *MessagesExportChatInviteRequest ) SetLegacyRevokePermanent (value bool ) {
if value {
e .Flags .Set (2 )
e .LegacyRevokePermanent = true
} else {
e .Flags .Unset (2 )
e .LegacyRevokePermanent = false
}
}
func (e *MessagesExportChatInviteRequest ) GetLegacyRevokePermanent () (value bool ) {
if e == nil {
return
}
return e .Flags .Has (2 )
}
func (e *MessagesExportChatInviteRequest ) SetRequestNeeded (value bool ) {
if value {
e .Flags .Set (3 )
e .RequestNeeded = true
} else {
e .Flags .Unset (3 )
e .RequestNeeded = false
}
}
func (e *MessagesExportChatInviteRequest ) GetRequestNeeded () (value bool ) {
if e == nil {
return
}
return e .Flags .Has (3 )
}
func (e *MessagesExportChatInviteRequest ) GetPeer () (value InputPeerClass ) {
if e == nil {
return
}
return e .Peer
}
func (e *MessagesExportChatInviteRequest ) SetExpireDate (value int ) {
e .Flags .Set (0 )
e .ExpireDate = value
}
func (e *MessagesExportChatInviteRequest ) GetExpireDate () (value int , ok bool ) {
if e == nil {
return
}
if !e .Flags .Has (0 ) {
return value , false
}
return e .ExpireDate , true
}
func (e *MessagesExportChatInviteRequest ) SetUsageLimit (value int ) {
e .Flags .Set (1 )
e .UsageLimit = value
}
func (e *MessagesExportChatInviteRequest ) GetUsageLimit () (value int , ok bool ) {
if e == nil {
return
}
if !e .Flags .Has (1 ) {
return value , false
}
return e .UsageLimit , true
}
func (e *MessagesExportChatInviteRequest ) SetTitle (value string ) {
e .Flags .Set (4 )
e .Title = value
}
func (e *MessagesExportChatInviteRequest ) GetTitle () (value string , ok bool ) {
if e == nil {
return
}
if !e .Flags .Has (4 ) {
return value , false
}
return e .Title , true
}
func (c *Client ) MessagesExportChatInvite (ctx context .Context , request *MessagesExportChatInviteRequest ) (ExportedChatInviteClass , error ) {
var result ExportedChatInviteBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .ExportedChatInvite , nil
}
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 .