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

// MessagesSetTypingRequest represents TL type `messages.setTyping#58943ee2`.
// Sends a current user typing event (see SendMessageAction¹ for all event types) to a
// conversation partner or group.
//
// Links:
//  1. https://core.telegram.org/type/SendMessageAction
//
// See https://core.telegram.org/method/messages.setTyping for reference.
type MessagesSetTypingRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Target user or group
	Peer InputPeerClass
	// Topic ID¹
	//
	// Links:
	//  1) https://core.telegram.org/api/threads
	//
	// Use SetTopMsgID and GetTopMsgID helpers.
	TopMsgID int
	// Type of action
	Action SendMessageActionClass
}

// MessagesSetTypingRequestTypeID is TL type id of MessagesSetTypingRequest.
const MessagesSetTypingRequestTypeID = 0x58943ee2

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

func ( *MessagesSetTypingRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.TopMsgID == 0) {
		return false
	}
	if !(.Action == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSetTypingRequest from given interface.
func ( *MessagesSetTypingRequest) ( interface {
	() ( InputPeerClass)
	() ( int,  bool)
	() ( SendMessageActionClass)
}) {
	.Peer = .()
	if ,  := .();  {
		.TopMsgID = 
	}

	.Action = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesSetTypingRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.setTyping",
		ID:   MessagesSetTypingRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "TopMsgID",
			SchemaName: "top_msg_id",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Action",
			SchemaName: "action",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesSetTypingRequest) () {
	if !(.TopMsgID == 0) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesSetTypingRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.setTyping#58943ee2 as nil")
	}
	.PutID(MessagesSetTypingRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSetTypingRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.setTyping#58943ee2 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.setTyping#58943ee2: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.setTyping#58943ee2: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.setTyping#58943ee2: field peer: %w", )
	}
	if .Flags.Has(0) {
		.PutInt(.TopMsgID)
	}
	if .Action == nil {
		return fmt.Errorf("unable to encode messages.setTyping#58943ee2: field action is nil")
	}
	if  := .Action.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.setTyping#58943ee2: field action: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSetTypingRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.setTyping#58943ee2 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.setTyping#58943ee2: field flags: %w", )
		}
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setTyping#58943ee2: field peer: %w", )
		}
		.Peer = 
	}
	if .Flags.Has(0) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setTyping#58943ee2: field top_msg_id: %w", )
		}
		.TopMsgID = 
	}
	{
		,  := DecodeSendMessageAction()
		if  != nil {
			return fmt.Errorf("unable to decode messages.setTyping#58943ee2: field action: %w", )
		}
		.Action = 
	}
	return nil
}

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

// SetTopMsgID sets value of TopMsgID conditional field.
func ( *MessagesSetTypingRequest) ( int) {
	.Flags.Set(0)
	.TopMsgID = 
}

// GetTopMsgID returns value of TopMsgID conditional field and
// boolean which is true if field was set.
func ( *MessagesSetTypingRequest) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .TopMsgID, true
}

// GetAction returns value of Action field.
func ( *MessagesSetTypingRequest) () ( SendMessageActionClass) {
	if  == nil {
		return
	}
	return .Action
}

// MessagesSetTyping invokes method messages.setTyping#58943ee2 returning error if any.
// Sends a current user typing event (see SendMessageAction¹ for all event types) to a
// conversation partner or group.
//
// Links:
//  1. https://core.telegram.org/type/SendMessageAction
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	406 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	400 CHAT_ADMIN_REQUIRED: You must be an admin in this chat to do this.
//	400 CHAT_ID_INVALID: The provided chat id is invalid.
//	403 CHAT_WRITE_FORBIDDEN: You can't write in this chat.
//	403 GROUPCALL_FORBIDDEN: The group call has already ended.
//	400 INPUT_USER_DEACTIVATED: The specified user was deleted.
//	400 MSG_ID_INVALID: Invalid message ID provided.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 USER_BANNED_IN_CHANNEL: You're banned from sending messages in supergroups/channels.
//	403 USER_IS_BLOCKED: You were blocked by this user.
//	400 USER_IS_BOT: Bots can't send messages to other bots.
//
// See https://core.telegram.org/method/messages.setTyping for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *MessagesSetTypingRequest) (bool, error) {
	var  BoolBox

	if  := .rpc.Invoke(, , &);  != nil {
		return false, 
	}
	,  := .Bool.(*BoolTrue)
	return , nil
}