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 InputBusinessBotRecipients struct {
Flags bin .Fields
ExistingChats bool
NewChats bool
Contacts bool
NonContacts bool
ExcludeSelected bool
Users []InputUserClass
ExcludeUsers []InputUserClass
}
const InputBusinessBotRecipientsTypeID = 0xc4e5921e
var (
_ bin .Encoder = &InputBusinessBotRecipients {}
_ bin .Decoder = &InputBusinessBotRecipients {}
_ bin .BareEncoder = &InputBusinessBotRecipients {}
_ bin .BareDecoder = &InputBusinessBotRecipients {}
)
func (i *InputBusinessBotRecipients ) Zero () bool {
if i == nil {
return true
}
if !(i .Flags .Zero ()) {
return false
}
if !(i .ExistingChats == false ) {
return false
}
if !(i .NewChats == false ) {
return false
}
if !(i .Contacts == false ) {
return false
}
if !(i .NonContacts == false ) {
return false
}
if !(i .ExcludeSelected == false ) {
return false
}
if !(i .Users == nil ) {
return false
}
if !(i .ExcludeUsers == nil ) {
return false
}
return true
}
func (i *InputBusinessBotRecipients ) String () string {
if i == nil {
return "InputBusinessBotRecipients(nil)"
}
type Alias InputBusinessBotRecipients
return fmt .Sprintf ("InputBusinessBotRecipients%+v" , Alias (*i ))
}
func (i *InputBusinessBotRecipients ) FillFrom (from interface {
GetExistingChats () (value bool )
GetNewChats () (value bool )
GetContacts () (value bool )
GetNonContacts () (value bool )
GetExcludeSelected () (value bool )
GetUsers () (value []InputUserClass , ok bool )
GetExcludeUsers () (value []InputUserClass , ok bool )
}) {
i .ExistingChats = from .GetExistingChats ()
i .NewChats = from .GetNewChats ()
i .Contacts = from .GetContacts ()
i .NonContacts = from .GetNonContacts ()
i .ExcludeSelected = from .GetExcludeSelected ()
if val , ok := from .GetUsers (); ok {
i .Users = val
}
if val , ok := from .GetExcludeUsers (); ok {
i .ExcludeUsers = val
}
}
func (*InputBusinessBotRecipients ) TypeID () uint32 {
return InputBusinessBotRecipientsTypeID
}
func (*InputBusinessBotRecipients ) TypeName () string {
return "inputBusinessBotRecipients"
}
func (i *InputBusinessBotRecipients ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputBusinessBotRecipients" ,
ID : InputBusinessBotRecipientsTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ExistingChats" ,
SchemaName : "existing_chats" ,
Null : !i .Flags .Has (0 ),
},
{
Name : "NewChats" ,
SchemaName : "new_chats" ,
Null : !i .Flags .Has (1 ),
},
{
Name : "Contacts" ,
SchemaName : "contacts" ,
Null : !i .Flags .Has (2 ),
},
{
Name : "NonContacts" ,
SchemaName : "non_contacts" ,
Null : !i .Flags .Has (3 ),
},
{
Name : "ExcludeSelected" ,
SchemaName : "exclude_selected" ,
Null : !i .Flags .Has (5 ),
},
{
Name : "Users" ,
SchemaName : "users" ,
Null : !i .Flags .Has (4 ),
},
{
Name : "ExcludeUsers" ,
SchemaName : "exclude_users" ,
Null : !i .Flags .Has (6 ),
},
}
return typ
}
func (i *InputBusinessBotRecipients ) SetFlags () {
if !(i .ExistingChats == false ) {
i .Flags .Set (0 )
}
if !(i .NewChats == false ) {
i .Flags .Set (1 )
}
if !(i .Contacts == false ) {
i .Flags .Set (2 )
}
if !(i .NonContacts == false ) {
i .Flags .Set (3 )
}
if !(i .ExcludeSelected == false ) {
i .Flags .Set (5 )
}
if !(i .Users == nil ) {
i .Flags .Set (4 )
}
if !(i .ExcludeUsers == nil ) {
i .Flags .Set (6 )
}
}
func (i *InputBusinessBotRecipients ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputBusinessBotRecipients#c4e5921e as nil" )
}
b .PutID (InputBusinessBotRecipientsTypeID )
return i .EncodeBare (b )
}
func (i *InputBusinessBotRecipients ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputBusinessBotRecipients#c4e5921e as nil" )
}
i .SetFlags ()
if err := i .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputBusinessBotRecipients#c4e5921e: field flags: %w" , err )
}
if i .Flags .Has (4 ) {
b .PutVectorHeader (len (i .Users ))
for idx , v := range i .Users {
if v == nil {
return fmt .Errorf ("unable to encode inputBusinessBotRecipients#c4e5921e: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputBusinessBotRecipients#c4e5921e: field users element with index %d: %w" , idx , err )
}
}
}
if i .Flags .Has (6 ) {
b .PutVectorHeader (len (i .ExcludeUsers ))
for idx , v := range i .ExcludeUsers {
if v == nil {
return fmt .Errorf ("unable to encode inputBusinessBotRecipients#c4e5921e: field exclude_users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputBusinessBotRecipients#c4e5921e: field exclude_users element with index %d: %w" , idx , err )
}
}
}
return nil
}
func (i *InputBusinessBotRecipients ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputBusinessBotRecipients#c4e5921e to nil" )
}
if err := b .ConsumeID (InputBusinessBotRecipientsTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputBusinessBotRecipients#c4e5921e: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputBusinessBotRecipients ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputBusinessBotRecipients#c4e5921e to nil" )
}
{
if err := i .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode inputBusinessBotRecipients#c4e5921e: field flags: %w" , err )
}
}
i .ExistingChats = i .Flags .Has (0 )
i .NewChats = i .Flags .Has (1 )
i .Contacts = i .Flags .Has (2 )
i .NonContacts = i .Flags .Has (3 )
i .ExcludeSelected = i .Flags .Has (5 )
if i .Flags .Has (4 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode inputBusinessBotRecipients#c4e5921e: field users: %w" , err )
}
if headerLen > 0 {
i .Users = make ([]InputUserClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode inputBusinessBotRecipients#c4e5921e: field users: %w" , err )
}
i .Users = append (i .Users , value )
}
}
if i .Flags .Has (6 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode inputBusinessBotRecipients#c4e5921e: field exclude_users: %w" , err )
}
if headerLen > 0 {
i .ExcludeUsers = make ([]InputUserClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode inputBusinessBotRecipients#c4e5921e: field exclude_users: %w" , err )
}
i .ExcludeUsers = append (i .ExcludeUsers , value )
}
}
return nil
}
func (i *InputBusinessBotRecipients ) SetExistingChats (value bool ) {
if value {
i .Flags .Set (0 )
i .ExistingChats = true
} else {
i .Flags .Unset (0 )
i .ExistingChats = false
}
}
func (i *InputBusinessBotRecipients ) GetExistingChats () (value bool ) {
if i == nil {
return
}
return i .Flags .Has (0 )
}
func (i *InputBusinessBotRecipients ) SetNewChats (value bool ) {
if value {
i .Flags .Set (1 )
i .NewChats = true
} else {
i .Flags .Unset (1 )
i .NewChats = false
}
}
func (i *InputBusinessBotRecipients ) GetNewChats () (value bool ) {
if i == nil {
return
}
return i .Flags .Has (1 )
}
func (i *InputBusinessBotRecipients ) SetContacts (value bool ) {
if value {
i .Flags .Set (2 )
i .Contacts = true
} else {
i .Flags .Unset (2 )
i .Contacts = false
}
}
func (i *InputBusinessBotRecipients ) GetContacts () (value bool ) {
if i == nil {
return
}
return i .Flags .Has (2 )
}
func (i *InputBusinessBotRecipients ) SetNonContacts (value bool ) {
if value {
i .Flags .Set (3 )
i .NonContacts = true
} else {
i .Flags .Unset (3 )
i .NonContacts = false
}
}
func (i *InputBusinessBotRecipients ) GetNonContacts () (value bool ) {
if i == nil {
return
}
return i .Flags .Has (3 )
}
func (i *InputBusinessBotRecipients ) SetExcludeSelected (value bool ) {
if value {
i .Flags .Set (5 )
i .ExcludeSelected = true
} else {
i .Flags .Unset (5 )
i .ExcludeSelected = false
}
}
func (i *InputBusinessBotRecipients ) GetExcludeSelected () (value bool ) {
if i == nil {
return
}
return i .Flags .Has (5 )
}
func (i *InputBusinessBotRecipients ) SetUsers (value []InputUserClass ) {
i .Flags .Set (4 )
i .Users = value
}
func (i *InputBusinessBotRecipients ) GetUsers () (value []InputUserClass , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (4 ) {
return value , false
}
return i .Users , true
}
func (i *InputBusinessBotRecipients ) SetExcludeUsers (value []InputUserClass ) {
i .Flags .Set (6 )
i .ExcludeUsers = value
}
func (i *InputBusinessBotRecipients ) GetExcludeUsers () (value []InputUserClass , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (6 ) {
return value , false
}
return i .ExcludeUsers , true
}
func (i *InputBusinessBotRecipients ) MapUsers () (value InputUserClassArray , ok bool ) {
if !i .Flags .Has (4 ) {
return value , false
}
return InputUserClassArray (i .Users ), true
}
func (i *InputBusinessBotRecipients ) MapExcludeUsers () (value InputUserClassArray , ok bool ) {
if !i .Flags .Has (6 ) {
return value , false
}
return InputUserClassArray (i .ExcludeUsers ), true
}
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 .