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

// MessagesSendReactionRequest represents TL type `messages.sendReaction#d30d78d4`.
// React to message.
// Starting from layer 159, the reaction will be sent from the peer specified using
// messages.saveDefaultSendAs¹.
//
// Links:
//  1. https://core.telegram.org/method/messages.saveDefaultSendAs
//
// See https://core.telegram.org/method/messages.sendReaction for reference.
type MessagesSendReactionRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether a bigger and longer reaction should be shown
	Big bool
	// Whether to add this reaction to the recent reactions list »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/reactions#recent-reactions
	AddToRecent bool
	// Peer
	Peer InputPeerClass
	// Message ID to react to
	MsgID int
	// A list of reactions
	//
	// Use SetReaction and GetReaction helpers.
	Reaction []ReactionClass
}

// MessagesSendReactionRequestTypeID is TL type id of MessagesSendReactionRequest.
const MessagesSendReactionRequestTypeID = 0xd30d78d4

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

func ( *MessagesSendReactionRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Big == false) {
		return false
	}
	if !(.AddToRecent == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.MsgID == 0) {
		return false
	}
	if !(.Reaction == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSendReactionRequest from given interface.
func ( *MessagesSendReactionRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( InputPeerClass)
	() ( int)
	() ( []ReactionClass,  bool)
}) {
	.Big = .()
	.AddToRecent = .()
	.Peer = .()
	.MsgID = .()
	if ,  := .();  {
		.Reaction = 
	}

}

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

// TypeName returns name of type in TL schema.
func (*MessagesSendReactionRequest) () string {
	return "messages.sendReaction"
}

// TypeInfo returns info about TL type.
func ( *MessagesSendReactionRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.sendReaction",
		ID:   MessagesSendReactionRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Big",
			SchemaName: "big",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "AddToRecent",
			SchemaName: "add_to_recent",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "MsgID",
			SchemaName: "msg_id",
		},
		{
			Name:       "Reaction",
			SchemaName: "reaction",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesSendReactionRequest) () {
	if !(.Big == false) {
		.Flags.Set(1)
	}
	if !(.AddToRecent == false) {
		.Flags.Set(2)
	}
	if !(.Reaction == nil) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesSendReactionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.sendReaction#d30d78d4 as nil")
	}
	.PutID(MessagesSendReactionRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSendReactionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.sendReaction#d30d78d4 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.sendReaction#d30d78d4: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.sendReaction#d30d78d4: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.sendReaction#d30d78d4: field peer: %w", )
	}
	.PutInt(.MsgID)
	if .Flags.Has(0) {
		.PutVectorHeader(len(.Reaction))
		for ,  := range .Reaction {
			if  == nil {
				return fmt.Errorf("unable to encode messages.sendReaction#d30d78d4: field reaction element with index %d is nil", )
			}
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode messages.sendReaction#d30d78d4: field reaction element with index %d: %w", , )
			}
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSendReactionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.sendReaction#d30d78d4 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.sendReaction#d30d78d4: field flags: %w", )
		}
	}
	.Big = .Flags.Has(1)
	.AddToRecent = .Flags.Has(2)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendReaction#d30d78d4: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendReaction#d30d78d4: field msg_id: %w", )
		}
		.MsgID = 
	}
	if .Flags.Has(0) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendReaction#d30d78d4: field reaction: %w", )
		}

		if  > 0 {
			.Reaction = make([]ReactionClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeReaction()
			if  != nil {
				return fmt.Errorf("unable to decode messages.sendReaction#d30d78d4: field reaction: %w", )
			}
			.Reaction = append(.Reaction, )
		}
	}
	return nil
}

// SetBig sets value of Big conditional field.
func ( *MessagesSendReactionRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.Big = true
	} else {
		.Flags.Unset(1)
		.Big = false
	}
}

// GetBig returns value of Big conditional field.
func ( *MessagesSendReactionRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetAddToRecent sets value of AddToRecent conditional field.
func ( *MessagesSendReactionRequest) ( bool) {
	if  {
		.Flags.Set(2)
		.AddToRecent = true
	} else {
		.Flags.Unset(2)
		.AddToRecent = false
	}
}

// GetAddToRecent returns value of AddToRecent conditional field.
func ( *MessagesSendReactionRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// GetPeer returns value of Peer field.
func ( *MessagesSendReactionRequest) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

// GetMsgID returns value of MsgID field.
func ( *MessagesSendReactionRequest) () ( int) {
	if  == nil {
		return
	}
	return .MsgID
}

// SetReaction sets value of Reaction conditional field.
func ( *MessagesSendReactionRequest) ( []ReactionClass) {
	.Flags.Set(0)
	.Reaction = 
}

// GetReaction returns value of Reaction conditional field and
// boolean which is true if field was set.
func ( *MessagesSendReactionRequest) () ( []ReactionClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Reaction, true
}

// MapReaction returns field Reaction wrapped in ReactionClassArray helper.
func ( *MessagesSendReactionRequest) () ( ReactionClassArray,  bool) {
	if !.Flags.Has(0) {
		return , false
	}
	return ReactionClassArray(.Reaction), true
}

// MessagesSendReaction invokes method messages.sendReaction#d30d78d4 returning error if any.
// React to message.
// Starting from layer 159, the reaction will be sent from the peer specified using
// messages.saveDefaultSendAs¹.
//
// Links:
//  1. https://core.telegram.org/method/messages.saveDefaultSendAs
//
// Possible errors:
//
//	403 ANONYMOUS_REACTIONS_DISABLED:
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	400 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	403 CHAT_WRITE_FORBIDDEN: You can't write in this chat.
//	400 CUSTOM_REACTIONS_TOO_MANY: Too many custom reactions were specified.
//	400 MESSAGE_ID_INVALID: The provided message id is invalid.
//	400 MESSAGE_NOT_MODIFIED: The provided message data is identical to the previous message data, the message wasn't modified.
//	400 MSG_ID_INVALID: Invalid message ID provided.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	403 PREMIUM_ACCOUNT_REQUIRED: A premium account is required to execute this action.
//	400 REACTIONS_TOO_MANY: The message already has exactly reactions_uniq_max reaction emojis, you can't react with a new emoji, see the docs for more info ».
//	400 REACTION_EMPTY: Empty reaction provided.
//	400 REACTION_INVALID: The specified reaction is invalid.
//	400 USER_BANNED_IN_CHANNEL: You're banned from sending messages in supergroups/channels.
//
// See https://core.telegram.org/method/messages.sendReaction for reference.
func ( *Client) ( context.Context,  *MessagesSendReactionRequest) (UpdatesClass, error) {
	var  UpdatesBox

	if  := .rpc.Invoke(, , &);  != nil {
		return nil, 
	}
	return .Updates, nil
}