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

// AttachMenuBot represents TL type `attachMenuBot#d90d8dfe`.
// Represents a bot mini app that can be launched from the attachment/side menu »¹
// At least one of the show_in_attach_menu or the show_in_side_menu flags will always be
// set.
//
// Links:
//  1. https://core.telegram.org/api/bots/attach
//
// See https://core.telegram.org/constructor/attachMenuBot for reference.
type AttachMenuBot struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, before launching the mini app the client should ask the user to add the mini
	// app to the attachment/side menu, and only if the user accepts, after invoking messages
	// toggleBotInAttachMenu¹ the app should be opened.
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.toggleBotInAttachMenu
	Inactive bool
	// Deprecated flag, can be ignored.
	HasSettings bool
	// Whether the bot would like to send messages to the user.
	RequestWriteAccess bool
	// Whether, when installed, an attachment menu entry should be shown for the Mini App.
	ShowInAttachMenu bool
	// Whether, when installed, an entry in the main view side menu should be shown for the
	// Mini App.
	ShowInSideMenu bool
	// If inactive if set and the user hasn't previously accepted the third-party mini apps
	// Terms of Service¹ for this bot, when showing the mini app installation prompt, an
	// additional mandatory checkbox to accept the mini apps TOS² and a disclaimer
	// indicating that this Mini App is not affiliated to Telegram should be shown.
	//
	// Links:
	//  1) https://telegram.org/tos/mini-apps
	//  2) https://telegram.org/tos/mini-apps
	SideMenuDisclaimerNeeded bool
	// Bot ID
	BotID int64
	// Attachment menu item name
	ShortName string
	// List of dialog types where this attachment menu entry should be shown
	//
	// Use SetPeerTypes and GetPeerTypes helpers.
	PeerTypes []AttachMenuPeerTypeClass
	// List of platform-specific static icons and animations to use for the attachment menu
	// button
	Icons []AttachMenuBotIcon
}

// AttachMenuBotTypeID is TL type id of AttachMenuBot.
const AttachMenuBotTypeID = 0xd90d8dfe

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

func ( *AttachMenuBot) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Inactive == false) {
		return false
	}
	if !(.HasSettings == false) {
		return false
	}
	if !(.RequestWriteAccess == false) {
		return false
	}
	if !(.ShowInAttachMenu == false) {
		return false
	}
	if !(.ShowInSideMenu == false) {
		return false
	}
	if !(.SideMenuDisclaimerNeeded == false) {
		return false
	}
	if !(.BotID == 0) {
		return false
	}
	if !(.ShortName == "") {
		return false
	}
	if !(.PeerTypes == nil) {
		return false
	}
	if !(.Icons == nil) {
		return false
	}

	return true
}

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

// FillFrom fills AttachMenuBot from given interface.
func ( *AttachMenuBot) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( int64)
	() ( string)
	() ( []AttachMenuPeerTypeClass,  bool)
	() ( []AttachMenuBotIcon)
}) {
	.Inactive = .()
	.HasSettings = .()
	.RequestWriteAccess = .()
	.ShowInAttachMenu = .()
	.ShowInSideMenu = .()
	.SideMenuDisclaimerNeeded = .()
	.BotID = .()
	.ShortName = .()
	if ,  := .();  {
		.PeerTypes = 
	}

	.Icons = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AttachMenuBot) () tdp.Type {
	 := tdp.Type{
		Name: "attachMenuBot",
		ID:   AttachMenuBotTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Inactive",
			SchemaName: "inactive",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "HasSettings",
			SchemaName: "has_settings",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "RequestWriteAccess",
			SchemaName: "request_write_access",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "ShowInAttachMenu",
			SchemaName: "show_in_attach_menu",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "ShowInSideMenu",
			SchemaName: "show_in_side_menu",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "SideMenuDisclaimerNeeded",
			SchemaName: "side_menu_disclaimer_needed",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "BotID",
			SchemaName: "bot_id",
		},
		{
			Name:       "ShortName",
			SchemaName: "short_name",
		},
		{
			Name:       "PeerTypes",
			SchemaName: "peer_types",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "Icons",
			SchemaName: "icons",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AttachMenuBot) () {
	if !(.Inactive == false) {
		.Flags.Set(0)
	}
	if !(.HasSettings == false) {
		.Flags.Set(1)
	}
	if !(.RequestWriteAccess == false) {
		.Flags.Set(2)
	}
	if !(.ShowInAttachMenu == false) {
		.Flags.Set(3)
	}
	if !(.ShowInSideMenu == false) {
		.Flags.Set(4)
	}
	if !(.SideMenuDisclaimerNeeded == false) {
		.Flags.Set(5)
	}
	if !(.PeerTypes == nil) {
		.Flags.Set(3)
	}
}

// Encode implements bin.Encoder.
func ( *AttachMenuBot) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode attachMenuBot#d90d8dfe as nil")
	}
	.PutID(AttachMenuBotTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AttachMenuBot) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode attachMenuBot#d90d8dfe as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode attachMenuBot#d90d8dfe: field flags: %w", )
	}
	.PutLong(.BotID)
	.PutString(.ShortName)
	if .Flags.Has(3) {
		.PutVectorHeader(len(.PeerTypes))
		for ,  := range .PeerTypes {
			if  == nil {
				return fmt.Errorf("unable to encode attachMenuBot#d90d8dfe: field peer_types element with index %d is nil", )
			}
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode attachMenuBot#d90d8dfe: field peer_types element with index %d: %w", , )
			}
		}
	}
	.PutVectorHeader(len(.Icons))
	for ,  := range .Icons {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode attachMenuBot#d90d8dfe: field icons element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AttachMenuBot) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode attachMenuBot#d90d8dfe to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode attachMenuBot#d90d8dfe: field flags: %w", )
		}
	}
	.Inactive = .Flags.Has(0)
	.HasSettings = .Flags.Has(1)
	.RequestWriteAccess = .Flags.Has(2)
	.ShowInAttachMenu = .Flags.Has(3)
	.ShowInSideMenu = .Flags.Has(4)
	.SideMenuDisclaimerNeeded = .Flags.Has(5)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode attachMenuBot#d90d8dfe: field bot_id: %w", )
		}
		.BotID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode attachMenuBot#d90d8dfe: field short_name: %w", )
		}
		.ShortName = 
	}
	if .Flags.Has(3) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode attachMenuBot#d90d8dfe: field peer_types: %w", )
		}

		if  > 0 {
			.PeerTypes = make([]AttachMenuPeerTypeClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeAttachMenuPeerType()
			if  != nil {
				return fmt.Errorf("unable to decode attachMenuBot#d90d8dfe: field peer_types: %w", )
			}
			.PeerTypes = append(.PeerTypes, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode attachMenuBot#d90d8dfe: field icons: %w", )
		}

		if  > 0 {
			.Icons = make([]AttachMenuBotIcon, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  AttachMenuBotIcon
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode attachMenuBot#d90d8dfe: field icons: %w", )
			}
			.Icons = append(.Icons, )
		}
	}
	return nil
}

// SetInactive sets value of Inactive conditional field.
func ( *AttachMenuBot) ( bool) {
	if  {
		.Flags.Set(0)
		.Inactive = true
	} else {
		.Flags.Unset(0)
		.Inactive = false
	}
}

// GetInactive returns value of Inactive conditional field.
func ( *AttachMenuBot) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetHasSettings sets value of HasSettings conditional field.
func ( *AttachMenuBot) ( bool) {
	if  {
		.Flags.Set(1)
		.HasSettings = true
	} else {
		.Flags.Unset(1)
		.HasSettings = false
	}
}

// GetHasSettings returns value of HasSettings conditional field.
func ( *AttachMenuBot) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetRequestWriteAccess sets value of RequestWriteAccess conditional field.
func ( *AttachMenuBot) ( bool) {
	if  {
		.Flags.Set(2)
		.RequestWriteAccess = true
	} else {
		.Flags.Unset(2)
		.RequestWriteAccess = false
	}
}

// GetRequestWriteAccess returns value of RequestWriteAccess conditional field.
func ( *AttachMenuBot) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// SetShowInAttachMenu sets value of ShowInAttachMenu conditional field.
func ( *AttachMenuBot) ( bool) {
	if  {
		.Flags.Set(3)
		.ShowInAttachMenu = true
	} else {
		.Flags.Unset(3)
		.ShowInAttachMenu = false
	}
}

// GetShowInAttachMenu returns value of ShowInAttachMenu conditional field.
func ( *AttachMenuBot) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// SetShowInSideMenu sets value of ShowInSideMenu conditional field.
func ( *AttachMenuBot) ( bool) {
	if  {
		.Flags.Set(4)
		.ShowInSideMenu = true
	} else {
		.Flags.Unset(4)
		.ShowInSideMenu = false
	}
}

// GetShowInSideMenu returns value of ShowInSideMenu conditional field.
func ( *AttachMenuBot) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(4)
}

// SetSideMenuDisclaimerNeeded sets value of SideMenuDisclaimerNeeded conditional field.
func ( *AttachMenuBot) ( bool) {
	if  {
		.Flags.Set(5)
		.SideMenuDisclaimerNeeded = true
	} else {
		.Flags.Unset(5)
		.SideMenuDisclaimerNeeded = false
	}
}

// GetSideMenuDisclaimerNeeded returns value of SideMenuDisclaimerNeeded conditional field.
func ( *AttachMenuBot) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(5)
}

// GetBotID returns value of BotID field.
func ( *AttachMenuBot) () ( int64) {
	if  == nil {
		return
	}
	return .BotID
}

// GetShortName returns value of ShortName field.
func ( *AttachMenuBot) () ( string) {
	if  == nil {
		return
	}
	return .ShortName
}

// SetPeerTypes sets value of PeerTypes conditional field.
func ( *AttachMenuBot) ( []AttachMenuPeerTypeClass) {
	.Flags.Set(3)
	.PeerTypes = 
}

// GetPeerTypes returns value of PeerTypes conditional field and
// boolean which is true if field was set.
func ( *AttachMenuBot) () ( []AttachMenuPeerTypeClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .PeerTypes, true
}

// GetIcons returns value of Icons field.
func ( *AttachMenuBot) () ( []AttachMenuBotIcon) {
	if  == nil {
		return
	}
	return .Icons
}

// MapPeerTypes returns field PeerTypes wrapped in AttachMenuPeerTypeClassArray helper.
func ( *AttachMenuBot) () ( AttachMenuPeerTypeClassArray,  bool) {
	if !.Flags.Has(3) {
		return , false
	}
	return AttachMenuPeerTypeClassArray(.PeerTypes), true
}