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

// MessagePeerReaction represents TL type `messagePeerReaction#8c79b63c`.
// How a certain peer reacted to the message
//
// See https://core.telegram.org/constructor/messagePeerReaction for reference.
type MessagePeerReaction struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the specified message reaction »¹ should elicit a bigger and longer reaction
	//
	// Links:
	//  1) https://core.telegram.org/api/reactions
	Big bool
	// Whether the reaction wasn't yet marked as read by the current user
	Unread bool
	// Starting from layer 159, messages.sendReaction¹ will send reactions from the peer
	// (user or channel) specified using messages.saveDefaultSendAs². If set, this flag
	// indicates that this reaction was sent by us, even if the peer doesn't point to the
	// current account.
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.sendReaction
	//  2) https://core.telegram.org/method/messages.saveDefaultSendAs
	My bool
	// Peer that reacted to the message
	PeerID PeerClass
	// When was this reaction added
	Date int
	// Reaction emoji
	Reaction ReactionClass
}

// MessagePeerReactionTypeID is TL type id of MessagePeerReaction.
const MessagePeerReactionTypeID = 0x8c79b63c

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

func ( *MessagePeerReaction) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Big == false) {
		return false
	}
	if !(.Unread == false) {
		return false
	}
	if !(.My == false) {
		return false
	}
	if !(.PeerID == nil) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.Reaction == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagePeerReaction from given interface.
func ( *MessagePeerReaction) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( PeerClass)
	() ( int)
	() ( ReactionClass)
}) {
	.Big = .()
	.Unread = .()
	.My = .()
	.PeerID = .()
	.Date = .()
	.Reaction = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagePeerReaction) () tdp.Type {
	 := tdp.Type{
		Name: "messagePeerReaction",
		ID:   MessagePeerReactionTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Big",
			SchemaName: "big",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Unread",
			SchemaName: "unread",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "My",
			SchemaName: "my",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "PeerID",
			SchemaName: "peer_id",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "Reaction",
			SchemaName: "reaction",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagePeerReaction) () {
	if !(.Big == false) {
		.Flags.Set(0)
	}
	if !(.Unread == false) {
		.Flags.Set(1)
	}
	if !(.My == false) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *MessagePeerReaction) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messagePeerReaction#8c79b63c as nil")
	}
	.PutID(MessagePeerReactionTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagePeerReaction) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messagePeerReaction#8c79b63c as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messagePeerReaction#8c79b63c: field flags: %w", )
	}
	if .PeerID == nil {
		return fmt.Errorf("unable to encode messagePeerReaction#8c79b63c: field peer_id is nil")
	}
	if  := .PeerID.Encode();  != nil {
		return fmt.Errorf("unable to encode messagePeerReaction#8c79b63c: field peer_id: %w", )
	}
	.PutInt(.Date)
	if .Reaction == nil {
		return fmt.Errorf("unable to encode messagePeerReaction#8c79b63c: field reaction is nil")
	}
	if  := .Reaction.Encode();  != nil {
		return fmt.Errorf("unable to encode messagePeerReaction#8c79b63c: field reaction: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagePeerReaction) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messagePeerReaction#8c79b63c to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messagePeerReaction#8c79b63c: field flags: %w", )
		}
	}
	.Big = .Flags.Has(0)
	.Unread = .Flags.Has(1)
	.My = .Flags.Has(2)
	{
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode messagePeerReaction#8c79b63c: field peer_id: %w", )
		}
		.PeerID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messagePeerReaction#8c79b63c: field date: %w", )
		}
		.Date = 
	}
	{
		,  := DecodeReaction()
		if  != nil {
			return fmt.Errorf("unable to decode messagePeerReaction#8c79b63c: field reaction: %w", )
		}
		.Reaction = 
	}
	return nil
}

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

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

// SetUnread sets value of Unread conditional field.
func ( *MessagePeerReaction) ( bool) {
	if  {
		.Flags.Set(1)
		.Unread = true
	} else {
		.Flags.Unset(1)
		.Unread = false
	}
}

// GetUnread returns value of Unread conditional field.
func ( *MessagePeerReaction) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetMy sets value of My conditional field.
func ( *MessagePeerReaction) ( bool) {
	if  {
		.Flags.Set(2)
		.My = true
	} else {
		.Flags.Unset(2)
		.My = false
	}
}

// GetMy returns value of My conditional field.
func ( *MessagePeerReaction) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// GetPeerID returns value of PeerID field.
func ( *MessagePeerReaction) () ( PeerClass) {
	if  == nil {
		return
	}
	return .PeerID
}

// GetDate returns value of Date field.
func ( *MessagePeerReaction) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

// GetReaction returns value of Reaction field.
func ( *MessagePeerReaction) () ( ReactionClass) {
	if  == nil {
		return
	}
	return .Reaction
}