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

// BotMenuButtonDefault represents TL type `botMenuButtonDefault#7533a588`.
// Placeholder bot menu button¹ never returned to users: see the docs for more info².
//
// Links:
//  1. https://core.telegram.org/api/bots/menu
//  2. https://core.telegram.org/api/bots/menu
//
// See https://core.telegram.org/constructor/botMenuButtonDefault for reference.
type BotMenuButtonDefault struct {
}

// BotMenuButtonDefaultTypeID is TL type id of BotMenuButtonDefault.
const BotMenuButtonDefaultTypeID = 0x7533a588

// construct implements constructor of BotMenuButtonClass.
func ( BotMenuButtonDefault) () BotMenuButtonClass { return & }

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

	_ BotMenuButtonClass = &BotMenuButtonDefault{}
)

func ( *BotMenuButtonDefault) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *BotMenuButtonDefault) () tdp.Type {
	 := tdp.Type{
		Name: "botMenuButtonDefault",
		ID:   BotMenuButtonDefaultTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *BotMenuButtonDefault) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode botMenuButtonDefault#7533a588 as nil")
	}
	.PutID(BotMenuButtonDefaultTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BotMenuButtonDefault) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode botMenuButtonDefault#7533a588 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *BotMenuButtonDefault) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode botMenuButtonDefault#7533a588 to nil")
	}
	return nil
}

// BotMenuButtonCommands represents TL type `botMenuButtonCommands#4258c205`.
// Bot menu button¹ that opens the bot command list when clicked.
//
// Links:
//  1. https://core.telegram.org/api/bots/menu
//
// See https://core.telegram.org/constructor/botMenuButtonCommands for reference.
type BotMenuButtonCommands struct {
}

// BotMenuButtonCommandsTypeID is TL type id of BotMenuButtonCommands.
const BotMenuButtonCommandsTypeID = 0x4258c205

// construct implements constructor of BotMenuButtonClass.
func ( BotMenuButtonCommands) () BotMenuButtonClass { return & }

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

	_ BotMenuButtonClass = &BotMenuButtonCommands{}
)

func ( *BotMenuButtonCommands) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *BotMenuButtonCommands) () tdp.Type {
	 := tdp.Type{
		Name: "botMenuButtonCommands",
		ID:   BotMenuButtonCommandsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *BotMenuButtonCommands) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode botMenuButtonCommands#4258c205 as nil")
	}
	.PutID(BotMenuButtonCommandsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BotMenuButtonCommands) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode botMenuButtonCommands#4258c205 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *BotMenuButtonCommands) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode botMenuButtonCommands#4258c205 to nil")
	}
	return nil
}

// BotMenuButton represents TL type `botMenuButton#c7b57ce6`.
// Bot menu button¹ that opens a web app² when clicked.
//
// Links:
//  1. https://core.telegram.org/api/bots/menu
//  2. https://core.telegram.org/api/bots/webapps
//
// See https://core.telegram.org/constructor/botMenuButton for reference.
type BotMenuButton struct {
	// Title to be displayed on the menu button instead of 'Menu'
	Text string
	// URL of a web app¹ to open when the user clicks on the button
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/webapps
	URL string
}

// BotMenuButtonTypeID is TL type id of BotMenuButton.
const BotMenuButtonTypeID = 0xc7b57ce6

// construct implements constructor of BotMenuButtonClass.
func ( BotMenuButton) () BotMenuButtonClass { return & }

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

	_ BotMenuButtonClass = &BotMenuButton{}
)

func ( *BotMenuButton) () bool {
	if  == nil {
		return true
	}
	if !(.Text == "") {
		return false
	}
	if !(.URL == "") {
		return false
	}

	return true
}

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

// FillFrom fills BotMenuButton from given interface.
func ( *BotMenuButton) ( interface {
	() ( string)
	() ( string)
}) {
	.Text = .()
	.URL = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *BotMenuButton) () tdp.Type {
	 := tdp.Type{
		Name: "botMenuButton",
		ID:   BotMenuButtonTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Text",
			SchemaName: "text",
		},
		{
			Name:       "URL",
			SchemaName: "url",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *BotMenuButton) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode botMenuButton#c7b57ce6 as nil")
	}
	.PutID(BotMenuButtonTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BotMenuButton) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode botMenuButton#c7b57ce6 as nil")
	}
	.PutString(.Text)
	.PutString(.URL)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *BotMenuButton) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode botMenuButton#c7b57ce6 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode botMenuButton#c7b57ce6: field text: %w", )
		}
		.Text = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode botMenuButton#c7b57ce6: field url: %w", )
		}
		.URL = 
	}
	return nil
}

// GetText returns value of Text field.
func ( *BotMenuButton) () ( string) {
	if  == nil {
		return
	}
	return .Text
}

// GetURL returns value of URL field.
func ( *BotMenuButton) () ( string) {
	if  == nil {
		return
	}
	return .URL
}

// BotMenuButtonClassName is schema name of BotMenuButtonClass.
const BotMenuButtonClassName = "BotMenuButton"

// BotMenuButtonClass represents BotMenuButton generic type.
//
// See https://core.telegram.org/type/BotMenuButton for reference.
//
// Example:
//
//	g, err := tg.DecodeBotMenuButton(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.BotMenuButtonDefault: // botMenuButtonDefault#7533a588
//	case *tg.BotMenuButtonCommands: // botMenuButtonCommands#4258c205
//	case *tg.BotMenuButton: // botMenuButton#c7b57ce6
//	default: panic(v)
//	}
type BotMenuButtonClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() BotMenuButtonClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool
}

// DecodeBotMenuButton implements binary de-serialization for BotMenuButtonClass.
func ( *bin.Buffer) (BotMenuButtonClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case BotMenuButtonDefaultTypeID:
		// Decoding botMenuButtonDefault#7533a588.
		 := BotMenuButtonDefault{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode BotMenuButtonClass: %w", )
		}
		return &, nil
	case BotMenuButtonCommandsTypeID:
		// Decoding botMenuButtonCommands#4258c205.
		 := BotMenuButtonCommands{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode BotMenuButtonClass: %w", )
		}
		return &, nil
	case BotMenuButtonTypeID:
		// Decoding botMenuButton#c7b57ce6.
		 := BotMenuButton{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode BotMenuButtonClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode BotMenuButtonClass: %w", bin.NewUnexpectedID())
	}
}

// BotMenuButton boxes the BotMenuButtonClass providing a helper.
type BotMenuButtonBox struct {
	BotMenuButton BotMenuButtonClass
}

// Decode implements bin.Decoder for BotMenuButtonBox.
func ( *BotMenuButtonBox) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("unable to decode BotMenuButtonBox to nil")
	}
	,  := DecodeBotMenuButton()
	if  != nil {
		return fmt.Errorf("unable to decode boxed value: %w", )
	}
	.BotMenuButton = 
	return nil
}

// Encode implements bin.Encode for BotMenuButtonBox.
func ( *BotMenuButtonBox) ( *bin.Buffer) error {
	if  == nil || .BotMenuButton == nil {
		return fmt.Errorf("unable to encode BotMenuButtonClass as nil")
	}
	return .BotMenuButton.Encode()
}