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