// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	"context"
	"errors"
	"fmt"
	"sort"
	"strings"

	"go.uber.org/multierr"

	"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
)

// 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{}
)

// PeerSettings represents TL type `peerSettings#f47741f7`.
// List of actions that are possible when interacting with this user, to be shown as
// suggested actions in the chat action bar »¹, see here »² for more info.
//
// Links:
//  1. https://core.telegram.org/api/action-bar
//  2. https://core.telegram.org/api/action-bar
//
// See https://core.telegram.org/constructor/peerSettings for reference.
type PeerSettings struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether we can still report the user for spam
	ReportSpam bool
	// Whether we can add the user as contact
	AddContact bool
	// Whether we can block the user
	BlockContact bool
	// Whether we can share the user's contact
	ShareContact bool
	// Whether a special exception for contacts is needed
	NeedContactsException bool
	// Whether we can report a geogroup as irrelevant for this location
	ReportGeo bool
	// Whether this peer was automatically archived according to privacy settings¹ and can
	// be unarchived
	//
	// Links:
	//  1) https://core.telegram.org/constructor/globalPrivacySettings
	Autoarchived bool
	// If set, this is a recently created group chat to which new members can be invited
	InviteMembers bool
	// This flag is set if request_chat_title and request_chat_date fields are set and the
	// join request »¹ is related to a channel (otherwise if only the request fields are
	// set, the join request »² is related to a chat).
	//
	// Links:
	//  1) https://core.telegram.org/api/invites#join-requests
	//  2) https://core.telegram.org/api/invites#join-requests
	RequestChatBroadcast bool
	// This flag is set if both business_bot_id and business_bot_manage_url are set and all
	// connected business bots »¹ were paused in this chat using account
	// toggleConnectedBotPaused »².
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/connected-business-bots
	//  2) https://core.telegram.org/method/account.toggleConnectedBotPaused
	BusinessBotPaused bool
	// This flag is set if both business_bot_id and business_bot_manage_url are set and
	// connected business bots »¹ can reply to messages in this chat, as specified by the
	// settings during initial configuration².
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/connected-business-bots
	//  2) https://core.telegram.org/api/bots/connected-business-bots
	BusinessBotCanReply bool
	// Distance in meters between us and this peer
	//
	// Use SetGeoDistance and GetGeoDistance helpers.
	GeoDistance int
	// If set, this is a private chat with an administrator of a chat or channel to which the
	// user sent a join request, and this field contains the chat/channel's title.
	//
	// Use SetRequestChatTitle and GetRequestChatTitle helpers.
	RequestChatTitle string
	// If set, this is a private chat with an administrator of a chat or channel to which the
	// user sent a join request, and this field contains the timestamp when the join request
	// »¹ was sent.
	//
	// Links:
	//  1) https://core.telegram.org/api/invites#join-requests
	//
	// Use SetRequestChatDate and GetRequestChatDate helpers.
	RequestChatDate int
	// Contains the ID of the business bot »¹ managing this chat, used to display info
	// about the bot in the action bar.
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/connected-business-bots
	//
	// Use SetBusinessBotID and GetBusinessBotID helpers.
	BusinessBotID int64
	// Contains a deep link »¹, used to open a management menu in the business bot. This
	// flag is set if and only if business_bot_id is set.
	//
	// Links:
	//  1) https://core.telegram.org/api/links
	//
	// Use SetBusinessBotManageURL and GetBusinessBotManageURL helpers.
	BusinessBotManageURL string
	// All users that must pay us »¹ to send us private messages will have this flag set
	// only for us, containing the amount of required stars, see here »² for more info on
	// paid messages.
	//
	// Links:
	//  1) https://core.telegram.org/api/paid-messages
	//  2) https://core.telegram.org/api/paid-messages
	//
	// Use SetChargePaidMessageStars and GetChargePaidMessageStars helpers.
	ChargePaidMessageStars int64
	// Used to display the user's registration year and month, the string is in MM.YYYY
	// format, where MM is the registration month (1-12), and YYYY is the registration year.
	//
	// Use SetRegistrationMonth and GetRegistrationMonth helpers.
	RegistrationMonth string
	// The country code of the user's phone number.
	//
	// Use SetPhoneCountry and GetPhoneCountry helpers.
	PhoneCountry string
	// When was the user's name last changed.
	//
	// Use SetNameChangeDate and GetNameChangeDate helpers.
	NameChangeDate int
	// When was the user's photo last changed.
	//
	// Use SetPhotoChangeDate and GetPhotoChangeDate helpers.
	PhotoChangeDate int
}

// PeerSettingsTypeID is TL type id of PeerSettings.
const PeerSettingsTypeID = 0xf47741f7

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

func (p *PeerSettings) Zero() bool {
	if p == nil {
		return true
	}
	if !(p.Flags.Zero()) {
		return false
	}
	if !(p.ReportSpam == false) {
		return false
	}
	if !(p.AddContact == false) {
		return false
	}
	if !(p.BlockContact == false) {
		return false
	}
	if !(p.ShareContact == false) {
		return false
	}
	if !(p.NeedContactsException == false) {
		return false
	}
	if !(p.ReportGeo == false) {
		return false
	}
	if !(p.Autoarchived == false) {
		return false
	}
	if !(p.InviteMembers == false) {
		return false
	}
	if !(p.RequestChatBroadcast == false) {
		return false
	}
	if !(p.BusinessBotPaused == false) {
		return false
	}
	if !(p.BusinessBotCanReply == false) {
		return false
	}
	if !(p.GeoDistance == 0) {
		return false
	}
	if !(p.RequestChatTitle == "") {
		return false
	}
	if !(p.RequestChatDate == 0) {
		return false
	}
	if !(p.BusinessBotID == 0) {
		return false
	}
	if !(p.BusinessBotManageURL == "") {
		return false
	}
	if !(p.ChargePaidMessageStars == 0) {
		return false
	}
	if !(p.RegistrationMonth == "") {
		return false
	}
	if !(p.PhoneCountry == "") {
		return false
	}
	if !(p.NameChangeDate == 0) {
		return false
	}
	if !(p.PhotoChangeDate == 0) {
		return false
	}

	return true
}

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

// FillFrom fills PeerSettings from given interface.
func (p *PeerSettings) FillFrom(from interface {
	GetReportSpam() (value bool)
	GetAddContact() (value bool)
	GetBlockContact() (value bool)
	GetShareContact() (value bool)
	GetNeedContactsException() (value bool)
	GetReportGeo() (value bool)
	GetAutoarchived() (value bool)
	GetInviteMembers() (value bool)
	GetRequestChatBroadcast() (value bool)
	GetBusinessBotPaused() (value bool)
	GetBusinessBotCanReply() (value bool)
	GetGeoDistance() (value int, ok bool)
	GetRequestChatTitle() (value string, ok bool)
	GetRequestChatDate() (value int, ok bool)
	GetBusinessBotID() (value int64, ok bool)
	GetBusinessBotManageURL() (value string, ok bool)
	GetChargePaidMessageStars() (value int64, ok bool)
	GetRegistrationMonth() (value string, ok bool)
	GetPhoneCountry() (value string, ok bool)
	GetNameChangeDate() (value int, ok bool)
	GetPhotoChangeDate() (value int, ok bool)
}) {
	p.ReportSpam = from.GetReportSpam()
	p.AddContact = from.GetAddContact()
	p.BlockContact = from.GetBlockContact()
	p.ShareContact = from.GetShareContact()
	p.NeedContactsException = from.GetNeedContactsException()
	p.ReportGeo = from.GetReportGeo()
	p.Autoarchived = from.GetAutoarchived()
	p.InviteMembers = from.GetInviteMembers()
	p.RequestChatBroadcast = from.GetRequestChatBroadcast()
	p.BusinessBotPaused = from.GetBusinessBotPaused()
	p.BusinessBotCanReply = from.GetBusinessBotCanReply()
	if val, ok := from.GetGeoDistance(); ok {
		p.GeoDistance = val
	}

	if val, ok := from.GetRequestChatTitle(); ok {
		p.RequestChatTitle = val
	}

	if val, ok := from.GetRequestChatDate(); ok {
		p.RequestChatDate = val
	}

	if val, ok := from.GetBusinessBotID(); ok {
		p.BusinessBotID = val
	}

	if val, ok := from.GetBusinessBotManageURL(); ok {
		p.BusinessBotManageURL = val
	}

	if val, ok := from.GetChargePaidMessageStars(); ok {
		p.ChargePaidMessageStars = val
	}

	if val, ok := from.GetRegistrationMonth(); ok {
		p.RegistrationMonth = val
	}

	if val, ok := from.GetPhoneCountry(); ok {
		p.PhoneCountry = val
	}

	if val, ok := from.GetNameChangeDate(); ok {
		p.NameChangeDate = val
	}

	if val, ok := from.GetPhotoChangeDate(); ok {
		p.PhotoChangeDate = val
	}

}

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

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

// TypeInfo returns info about TL type.
func (p *PeerSettings) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "peerSettings",
		ID:   PeerSettingsTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "ReportSpam",
			SchemaName: "report_spam",
			Null:       !p.Flags.Has(0),
		},
		{
			Name:       "AddContact",
			SchemaName: "add_contact",
			Null:       !p.Flags.Has(1),
		},
		{
			Name:       "BlockContact",
			SchemaName: "block_contact",
			Null:       !p.Flags.Has(2),
		},
		{
			Name:       "ShareContact",
			SchemaName: "share_contact",
			Null:       !p.Flags.Has(3),
		},
		{
			Name:       "NeedContactsException",
			SchemaName: "need_contacts_exception",
			Null:       !p.Flags.Has(4),
		},
		{
			Name:       "ReportGeo",
			SchemaName: "report_geo",
			Null:       !p.Flags.Has(5),
		},
		{
			Name:       "Autoarchived",
			SchemaName: "autoarchived",
			Null:       !p.Flags.Has(7),
		},
		{
			Name:       "InviteMembers",
			SchemaName: "invite_members",
			Null:       !p.Flags.Has(8),
		},
		{
			Name:       "RequestChatBroadcast",
			SchemaName: "request_chat_broadcast",
			Null:       !p.Flags.Has(10),
		},
		{
			Name:       "BusinessBotPaused",
			SchemaName: "business_bot_paused",
			Null:       !p.Flags.Has(11),
		},
		{
			Name:       "BusinessBotCanReply",
			SchemaName: "business_bot_can_reply",
			Null:       !p.Flags.Has(12),
		},
		{
			Name:       "GeoDistance",
			SchemaName: "geo_distance",
			Null:       !p.Flags.Has(6),
		},
		{
			Name:       "RequestChatTitle",
			SchemaName: "request_chat_title",
			Null:       !p.Flags.Has(9),
		},
		{
			Name:       "RequestChatDate",
			SchemaName: "request_chat_date",
			Null:       !p.Flags.Has(9),
		},
		{
			Name:       "BusinessBotID",
			SchemaName: "business_bot_id",
			Null:       !p.Flags.Has(13),
		},
		{
			Name:       "BusinessBotManageURL",
			SchemaName: "business_bot_manage_url",
			Null:       !p.Flags.Has(13),
		},
		{
			Name:       "ChargePaidMessageStars",
			SchemaName: "charge_paid_message_stars",
			Null:       !p.Flags.Has(14),
		},
		{
			Name:       "RegistrationMonth",
			SchemaName: "registration_month",
			Null:       !p.Flags.Has(15),
		},
		{
			Name:       "PhoneCountry",
			SchemaName: "phone_country",
			Null:       !p.Flags.Has(16),
		},
		{
			Name:       "NameChangeDate",
			SchemaName: "name_change_date",
			Null:       !p.Flags.Has(17),
		},
		{
			Name:       "PhotoChangeDate",
			SchemaName: "photo_change_date",
			Null:       !p.Flags.Has(18),
		},
	}
	return typ
}

// SetFlags sets flags for non-zero fields.
func (p *PeerSettings) SetFlags() {
	if !(p.ReportSpam == false) {
		p.Flags.Set(0)
	}
	if !(p.AddContact == false) {
		p.Flags.Set(1)
	}
	if !(p.BlockContact == false) {
		p.Flags.Set(2)
	}
	if !(p.ShareContact == false) {
		p.Flags.Set(3)
	}
	if !(p.NeedContactsException == false) {
		p.Flags.Set(4)
	}
	if !(p.ReportGeo == false) {
		p.Flags.Set(5)
	}
	if !(p.Autoarchived == false) {
		p.Flags.Set(7)
	}
	if !(p.InviteMembers == false) {
		p.Flags.Set(8)
	}
	if !(p.RequestChatBroadcast == false) {
		p.Flags.Set(10)
	}
	if !(p.BusinessBotPaused == false) {
		p.Flags.Set(11)
	}
	if !(p.BusinessBotCanReply == false) {
		p.Flags.Set(12)
	}
	if !(p.GeoDistance == 0) {
		p.Flags.Set(6)
	}
	if !(p.RequestChatTitle == "") {
		p.Flags.Set(9)
	}
	if !(p.RequestChatDate == 0) {
		p.Flags.Set(9)
	}
	if !(p.BusinessBotID == 0) {
		p.Flags.Set(13)
	}
	if !(p.BusinessBotManageURL == "") {
		p.Flags.Set(13)
	}
	if !(p.ChargePaidMessageStars == 0) {
		p.Flags.Set(14)
	}
	if !(p.RegistrationMonth == "") {
		p.Flags.Set(15)
	}
	if !(p.PhoneCountry == "") {
		p.Flags.Set(16)
	}
	if !(p.NameChangeDate == 0) {
		p.Flags.Set(17)
	}
	if !(p.PhotoChangeDate == 0) {
		p.Flags.Set(18)
	}
}

// Encode implements bin.Encoder.
func (p *PeerSettings) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode peerSettings#f47741f7 as nil")
	}
	b.PutID(PeerSettingsTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PeerSettings) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode peerSettings#f47741f7 as nil")
	}
	p.SetFlags()
	if err := p.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode peerSettings#f47741f7: field flags: %w", err)
	}
	if p.Flags.Has(6) {
		b.PutInt(p.GeoDistance)
	}
	if p.Flags.Has(9) {
		b.PutString(p.RequestChatTitle)
	}
	if p.Flags.Has(9) {
		b.PutInt(p.RequestChatDate)
	}
	if p.Flags.Has(13) {
		b.PutLong(p.BusinessBotID)
	}
	if p.Flags.Has(13) {
		b.PutString(p.BusinessBotManageURL)
	}
	if p.Flags.Has(14) {
		b.PutLong(p.ChargePaidMessageStars)
	}
	if p.Flags.Has(15) {
		b.PutString(p.RegistrationMonth)
	}
	if p.Flags.Has(16) {
		b.PutString(p.PhoneCountry)
	}
	if p.Flags.Has(17) {
		b.PutInt(p.NameChangeDate)
	}
	if p.Flags.Has(18) {
		b.PutInt(p.PhotoChangeDate)
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PeerSettings) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode peerSettings#f47741f7 to nil")
	}
	if err := b.ConsumeID(PeerSettingsTypeID); err != nil {
		return fmt.Errorf("unable to decode peerSettings#f47741f7: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PeerSettings) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode peerSettings#f47741f7 to nil")
	}
	{
		if err := p.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode peerSettings#f47741f7: field flags: %w", err)
		}
	}
	p.ReportSpam = p.Flags.Has(0)
	p.AddContact = p.Flags.Has(1)
	p.BlockContact = p.Flags.Has(2)
	p.ShareContact = p.Flags.Has(3)
	p.NeedContactsException = p.Flags.Has(4)
	p.ReportGeo = p.Flags.Has(5)
	p.Autoarchived = p.Flags.Has(7)
	p.InviteMembers = p.Flags.Has(8)
	p.RequestChatBroadcast = p.Flags.Has(10)
	p.BusinessBotPaused = p.Flags.Has(11)
	p.BusinessBotCanReply = p.Flags.Has(12)
	if p.Flags.Has(6) {
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode peerSettings#f47741f7: field geo_distance: %w", err)
		}
		p.GeoDistance = value
	}
	if p.Flags.Has(9) {
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode peerSettings#f47741f7: field request_chat_title: %w", err)
		}
		p.RequestChatTitle = value
	}
	if p.Flags.Has(9) {
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode peerSettings#f47741f7: field request_chat_date: %w", err)
		}
		p.RequestChatDate = value
	}
	if p.Flags.Has(13) {
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode peerSettings#f47741f7: field business_bot_id: %w", err)
		}
		p.BusinessBotID = value
	}
	if p.Flags.Has(13) {
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode peerSettings#f47741f7: field business_bot_manage_url: %w", err)
		}
		p.BusinessBotManageURL = value
	}
	if p.Flags.Has(14) {
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode peerSettings#f47741f7: field charge_paid_message_stars: %w", err)
		}
		p.ChargePaidMessageStars = value
	}
	if p.Flags.Has(15) {
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode peerSettings#f47741f7: field registration_month: %w", err)
		}
		p.RegistrationMonth = value
	}
	if p.Flags.Has(16) {
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode peerSettings#f47741f7: field phone_country: %w", err)
		}
		p.PhoneCountry = value
	}
	if p.Flags.Has(17) {
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode peerSettings#f47741f7: field name_change_date: %w", err)
		}
		p.NameChangeDate = value
	}
	if p.Flags.Has(18) {
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode peerSettings#f47741f7: field photo_change_date: %w", err)
		}
		p.PhotoChangeDate = value
	}
	return nil
}

// SetReportSpam sets value of ReportSpam conditional field.
func (p *PeerSettings) SetReportSpam(value bool) {
	if value {
		p.Flags.Set(0)
		p.ReportSpam = true
	} else {
		p.Flags.Unset(0)
		p.ReportSpam = false
	}
}

// GetReportSpam returns value of ReportSpam conditional field.
func (p *PeerSettings) GetReportSpam() (value bool) {
	if p == nil {
		return
	}
	return p.Flags.Has(0)
}

// SetAddContact sets value of AddContact conditional field.
func (p *PeerSettings) SetAddContact(value bool) {
	if value {
		p.Flags.Set(1)
		p.AddContact = true
	} else {
		p.Flags.Unset(1)
		p.AddContact = false
	}
}

// GetAddContact returns value of AddContact conditional field.
func (p *PeerSettings) GetAddContact() (value bool) {
	if p == nil {
		return
	}
	return p.Flags.Has(1)
}

// SetBlockContact sets value of BlockContact conditional field.
func (p *PeerSettings) SetBlockContact(value bool) {
	if value {
		p.Flags.Set(2)
		p.BlockContact = true
	} else {
		p.Flags.Unset(2)
		p.BlockContact = false
	}
}

// GetBlockContact returns value of BlockContact conditional field.
func (p *PeerSettings) GetBlockContact() (value bool) {
	if p == nil {
		return
	}
	return p.Flags.Has(2)
}

// SetShareContact sets value of ShareContact conditional field.
func (p *PeerSettings) SetShareContact(value bool) {
	if value {
		p.Flags.Set(3)
		p.ShareContact = true
	} else {
		p.Flags.Unset(3)
		p.ShareContact = false
	}
}

// GetShareContact returns value of ShareContact conditional field.
func (p *PeerSettings) GetShareContact() (value bool) {
	if p == nil {
		return
	}
	return p.Flags.Has(3)
}

// SetNeedContactsException sets value of NeedContactsException conditional field.
func (p *PeerSettings) SetNeedContactsException(value bool) {
	if value {
		p.Flags.Set(4)
		p.NeedContactsException = true
	} else {
		p.Flags.Unset(4)
		p.NeedContactsException = false
	}
}

// GetNeedContactsException returns value of NeedContactsException conditional field.
func (p *PeerSettings) GetNeedContactsException() (value bool) {
	if p == nil {
		return
	}
	return p.Flags.Has(4)
}

// SetReportGeo sets value of ReportGeo conditional field.
func (p *PeerSettings) SetReportGeo(value bool) {
	if value {
		p.Flags.Set(5)
		p.ReportGeo = true
	} else {
		p.Flags.Unset(5)
		p.ReportGeo = false
	}
}

// GetReportGeo returns value of ReportGeo conditional field.
func (p *PeerSettings) GetReportGeo() (value bool) {
	if p == nil {
		return
	}
	return p.Flags.Has(5)
}

// SetAutoarchived sets value of Autoarchived conditional field.
func (p *PeerSettings) SetAutoarchived(value bool) {
	if value {
		p.Flags.Set(7)
		p.Autoarchived = true
	} else {
		p.Flags.Unset(7)
		p.Autoarchived = false
	}
}

// GetAutoarchived returns value of Autoarchived conditional field.
func (p *PeerSettings) GetAutoarchived() (value bool) {
	if p == nil {
		return
	}
	return p.Flags.Has(7)
}

// SetInviteMembers sets value of InviteMembers conditional field.
func (p *PeerSettings) SetInviteMembers(value bool) {
	if value {
		p.Flags.Set(8)
		p.InviteMembers = true
	} else {
		p.Flags.Unset(8)
		p.InviteMembers = false
	}
}

// GetInviteMembers returns value of InviteMembers conditional field.
func (p *PeerSettings) GetInviteMembers() (value bool) {
	if p == nil {
		return
	}
	return p.Flags.Has(8)
}

// SetRequestChatBroadcast sets value of RequestChatBroadcast conditional field.
func (p *PeerSettings) SetRequestChatBroadcast(value bool) {
	if value {
		p.Flags.Set(10)
		p.RequestChatBroadcast = true
	} else {
		p.Flags.Unset(10)
		p.RequestChatBroadcast = false
	}
}

// GetRequestChatBroadcast returns value of RequestChatBroadcast conditional field.
func (p *PeerSettings) GetRequestChatBroadcast() (value bool) {
	if p == nil {
		return
	}
	return p.Flags.Has(10)
}

// SetBusinessBotPaused sets value of BusinessBotPaused conditional field.
func (p *PeerSettings) SetBusinessBotPaused(value bool) {
	if value {
		p.Flags.Set(11)
		p.BusinessBotPaused = true
	} else {
		p.Flags.Unset(11)
		p.BusinessBotPaused = false
	}
}

// GetBusinessBotPaused returns value of BusinessBotPaused conditional field.
func (p *PeerSettings) GetBusinessBotPaused() (value bool) {
	if p == nil {
		return
	}
	return p.Flags.Has(11)
}

// SetBusinessBotCanReply sets value of BusinessBotCanReply conditional field.
func (p *PeerSettings) SetBusinessBotCanReply(value bool) {
	if value {
		p.Flags.Set(12)
		p.BusinessBotCanReply = true
	} else {
		p.Flags.Unset(12)
		p.BusinessBotCanReply = false
	}
}

// GetBusinessBotCanReply returns value of BusinessBotCanReply conditional field.
func (p *PeerSettings) GetBusinessBotCanReply() (value bool) {
	if p == nil {
		return
	}
	return p.Flags.Has(12)
}

// SetGeoDistance sets value of GeoDistance conditional field.
func (p *PeerSettings) SetGeoDistance(value int) {
	p.Flags.Set(6)
	p.GeoDistance = value
}

// GetGeoDistance returns value of GeoDistance conditional field and
// boolean which is true if field was set.
func (p *PeerSettings) GetGeoDistance() (value int, ok bool) {
	if p == nil {
		return
	}
	if !p.Flags.Has(6) {
		return value, false
	}
	return p.GeoDistance, true
}

// SetRequestChatTitle sets value of RequestChatTitle conditional field.
func (p *PeerSettings) SetRequestChatTitle(value string) {
	p.Flags.Set(9)
	p.RequestChatTitle = value
}

// GetRequestChatTitle returns value of RequestChatTitle conditional field and
// boolean which is true if field was set.
func (p *PeerSettings) GetRequestChatTitle() (value string, ok bool) {
	if p == nil {
		return
	}
	if !p.Flags.Has(9) {
		return value, false
	}
	return p.RequestChatTitle, true
}

// SetRequestChatDate sets value of RequestChatDate conditional field.
func (p *PeerSettings) SetRequestChatDate(value int) {
	p.Flags.Set(9)
	p.RequestChatDate = value
}

// GetRequestChatDate returns value of RequestChatDate conditional field and
// boolean which is true if field was set.
func (p *PeerSettings) GetRequestChatDate() (value int, ok bool) {
	if p == nil {
		return
	}
	if !p.Flags.Has(9) {
		return value, false
	}
	return p.RequestChatDate, true
}

// SetBusinessBotID sets value of BusinessBotID conditional field.
func (p *PeerSettings) SetBusinessBotID(value int64) {
	p.Flags.Set(13)
	p.BusinessBotID = value
}

// GetBusinessBotID returns value of BusinessBotID conditional field and
// boolean which is true if field was set.
func (p *PeerSettings) GetBusinessBotID() (value int64, ok bool) {
	if p == nil {
		return
	}
	if !p.Flags.Has(13) {
		return value, false
	}
	return p.BusinessBotID, true
}

// SetBusinessBotManageURL sets value of BusinessBotManageURL conditional field.
func (p *PeerSettings) SetBusinessBotManageURL(value string) {
	p.Flags.Set(13)
	p.BusinessBotManageURL = value
}

// GetBusinessBotManageURL returns value of BusinessBotManageURL conditional field and
// boolean which is true if field was set.
func (p *PeerSettings) GetBusinessBotManageURL() (value string, ok bool) {
	if p == nil {
		return
	}
	if !p.Flags.Has(13) {
		return value, false
	}
	return p.BusinessBotManageURL, true
}

// SetChargePaidMessageStars sets value of ChargePaidMessageStars conditional field.
func (p *PeerSettings) SetChargePaidMessageStars(value int64) {
	p.Flags.Set(14)
	p.ChargePaidMessageStars = value
}

// GetChargePaidMessageStars returns value of ChargePaidMessageStars conditional field and
// boolean which is true if field was set.
func (p *PeerSettings) GetChargePaidMessageStars() (value int64, ok bool) {
	if p == nil {
		return
	}
	if !p.Flags.Has(14) {
		return value, false
	}
	return p.ChargePaidMessageStars, true
}

// SetRegistrationMonth sets value of RegistrationMonth conditional field.
func (p *PeerSettings) SetRegistrationMonth(value string) {
	p.Flags.Set(15)
	p.RegistrationMonth = value
}

// GetRegistrationMonth returns value of RegistrationMonth conditional field and
// boolean which is true if field was set.
func (p *PeerSettings) GetRegistrationMonth() (value string, ok bool) {
	if p == nil {
		return
	}
	if !p.Flags.Has(15) {
		return value, false
	}
	return p.RegistrationMonth, true
}

// SetPhoneCountry sets value of PhoneCountry conditional field.
func (p *PeerSettings) SetPhoneCountry(value string) {
	p.Flags.Set(16)
	p.PhoneCountry = value
}

// GetPhoneCountry returns value of PhoneCountry conditional field and
// boolean which is true if field was set.
func (p *PeerSettings) GetPhoneCountry() (value string, ok bool) {
	if p == nil {
		return
	}
	if !p.Flags.Has(16) {
		return value, false
	}
	return p.PhoneCountry, true
}

// SetNameChangeDate sets value of NameChangeDate conditional field.
func (p *PeerSettings) SetNameChangeDate(value int) {
	p.Flags.Set(17)
	p.NameChangeDate = value
}

// GetNameChangeDate returns value of NameChangeDate conditional field and
// boolean which is true if field was set.
func (p *PeerSettings) GetNameChangeDate() (value int, ok bool) {
	if p == nil {
		return
	}
	if !p.Flags.Has(17) {
		return value, false
	}
	return p.NameChangeDate, true
}

// SetPhotoChangeDate sets value of PhotoChangeDate conditional field.
func (p *PeerSettings) SetPhotoChangeDate(value int) {
	p.Flags.Set(18)
	p.PhotoChangeDate = value
}

// GetPhotoChangeDate returns value of PhotoChangeDate conditional field and
// boolean which is true if field was set.
func (p *PeerSettings) GetPhotoChangeDate() (value int, ok bool) {
	if p == nil {
		return
	}
	if !p.Flags.Has(18) {
		return value, false
	}
	return p.PhotoChangeDate, true
}
