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

// InputMessageID represents TL type `inputMessageID#a676a322`.
// Message by ID
//
// See https://core.telegram.org/constructor/inputMessageID for reference.
type InputMessageID struct {
	// Message ID
	ID int
}

// InputMessageIDTypeID is TL type id of InputMessageID.
const InputMessageIDTypeID = 0xa676a322

// construct implements constructor of InputMessageClass.
func ( InputMessageID) () InputMessageClass { return & }

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

	_ InputMessageClass = &InputMessageID{}
)

func ( *InputMessageID) () bool {
	if  == nil {
		return true
	}
	if !(.ID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills InputMessageID from given interface.
func ( *InputMessageID) ( interface {
	() ( int)
}) {
	.ID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputMessageID) () tdp.Type {
	 := tdp.Type{
		Name: "inputMessageID",
		ID:   InputMessageIDTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputMessageID) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputMessageID#a676a322 as nil")
	}
	.PutID(InputMessageIDTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputMessageID) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputMessageID#a676a322 as nil")
	}
	.PutInt(.ID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputMessageID) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputMessageID#a676a322 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode inputMessageID#a676a322: field id: %w", )
		}
		.ID = 
	}
	return nil
}

// GetID returns value of ID field.
func ( *InputMessageID) () ( int) {
	if  == nil {
		return
	}
	return .ID
}

// InputMessageReplyTo represents TL type `inputMessageReplyTo#bad88395`.
// Message to which the specified message replies to
//
// See https://core.telegram.org/constructor/inputMessageReplyTo for reference.
type InputMessageReplyTo struct {
	// ID of the message that replies to the message we need
	ID int
}

// InputMessageReplyToTypeID is TL type id of InputMessageReplyTo.
const InputMessageReplyToTypeID = 0xbad88395

// construct implements constructor of InputMessageClass.
func ( InputMessageReplyTo) () InputMessageClass { return & }

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

	_ InputMessageClass = &InputMessageReplyTo{}
)

func ( *InputMessageReplyTo) () bool {
	if  == nil {
		return true
	}
	if !(.ID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills InputMessageReplyTo from given interface.
func ( *InputMessageReplyTo) ( interface {
	() ( int)
}) {
	.ID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputMessageReplyTo) () tdp.Type {
	 := tdp.Type{
		Name: "inputMessageReplyTo",
		ID:   InputMessageReplyToTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputMessageReplyTo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputMessageReplyTo#bad88395 as nil")
	}
	.PutID(InputMessageReplyToTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputMessageReplyTo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputMessageReplyTo#bad88395 as nil")
	}
	.PutInt(.ID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputMessageReplyTo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputMessageReplyTo#bad88395 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode inputMessageReplyTo#bad88395: field id: %w", )
		}
		.ID = 
	}
	return nil
}

// GetID returns value of ID field.
func ( *InputMessageReplyTo) () ( int) {
	if  == nil {
		return
	}
	return .ID
}

// InputMessagePinned represents TL type `inputMessagePinned#86872538`.
// Pinned message
//
// See https://core.telegram.org/constructor/inputMessagePinned for reference.
type InputMessagePinned struct {
}

// InputMessagePinnedTypeID is TL type id of InputMessagePinned.
const InputMessagePinnedTypeID = 0x86872538

// construct implements constructor of InputMessageClass.
func ( InputMessagePinned) () InputMessageClass { return & }

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

	_ InputMessageClass = &InputMessagePinned{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *InputMessagePinned) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputMessagePinned#86872538 as nil")
	}
	.PutID(InputMessagePinnedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputMessagePinned) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputMessagePinned#86872538 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputMessagePinned) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputMessagePinned#86872538 to nil")
	}
	return nil
}

// InputMessageCallbackQuery represents TL type `inputMessageCallbackQuery#acfa1a7e`.
// Used by bots for fetching information about the message that originated a callback
// query
//
// See https://core.telegram.org/constructor/inputMessageCallbackQuery for reference.
type InputMessageCallbackQuery struct {
	// Message ID
	ID int
	// Callback query ID
	QueryID int64
}

// InputMessageCallbackQueryTypeID is TL type id of InputMessageCallbackQuery.
const InputMessageCallbackQueryTypeID = 0xacfa1a7e

// construct implements constructor of InputMessageClass.
func ( InputMessageCallbackQuery) () InputMessageClass { return & }

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

	_ InputMessageClass = &InputMessageCallbackQuery{}
)

func ( *InputMessageCallbackQuery) () bool {
	if  == nil {
		return true
	}
	if !(.ID == 0) {
		return false
	}
	if !(.QueryID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills InputMessageCallbackQuery from given interface.
func ( *InputMessageCallbackQuery) ( interface {
	() ( int)
	() ( int64)
}) {
	.ID = .()
	.QueryID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputMessageCallbackQuery) () tdp.Type {
	 := tdp.Type{
		Name: "inputMessageCallbackQuery",
		ID:   InputMessageCallbackQueryTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "QueryID",
			SchemaName: "query_id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputMessageCallbackQuery) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputMessageCallbackQuery#acfa1a7e as nil")
	}
	.PutID(InputMessageCallbackQueryTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputMessageCallbackQuery) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputMessageCallbackQuery#acfa1a7e as nil")
	}
	.PutInt(.ID)
	.PutLong(.QueryID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputMessageCallbackQuery) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputMessageCallbackQuery#acfa1a7e to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode inputMessageCallbackQuery#acfa1a7e: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputMessageCallbackQuery#acfa1a7e: field query_id: %w", )
		}
		.QueryID = 
	}
	return nil
}

// GetID returns value of ID field.
func ( *InputMessageCallbackQuery) () ( int) {
	if  == nil {
		return
	}
	return .ID
}

// GetQueryID returns value of QueryID field.
func ( *InputMessageCallbackQuery) () ( int64) {
	if  == nil {
		return
	}
	return .QueryID
}

// InputMessageClassName is schema name of InputMessageClass.
const InputMessageClassName = "InputMessage"

// InputMessageClass represents InputMessage generic type.
//
// See https://core.telegram.org/type/InputMessage for reference.
//
// Example:
//
//	g, err := tg.DecodeInputMessage(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.InputMessageID: // inputMessageID#a676a322
//	case *tg.InputMessageReplyTo: // inputMessageReplyTo#bad88395
//	case *tg.InputMessagePinned: // inputMessagePinned#86872538
//	case *tg.InputMessageCallbackQuery: // inputMessageCallbackQuery#acfa1a7e
//	default: panic(v)
//	}
type InputMessageClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() InputMessageClass

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

// DecodeInputMessage implements binary de-serialization for InputMessageClass.
func ( *bin.Buffer) (InputMessageClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case InputMessageIDTypeID:
		// Decoding inputMessageID#a676a322.
		 := InputMessageID{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputMessageClass: %w", )
		}
		return &, nil
	case InputMessageReplyToTypeID:
		// Decoding inputMessageReplyTo#bad88395.
		 := InputMessageReplyTo{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputMessageClass: %w", )
		}
		return &, nil
	case InputMessagePinnedTypeID:
		// Decoding inputMessagePinned#86872538.
		 := InputMessagePinned{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputMessageClass: %w", )
		}
		return &, nil
	case InputMessageCallbackQueryTypeID:
		// Decoding inputMessageCallbackQuery#acfa1a7e.
		 := InputMessageCallbackQuery{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputMessageClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode InputMessageClass: %w", bin.NewUnexpectedID())
	}
}

// InputMessage boxes the InputMessageClass providing a helper.
type InputMessageBox struct {
	InputMessage InputMessageClass
}

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

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