// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// BusinessBotRecipients represents TL type `businessBotRecipients#b88cf373`.
// Specifies the private chats that a connected business bot »¹ may receive messages
// and interact with.
//
// Links:
//  1. https://core.telegram.org/api/bots/connected-business-bots
//
// See https://core.telegram.org/constructor/businessBotRecipients for reference.
type BusinessBotRecipients struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Selects all existing private chats.
	ExistingChats bool
	// Selects all new private chats.
	NewChats bool
	// Selects all private chats with contacts.
	Contacts bool
	// Selects all private chats with non-contacts.
	NonContacts bool
	// If set, then all private chats except the ones selected by existing_chats, new_chats,
	// contacts, non_contacts and users are chosen. Note that if this flag is set, any values
	// passed in exclude_users will be merged and moved into users by the server, thus
	// exclude_users will always be empty.
	ExcludeSelected bool
	// Explicitly selected private chats.
	//
	// Use SetUsers and GetUsers helpers.
	Users []int64
	// Identifiers of private chats that are always excluded.
	//
	// Use SetExcludeUsers and GetExcludeUsers helpers.
	ExcludeUsers []int64
}

// BusinessBotRecipientsTypeID is TL type id of BusinessBotRecipients.
const BusinessBotRecipientsTypeID = 0xb88cf373

// Ensuring interfaces in compile-time for BusinessBotRecipients.
var (
	_ bin.Encoder     = &BusinessBotRecipients{}
	_ bin.Decoder     = &BusinessBotRecipients{}
	_ bin.BareEncoder = &BusinessBotRecipients{}
	_ bin.BareDecoder = &BusinessBotRecipients{}
)

func ( *BusinessBotRecipients) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ExistingChats == false) {
		return false
	}
	if !(.NewChats == false) {
		return false
	}
	if !(.Contacts == false) {
		return false
	}
	if !(.NonContacts == false) {
		return false
	}
	if !(.ExcludeSelected == false) {
		return false
	}
	if !(.Users == nil) {
		return false
	}
	if !(.ExcludeUsers == nil) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *BusinessBotRecipients) () string {
	if  == nil {
		return "BusinessBotRecipients(nil)"
	}
	type  BusinessBotRecipients
	return fmt.Sprintf("BusinessBotRecipients%+v", (*))
}

// FillFrom fills BusinessBotRecipients from given interface.
func ( *BusinessBotRecipients) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( []int64,  bool)
	() ( []int64,  bool)
}) {
	.ExistingChats = .()
	.NewChats = .()
	.Contacts = .()
	.NonContacts = .()
	.ExcludeSelected = .()
	if ,  := .();  {
		.Users = 
	}

	if ,  := .();  {
		.ExcludeUsers = 
	}

}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*BusinessBotRecipients) () uint32 {
	return BusinessBotRecipientsTypeID
}

// TypeName returns name of type in TL schema.
func (*BusinessBotRecipients) () string {
	return "businessBotRecipients"
}

// TypeInfo returns info about TL type.
func ( *BusinessBotRecipients) () tdp.Type {
	 := tdp.Type{
		Name: "businessBotRecipients",
		ID:   BusinessBotRecipientsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ExistingChats",
			SchemaName: "existing_chats",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "NewChats",
			SchemaName: "new_chats",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Contacts",
			SchemaName: "contacts",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "NonContacts",
			SchemaName: "non_contacts",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "ExcludeSelected",
			SchemaName: "exclude_selected",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "Users",
			SchemaName: "users",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "ExcludeUsers",
			SchemaName: "exclude_users",
			Null:       !.Flags.Has(6),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *BusinessBotRecipients) () {
	if !(.ExistingChats == false) {
		.Flags.Set(0)
	}
	if !(.NewChats == false) {
		.Flags.Set(1)
	}
	if !(.Contacts == false) {
		.Flags.Set(2)
	}
	if !(.NonContacts == false) {
		.Flags.Set(3)
	}
	if !(.ExcludeSelected == false) {
		.Flags.Set(5)
	}
	if !(.Users == nil) {
		.Flags.Set(4)
	}
	if !(.ExcludeUsers == nil) {
		.Flags.Set(6)
	}
}

// Encode implements bin.Encoder.
func ( *BusinessBotRecipients) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode businessBotRecipients#b88cf373 as nil")
	}
	.PutID(BusinessBotRecipientsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BusinessBotRecipients) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode businessBotRecipients#b88cf373 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode businessBotRecipients#b88cf373: field flags: %w", )
	}
	if .Flags.Has(4) {
		.PutVectorHeader(len(.Users))
		for ,  := range .Users {
			.PutLong()
		}
	}
	if .Flags.Has(6) {
		.PutVectorHeader(len(.ExcludeUsers))
		for ,  := range .ExcludeUsers {
			.PutLong()
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *BusinessBotRecipients) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode businessBotRecipients#b88cf373 to nil")
	}
	if  := .ConsumeID(BusinessBotRecipientsTypeID);  != nil {
		return fmt.Errorf("unable to decode businessBotRecipients#b88cf373: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *BusinessBotRecipients) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode businessBotRecipients#b88cf373 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode businessBotRecipients#b88cf373: field flags: %w", )
		}
	}
	.ExistingChats = .Flags.Has(0)
	.NewChats = .Flags.Has(1)
	.Contacts = .Flags.Has(2)
	.NonContacts = .Flags.Has(3)
	.ExcludeSelected = .Flags.Has(5)
	if .Flags.Has(4) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode businessBotRecipients#b88cf373: field users: %w", )
		}

		if  > 0 {
			.Users = make([]int64, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Long()
			if  != nil {
				return fmt.Errorf("unable to decode businessBotRecipients#b88cf373: field users: %w", )
			}
			.Users = append(.Users, )
		}
	}
	if .Flags.Has(6) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode businessBotRecipients#b88cf373: field exclude_users: %w", )
		}

		if  > 0 {
			.ExcludeUsers = make([]int64, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Long()
			if  != nil {
				return fmt.Errorf("unable to decode businessBotRecipients#b88cf373: field exclude_users: %w", )
			}
			.ExcludeUsers = append(.ExcludeUsers, )
		}
	}
	return nil
}

// SetExistingChats sets value of ExistingChats conditional field.
func ( *BusinessBotRecipients) ( bool) {
	if  {
		.Flags.Set(0)
		.ExistingChats = true
	} else {
		.Flags.Unset(0)
		.ExistingChats = false
	}
}

// GetExistingChats returns value of ExistingChats conditional field.
func ( *BusinessBotRecipients) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetNewChats sets value of NewChats conditional field.
func ( *BusinessBotRecipients) ( bool) {
	if  {
		.Flags.Set(1)
		.NewChats = true
	} else {
		.Flags.Unset(1)
		.NewChats = false
	}
}

// GetNewChats returns value of NewChats conditional field.
func ( *BusinessBotRecipients) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetContacts sets value of Contacts conditional field.
func ( *BusinessBotRecipients) ( bool) {
	if  {
		.Flags.Set(2)
		.Contacts = true
	} else {
		.Flags.Unset(2)
		.Contacts = false
	}
}

// GetContacts returns value of Contacts conditional field.
func ( *BusinessBotRecipients) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// SetNonContacts sets value of NonContacts conditional field.
func ( *BusinessBotRecipients) ( bool) {
	if  {
		.Flags.Set(3)
		.NonContacts = true
	} else {
		.Flags.Unset(3)
		.NonContacts = false
	}
}

// GetNonContacts returns value of NonContacts conditional field.
func ( *BusinessBotRecipients) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// SetExcludeSelected sets value of ExcludeSelected conditional field.
func ( *BusinessBotRecipients) ( bool) {
	if  {
		.Flags.Set(5)
		.ExcludeSelected = true
	} else {
		.Flags.Unset(5)
		.ExcludeSelected = false
	}
}

// GetExcludeSelected returns value of ExcludeSelected conditional field.
func ( *BusinessBotRecipients) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(5)
}

// SetUsers sets value of Users conditional field.
func ( *BusinessBotRecipients) ( []int64) {
	.Flags.Set(4)
	.Users = 
}

// GetUsers returns value of Users conditional field and
// boolean which is true if field was set.
func ( *BusinessBotRecipients) () ( []int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(4) {
		return , false
	}
	return .Users, true
}

// SetExcludeUsers sets value of ExcludeUsers conditional field.
func ( *BusinessBotRecipients) ( []int64) {
	.Flags.Set(6)
	.ExcludeUsers = 
}

// GetExcludeUsers returns value of ExcludeUsers conditional field and
// boolean which is true if field was set.
func ( *BusinessBotRecipients) () ( []int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(6) {
		return , false
	}
	return .ExcludeUsers, true
}