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 AccountInitTakeoutSessionRequest struct {
Flags bin .Fields
Contacts bool
MessageUsers bool
MessageChats bool
MessageMegagroups bool
MessageChannels bool
Files bool
FileMaxSize int64
}
const AccountInitTakeoutSessionRequestTypeID = 0x8ef3eab0
var (
_ bin .Encoder = &AccountInitTakeoutSessionRequest {}
_ bin .Decoder = &AccountInitTakeoutSessionRequest {}
_ bin .BareEncoder = &AccountInitTakeoutSessionRequest {}
_ bin .BareDecoder = &AccountInitTakeoutSessionRequest {}
)
func (i *AccountInitTakeoutSessionRequest ) Zero () bool {
if i == nil {
return true
}
if !(i .Flags .Zero ()) {
return false
}
if !(i .Contacts == false ) {
return false
}
if !(i .MessageUsers == false ) {
return false
}
if !(i .MessageChats == false ) {
return false
}
if !(i .MessageMegagroups == false ) {
return false
}
if !(i .MessageChannels == false ) {
return false
}
if !(i .Files == false ) {
return false
}
if !(i .FileMaxSize == 0 ) {
return false
}
return true
}
func (i *AccountInitTakeoutSessionRequest ) String () string {
if i == nil {
return "AccountInitTakeoutSessionRequest(nil)"
}
type Alias AccountInitTakeoutSessionRequest
return fmt .Sprintf ("AccountInitTakeoutSessionRequest%+v" , Alias (*i ))
}
func (i *AccountInitTakeoutSessionRequest ) FillFrom (from interface {
GetContacts () (value bool )
GetMessageUsers () (value bool )
GetMessageChats () (value bool )
GetMessageMegagroups () (value bool )
GetMessageChannels () (value bool )
GetFiles () (value bool )
GetFileMaxSize () (value int64 , ok bool )
}) {
i .Contacts = from .GetContacts ()
i .MessageUsers = from .GetMessageUsers ()
i .MessageChats = from .GetMessageChats ()
i .MessageMegagroups = from .GetMessageMegagroups ()
i .MessageChannels = from .GetMessageChannels ()
i .Files = from .GetFiles ()
if val , ok := from .GetFileMaxSize (); ok {
i .FileMaxSize = val
}
}
func (*AccountInitTakeoutSessionRequest ) TypeID () uint32 {
return AccountInitTakeoutSessionRequestTypeID
}
func (*AccountInitTakeoutSessionRequest ) TypeName () string {
return "account.initTakeoutSession"
}
func (i *AccountInitTakeoutSessionRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.initTakeoutSession" ,
ID : AccountInitTakeoutSessionRequestTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Contacts" ,
SchemaName : "contacts" ,
Null : !i .Flags .Has (0 ),
},
{
Name : "MessageUsers" ,
SchemaName : "message_users" ,
Null : !i .Flags .Has (1 ),
},
{
Name : "MessageChats" ,
SchemaName : "message_chats" ,
Null : !i .Flags .Has (2 ),
},
{
Name : "MessageMegagroups" ,
SchemaName : "message_megagroups" ,
Null : !i .Flags .Has (3 ),
},
{
Name : "MessageChannels" ,
SchemaName : "message_channels" ,
Null : !i .Flags .Has (4 ),
},
{
Name : "Files" ,
SchemaName : "files" ,
Null : !i .Flags .Has (5 ),
},
{
Name : "FileMaxSize" ,
SchemaName : "file_max_size" ,
Null : !i .Flags .Has (5 ),
},
}
return typ
}
func (i *AccountInitTakeoutSessionRequest ) SetFlags () {
if !(i .Contacts == false ) {
i .Flags .Set (0 )
}
if !(i .MessageUsers == false ) {
i .Flags .Set (1 )
}
if !(i .MessageChats == false ) {
i .Flags .Set (2 )
}
if !(i .MessageMegagroups == false ) {
i .Flags .Set (3 )
}
if !(i .MessageChannels == false ) {
i .Flags .Set (4 )
}
if !(i .Files == false ) {
i .Flags .Set (5 )
}
if !(i .FileMaxSize == 0 ) {
i .Flags .Set (5 )
}
}
func (i *AccountInitTakeoutSessionRequest ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode account.initTakeoutSession#8ef3eab0 as nil" )
}
b .PutID (AccountInitTakeoutSessionRequestTypeID )
return i .EncodeBare (b )
}
func (i *AccountInitTakeoutSessionRequest ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode account.initTakeoutSession#8ef3eab0 as nil" )
}
i .SetFlags ()
if err := i .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.initTakeoutSession#8ef3eab0: field flags: %w" , err )
}
if i .Flags .Has (5 ) {
b .PutLong (i .FileMaxSize )
}
return nil
}
func (i *AccountInitTakeoutSessionRequest ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode account.initTakeoutSession#8ef3eab0 to nil" )
}
if err := b .ConsumeID (AccountInitTakeoutSessionRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.initTakeoutSession#8ef3eab0: %w" , err )
}
return i .DecodeBare (b )
}
func (i *AccountInitTakeoutSessionRequest ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode account.initTakeoutSession#8ef3eab0 to nil" )
}
{
if err := i .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.initTakeoutSession#8ef3eab0: field flags: %w" , err )
}
}
i .Contacts = i .Flags .Has (0 )
i .MessageUsers = i .Flags .Has (1 )
i .MessageChats = i .Flags .Has (2 )
i .MessageMegagroups = i .Flags .Has (3 )
i .MessageChannels = i .Flags .Has (4 )
i .Files = i .Flags .Has (5 )
if i .Flags .Has (5 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode account.initTakeoutSession#8ef3eab0: field file_max_size: %w" , err )
}
i .FileMaxSize = value
}
return nil
}
func (i *AccountInitTakeoutSessionRequest ) SetContacts (value bool ) {
if value {
i .Flags .Set (0 )
i .Contacts = true
} else {
i .Flags .Unset (0 )
i .Contacts = false
}
}
func (i *AccountInitTakeoutSessionRequest ) GetContacts () (value bool ) {
if i == nil {
return
}
return i .Flags .Has (0 )
}
func (i *AccountInitTakeoutSessionRequest ) SetMessageUsers (value bool ) {
if value {
i .Flags .Set (1 )
i .MessageUsers = true
} else {
i .Flags .Unset (1 )
i .MessageUsers = false
}
}
func (i *AccountInitTakeoutSessionRequest ) GetMessageUsers () (value bool ) {
if i == nil {
return
}
return i .Flags .Has (1 )
}
func (i *AccountInitTakeoutSessionRequest ) SetMessageChats (value bool ) {
if value {
i .Flags .Set (2 )
i .MessageChats = true
} else {
i .Flags .Unset (2 )
i .MessageChats = false
}
}
func (i *AccountInitTakeoutSessionRequest ) GetMessageChats () (value bool ) {
if i == nil {
return
}
return i .Flags .Has (2 )
}
func (i *AccountInitTakeoutSessionRequest ) SetMessageMegagroups (value bool ) {
if value {
i .Flags .Set (3 )
i .MessageMegagroups = true
} else {
i .Flags .Unset (3 )
i .MessageMegagroups = false
}
}
func (i *AccountInitTakeoutSessionRequest ) GetMessageMegagroups () (value bool ) {
if i == nil {
return
}
return i .Flags .Has (3 )
}
func (i *AccountInitTakeoutSessionRequest ) SetMessageChannels (value bool ) {
if value {
i .Flags .Set (4 )
i .MessageChannels = true
} else {
i .Flags .Unset (4 )
i .MessageChannels = false
}
}
func (i *AccountInitTakeoutSessionRequest ) GetMessageChannels () (value bool ) {
if i == nil {
return
}
return i .Flags .Has (4 )
}
func (i *AccountInitTakeoutSessionRequest ) SetFiles (value bool ) {
if value {
i .Flags .Set (5 )
i .Files = true
} else {
i .Flags .Unset (5 )
i .Files = false
}
}
func (i *AccountInitTakeoutSessionRequest ) GetFiles () (value bool ) {
if i == nil {
return
}
return i .Flags .Has (5 )
}
func (i *AccountInitTakeoutSessionRequest ) SetFileMaxSize (value int64 ) {
i .Flags .Set (5 )
i .FileMaxSize = value
}
func (i *AccountInitTakeoutSessionRequest ) GetFileMaxSize () (value int64 , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (5 ) {
return value , false
}
return i .FileMaxSize , true
}
func (c *Client ) AccountInitTakeoutSession (ctx context .Context , request *AccountInitTakeoutSessionRequest ) (*AccountTakeout , error ) {
var result AccountTakeout
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return &result , 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 .