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

// BotInfo represents TL type `botInfo#8f300b57`.
// Info about bots (available bot commands, etc)
//
// See https://core.telegram.org/constructor/botInfo for reference.
type BotInfo struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// ID of the bot
	//
	// Use SetUserID and GetUserID helpers.
	UserID int64
	// Description of the bot
	//
	// Use SetDescription and GetDescription helpers.
	Description string
	// Description photo
	//
	// Use SetDescriptionPhoto and GetDescriptionPhoto helpers.
	DescriptionPhoto PhotoClass
	// Description animation in MPEG4 format
	//
	// Use SetDescriptionDocument and GetDescriptionDocument helpers.
	DescriptionDocument DocumentClass
	// Bot commands that can be used in the chat
	//
	// Use SetCommands and GetCommands helpers.
	Commands []BotCommand
	// Indicates the action to execute when pressing the in-UI menu button for bots
	//
	// Use SetMenuButton and GetMenuButton helpers.
	MenuButton BotMenuButtonClass
}

// BotInfoTypeID is TL type id of BotInfo.
const BotInfoTypeID = 0x8f300b57

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

func ( *BotInfo) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.UserID == 0) {
		return false
	}
	if !(.Description == "") {
		return false
	}
	if !(.DescriptionPhoto == nil) {
		return false
	}
	if !(.DescriptionDocument == nil) {
		return false
	}
	if !(.Commands == nil) {
		return false
	}
	if !(.MenuButton == nil) {
		return false
	}

	return true
}

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

// FillFrom fills BotInfo from given interface.
func ( *BotInfo) ( interface {
	() ( int64,  bool)
	() ( string,  bool)
	() ( PhotoClass,  bool)
	() ( DocumentClass,  bool)
	() ( []BotCommand,  bool)
	() ( BotMenuButtonClass,  bool)
}) {
	if ,  := .();  {
		.UserID = 
	}

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

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

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

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

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

}

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

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

// TypeInfo returns info about TL type.
func ( *BotInfo) () tdp.Type {
	 := tdp.Type{
		Name: "botInfo",
		ID:   BotInfoTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Description",
			SchemaName: "description",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "DescriptionPhoto",
			SchemaName: "description_photo",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "DescriptionDocument",
			SchemaName: "description_document",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "Commands",
			SchemaName: "commands",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "MenuButton",
			SchemaName: "menu_button",
			Null:       !.Flags.Has(3),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *BotInfo) () {
	if !(.UserID == 0) {
		.Flags.Set(0)
	}
	if !(.Description == "") {
		.Flags.Set(1)
	}
	if !(.DescriptionPhoto == nil) {
		.Flags.Set(4)
	}
	if !(.DescriptionDocument == nil) {
		.Flags.Set(5)
	}
	if !(.Commands == nil) {
		.Flags.Set(2)
	}
	if !(.MenuButton == nil) {
		.Flags.Set(3)
	}
}

// Encode implements bin.Encoder.
func ( *BotInfo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode botInfo#8f300b57 as nil")
	}
	.PutID(BotInfoTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BotInfo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode botInfo#8f300b57 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode botInfo#8f300b57: field flags: %w", )
	}
	if .Flags.Has(0) {
		.PutLong(.UserID)
	}
	if .Flags.Has(1) {
		.PutString(.Description)
	}
	if .Flags.Has(4) {
		if .DescriptionPhoto == nil {
			return fmt.Errorf("unable to encode botInfo#8f300b57: field description_photo is nil")
		}
		if  := .DescriptionPhoto.Encode();  != nil {
			return fmt.Errorf("unable to encode botInfo#8f300b57: field description_photo: %w", )
		}
	}
	if .Flags.Has(5) {
		if .DescriptionDocument == nil {
			return fmt.Errorf("unable to encode botInfo#8f300b57: field description_document is nil")
		}
		if  := .DescriptionDocument.Encode();  != nil {
			return fmt.Errorf("unable to encode botInfo#8f300b57: field description_document: %w", )
		}
	}
	if .Flags.Has(2) {
		.PutVectorHeader(len(.Commands))
		for ,  := range .Commands {
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode botInfo#8f300b57: field commands element with index %d: %w", , )
			}
		}
	}
	if .Flags.Has(3) {
		if .MenuButton == nil {
			return fmt.Errorf("unable to encode botInfo#8f300b57: field menu_button is nil")
		}
		if  := .MenuButton.Encode();  != nil {
			return fmt.Errorf("unable to encode botInfo#8f300b57: field menu_button: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *BotInfo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode botInfo#8f300b57 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode botInfo#8f300b57: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode botInfo#8f300b57: field user_id: %w", )
		}
		.UserID = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode botInfo#8f300b57: field description: %w", )
		}
		.Description = 
	}
	if .Flags.Has(4) {
		,  := DecodePhoto()
		if  != nil {
			return fmt.Errorf("unable to decode botInfo#8f300b57: field description_photo: %w", )
		}
		.DescriptionPhoto = 
	}
	if .Flags.Has(5) {
		,  := DecodeDocument()
		if  != nil {
			return fmt.Errorf("unable to decode botInfo#8f300b57: field description_document: %w", )
		}
		.DescriptionDocument = 
	}
	if .Flags.Has(2) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode botInfo#8f300b57: field commands: %w", )
		}

		if  > 0 {
			.Commands = make([]BotCommand, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  BotCommand
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode botInfo#8f300b57: field commands: %w", )
			}
			.Commands = append(.Commands, )
		}
	}
	if .Flags.Has(3) {
		,  := DecodeBotMenuButton()
		if  != nil {
			return fmt.Errorf("unable to decode botInfo#8f300b57: field menu_button: %w", )
		}
		.MenuButton = 
	}
	return nil
}

// SetUserID sets value of UserID conditional field.
func ( *BotInfo) ( int64) {
	.Flags.Set(0)
	.UserID = 
}

// GetUserID returns value of UserID conditional field and
// boolean which is true if field was set.
func ( *BotInfo) () ( int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .UserID, true
}

// SetDescription sets value of Description conditional field.
func ( *BotInfo) ( string) {
	.Flags.Set(1)
	.Description = 
}

// GetDescription returns value of Description conditional field and
// boolean which is true if field was set.
func ( *BotInfo) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Description, true
}

// SetDescriptionPhoto sets value of DescriptionPhoto conditional field.
func ( *BotInfo) ( PhotoClass) {
	.Flags.Set(4)
	.DescriptionPhoto = 
}

// GetDescriptionPhoto returns value of DescriptionPhoto conditional field and
// boolean which is true if field was set.
func ( *BotInfo) () ( PhotoClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(4) {
		return , false
	}
	return .DescriptionPhoto, true
}

// SetDescriptionDocument sets value of DescriptionDocument conditional field.
func ( *BotInfo) ( DocumentClass) {
	.Flags.Set(5)
	.DescriptionDocument = 
}

// GetDescriptionDocument returns value of DescriptionDocument conditional field and
// boolean which is true if field was set.
func ( *BotInfo) () ( DocumentClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(5) {
		return , false
	}
	return .DescriptionDocument, true
}

// SetCommands sets value of Commands conditional field.
func ( *BotInfo) ( []BotCommand) {
	.Flags.Set(2)
	.Commands = 
}

// GetCommands returns value of Commands conditional field and
// boolean which is true if field was set.
func ( *BotInfo) () ( []BotCommand,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .Commands, true
}

// SetMenuButton sets value of MenuButton conditional field.
func ( *BotInfo) ( BotMenuButtonClass) {
	.Flags.Set(3)
	.MenuButton = 
}

// GetMenuButton returns value of MenuButton conditional field and
// boolean which is true if field was set.
func ( *BotInfo) () ( BotMenuButtonClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .MenuButton, true
}

// GetDescriptionPhotoAsNotEmpty returns mapped value of DescriptionPhoto conditional field and
// boolean which is true if field was set.
func ( *BotInfo) () (*Photo, bool) {
	if ,  := .GetDescriptionPhoto();  {
		return .AsNotEmpty()
	}
	return nil, false
}

// GetDescriptionDocumentAsNotEmpty returns mapped value of DescriptionDocument conditional field and
// boolean which is true if field was set.
func ( *BotInfo) () (*Document, bool) {
	if ,  := .GetDescriptionDocument();  {
		return .AsNotEmpty()
	}
	return nil, false
}