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

// MessageEmpty represents TL type `messageEmpty#90a6ca84`.
// Empty constructor, non-existent message.
//
// See https://core.telegram.org/constructor/messageEmpty for reference.
type MessageEmpty struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Message identifier
	ID int
	// Peer ID, the chat where this message was sent
	//
	// Use SetPeerID and GetPeerID helpers.
	PeerID PeerClass
}

// MessageEmptyTypeID is TL type id of MessageEmpty.
const MessageEmptyTypeID = 0x90a6ca84

// construct implements constructor of MessageClass.
func ( MessageEmpty) () MessageClass { return & }

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

	_ MessageClass = &MessageEmpty{}
)

func ( *MessageEmpty) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.PeerID == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessageEmpty from given interface.
func ( *MessageEmpty) ( interface {
	() ( int)
	() ( PeerClass,  bool)
}) {
	.ID = .()
	if ,  := .();  {
		.PeerID = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *MessageEmpty) () tdp.Type {
	 := tdp.Type{
		Name: "messageEmpty",
		ID:   MessageEmptyTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "PeerID",
			SchemaName: "peer_id",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *MessageEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messageEmpty#90a6ca84 as nil")
	}
	.PutID(MessageEmptyTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessageEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messageEmpty#90a6ca84 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messageEmpty#90a6ca84: field flags: %w", )
	}
	.PutInt(.ID)
	if .Flags.Has(0) {
		if .PeerID == nil {
			return fmt.Errorf("unable to encode messageEmpty#90a6ca84: field peer_id is nil")
		}
		if  := .PeerID.Encode();  != nil {
			return fmt.Errorf("unable to encode messageEmpty#90a6ca84: field peer_id: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessageEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messageEmpty#90a6ca84 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messageEmpty#90a6ca84: field flags: %w", )
		}
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messageEmpty#90a6ca84: field id: %w", )
		}
		.ID = 
	}
	if .Flags.Has(0) {
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode messageEmpty#90a6ca84: field peer_id: %w", )
		}
		.PeerID = 
	}
	return nil
}

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

// SetPeerID sets value of PeerID conditional field.
func ( *MessageEmpty) ( PeerClass) {
	.Flags.Set(0)
	.PeerID = 
}

// GetPeerID returns value of PeerID conditional field and
// boolean which is true if field was set.
func ( *MessageEmpty) () ( PeerClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .PeerID, true
}

// Message represents TL type `message#38116ee0`.
// A message
//
// See https://core.telegram.org/constructor/message for reference.
type Message struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Is this an outgoing message
	Out bool
	// Whether we were mentionedĀ¹ in this message
	//
	// Links:
	//  1) https://core.telegram.org/api/mentions
	Mentioned bool
	// Whether there are unread media attachments in this message
	MediaUnread bool
	// Whether this is a silent message (no notification triggered)
	Silent bool
	// Whether this is a channel post
	Post bool
	// Whether this is a scheduled messageĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/scheduled-messages
	FromScheduled bool
	// This is a legacy message: it has to be refetched with the new layer
	Legacy bool
	// Whether the message should be shown as not modified to the user, even if an edit date
	// is present
	EditHide bool
	// Whether this message is pinnedĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/pin
	Pinned bool
	// Whether this message is protectedĀ¹ and thus cannot be forwarded; clients should also
	// prevent users from saving attached media (i.e. videos should only be streamed, photos
	// should be kept in RAM, et cetera).
	//
	// Links:
	//  1) https://telegram.org/blog/protected-content-delete-by-date-and-more
	Noforwards bool
	// If set, any eventual webpage preview will be shown on top of the message instead of at
	// the bottom.
	InvertMedia bool
	// ID of the message
	ID int
	// ID of the sender of the message
	//
	// Use SetFromID and GetFromID helpers.
	FromID PeerClass
	// Peer ID, the chat where this message was sent
	PeerID PeerClass
	// Info about forwarded messages
	//
	// Use SetFwdFrom and GetFwdFrom helpers.
	FwdFrom MessageFwdHeader
	// ID of the inline bot that generated the message
	//
	// Use SetViaBotID and GetViaBotID helpers.
	ViaBotID int64
	// Reply information
	//
	// Use SetReplyTo and GetReplyTo helpers.
	ReplyTo MessageReplyHeaderClass
	// Date of the message
	Date int
	// The message
	Message string
	// Media attachment
	//
	// Use SetMedia and GetMedia helpers.
	Media MessageMediaClass
	// Reply markup (bot/inline keyboards)
	//
	// Use SetReplyMarkup and GetReplyMarkup helpers.
	ReplyMarkup ReplyMarkupClass
	// Message entitiesĀ¹ for styled text
	//
	// Links:
	//  1) https://core.telegram.org/api/entities
	//
	// Use SetEntities and GetEntities helpers.
	Entities []MessageEntityClass
	// View count for channel posts
	//
	// Use SetViews and GetViews helpers.
	Views int
	// Forward counter
	//
	// Use SetForwards and GetForwards helpers.
	Forwards int
	// Info about post comments (for channels) or message replies (for groups)Ā¹
	//
	// Links:
	//  1) https://core.telegram.org/api/threads
	//
	// Use SetReplies and GetReplies helpers.
	Replies MessageReplies
	// Last edit date of this message
	//
	// Use SetEditDate and GetEditDate helpers.
	EditDate int
	// Name of the author of this message for channel posts (with signatures enabled)
	//
	// Use SetPostAuthor and GetPostAuthor helpers.
	PostAuthor string
	// Multiple media messages sent using messages.sendMultiMediaĀ¹ with the same grouped ID
	// indicate an album or media groupĀ²
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.sendMultiMedia
	//  2) https://core.telegram.org/api/files#albums-grouped-media
	//
	// Use SetGroupedID and GetGroupedID helpers.
	GroupedID int64
	// Reactions to this message
	//
	// Use SetReactions and GetReactions helpers.
	Reactions MessageReactions
	// Contains the reason why access to this message must be restricted.
	//
	// Use SetRestrictionReason and GetRestrictionReason helpers.
	RestrictionReason []RestrictionReason
	// Time To Live of the message, once message.date+message.ttl_period === time(), the
	// message will be deleted on the server, and must be deleted locally as well.
	//
	// Use SetTTLPeriod and GetTTLPeriod helpers.
	TTLPeriod int
}

// MessageTypeID is TL type id of Message.
const MessageTypeID = 0x38116ee0

// construct implements constructor of MessageClass.
func ( Message) () MessageClass { return & }

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

	_ MessageClass = &Message{}
)

func ( *Message) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Out == false) {
		return false
	}
	if !(.Mentioned == false) {
		return false
	}
	if !(.MediaUnread == false) {
		return false
	}
	if !(.Silent == false) {
		return false
	}
	if !(.Post == false) {
		return false
	}
	if !(.FromScheduled == false) {
		return false
	}
	if !(.Legacy == false) {
		return false
	}
	if !(.EditHide == false) {
		return false
	}
	if !(.Pinned == false) {
		return false
	}
	if !(.Noforwards == false) {
		return false
	}
	if !(.InvertMedia == false) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.FromID == nil) {
		return false
	}
	if !(.PeerID == nil) {
		return false
	}
	if !(.FwdFrom.Zero()) {
		return false
	}
	if !(.ViaBotID == 0) {
		return false
	}
	if !(.ReplyTo == nil) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.Message == "") {
		return false
	}
	if !(.Media == nil) {
		return false
	}
	if !(.ReplyMarkup == nil) {
		return false
	}
	if !(.Entities == nil) {
		return false
	}
	if !(.Views == 0) {
		return false
	}
	if !(.Forwards == 0) {
		return false
	}
	if !(.Replies.Zero()) {
		return false
	}
	if !(.EditDate == 0) {
		return false
	}
	if !(.PostAuthor == "") {
		return false
	}
	if !(.GroupedID == 0) {
		return false
	}
	if !(.Reactions.Zero()) {
		return false
	}
	if !(.RestrictionReason == nil) {
		return false
	}
	if !(.TTLPeriod == 0) {
		return false
	}

	return true
}

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

// FillFrom fills Message from given interface.
func ( *Message) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( int)
	() ( PeerClass,  bool)
	() ( PeerClass)
	() ( MessageFwdHeader,  bool)
	() ( int64,  bool)
	() ( MessageReplyHeaderClass,  bool)
	() ( int)
	() ( string)
	() ( MessageMediaClass,  bool)
	() ( ReplyMarkupClass,  bool)
	() ( []MessageEntityClass,  bool)
	() ( int,  bool)
	() ( int,  bool)
	() ( MessageReplies,  bool)
	() ( int,  bool)
	() ( string,  bool)
	() ( int64,  bool)
	() ( MessageReactions,  bool)
	() ( []RestrictionReason,  bool)
	() ( int,  bool)
}) {
	.Out = .()
	.Mentioned = .()
	.MediaUnread = .()
	.Silent = .()
	.Post = .()
	.FromScheduled = .()
	.Legacy = .()
	.EditHide = .()
	.Pinned = .()
	.Noforwards = .()
	.InvertMedia = .()
	.ID = .()
	if ,  := .();  {
		.FromID = 
	}

	.PeerID = .()
	if ,  := .();  {
		.FwdFrom = 
	}

	if ,  := .();  {
		.ViaBotID = 
	}

	if ,  := .();  {
		.ReplyTo = 
	}

	.Date = .()
	.Message = .()
	if ,  := .();  {
		.Media = 
	}

	if ,  := .();  {
		.ReplyMarkup = 
	}

	if ,  := .();  {
		.Entities = 
	}

	if ,  := .();  {
		.Views = 
	}

	if ,  := .();  {
		.Forwards = 
	}

	if ,  := .();  {
		.Replies = 
	}

	if ,  := .();  {
		.EditDate = 
	}

	if ,  := .();  {
		.PostAuthor = 
	}

	if ,  := .();  {
		.GroupedID = 
	}

	if ,  := .();  {
		.Reactions = 
	}

	if ,  := .();  {
		.RestrictionReason = 
	}

	if ,  := .();  {
		.TTLPeriod = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *Message) () tdp.Type {
	 := tdp.Type{
		Name: "message",
		ID:   MessageTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Out",
			SchemaName: "out",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Mentioned",
			SchemaName: "mentioned",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "MediaUnread",
			SchemaName: "media_unread",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "Silent",
			SchemaName: "silent",
			Null:       !.Flags.Has(13),
		},
		{
			Name:       "Post",
			SchemaName: "post",
			Null:       !.Flags.Has(14),
		},
		{
			Name:       "FromScheduled",
			SchemaName: "from_scheduled",
			Null:       !.Flags.Has(18),
		},
		{
			Name:       "Legacy",
			SchemaName: "legacy",
			Null:       !.Flags.Has(19),
		},
		{
			Name:       "EditHide",
			SchemaName: "edit_hide",
			Null:       !.Flags.Has(21),
		},
		{
			Name:       "Pinned",
			SchemaName: "pinned",
			Null:       !.Flags.Has(24),
		},
		{
			Name:       "Noforwards",
			SchemaName: "noforwards",
			Null:       !.Flags.Has(26),
		},
		{
			Name:       "InvertMedia",
			SchemaName: "invert_media",
			Null:       !.Flags.Has(27),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "FromID",
			SchemaName: "from_id",
			Null:       !.Flags.Has(8),
		},
		{
			Name:       "PeerID",
			SchemaName: "peer_id",
		},
		{
			Name:       "FwdFrom",
			SchemaName: "fwd_from",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "ViaBotID",
			SchemaName: "via_bot_id",
			Null:       !.Flags.Has(11),
		},
		{
			Name:       "ReplyTo",
			SchemaName: "reply_to",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "Message",
			SchemaName: "message",
		},
		{
			Name:       "Media",
			SchemaName: "media",
			Null:       !.Flags.Has(9),
		},
		{
			Name:       "ReplyMarkup",
			SchemaName: "reply_markup",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "Entities",
			SchemaName: "entities",
			Null:       !.Flags.Has(7),
		},
		{
			Name:       "Views",
			SchemaName: "views",
			Null:       !.Flags.Has(10),
		},
		{
			Name:       "Forwards",
			SchemaName: "forwards",
			Null:       !.Flags.Has(10),
		},
		{
			Name:       "Replies",
			SchemaName: "replies",
			Null:       !.Flags.Has(23),
		},
		{
			Name:       "EditDate",
			SchemaName: "edit_date",
			Null:       !.Flags.Has(15),
		},
		{
			Name:       "PostAuthor",
			SchemaName: "post_author",
			Null:       !.Flags.Has(16),
		},
		{
			Name:       "GroupedID",
			SchemaName: "grouped_id",
			Null:       !.Flags.Has(17),
		},
		{
			Name:       "Reactions",
			SchemaName: "reactions",
			Null:       !.Flags.Has(20),
		},
		{
			Name:       "RestrictionReason",
			SchemaName: "restriction_reason",
			Null:       !.Flags.Has(22),
		},
		{
			Name:       "TTLPeriod",
			SchemaName: "ttl_period",
			Null:       !.Flags.Has(25),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *Message) () {
	if !(.Out == false) {
		.Flags.Set(1)
	}
	if !(.Mentioned == false) {
		.Flags.Set(4)
	}
	if !(.MediaUnread == false) {
		.Flags.Set(5)
	}
	if !(.Silent == false) {
		.Flags.Set(13)
	}
	if !(.Post == false) {
		.Flags.Set(14)
	}
	if !(.FromScheduled == false) {
		.Flags.Set(18)
	}
	if !(.Legacy == false) {
		.Flags.Set(19)
	}
	if !(.EditHide == false) {
		.Flags.Set(21)
	}
	if !(.Pinned == false) {
		.Flags.Set(24)
	}
	if !(.Noforwards == false) {
		.Flags.Set(26)
	}
	if !(.InvertMedia == false) {
		.Flags.Set(27)
	}
	if !(.FromID == nil) {
		.Flags.Set(8)
	}
	if !(.FwdFrom.Zero()) {
		.Flags.Set(2)
	}
	if !(.ViaBotID == 0) {
		.Flags.Set(11)
	}
	if !(.ReplyTo == nil) {
		.Flags.Set(3)
	}
	if !(.Media == nil) {
		.Flags.Set(9)
	}
	if !(.ReplyMarkup == nil) {
		.Flags.Set(6)
	}
	if !(.Entities == nil) {
		.Flags.Set(7)
	}
	if !(.Views == 0) {
		.Flags.Set(10)
	}
	if !(.Forwards == 0) {
		.Flags.Set(10)
	}
	if !(.Replies.Zero()) {
		.Flags.Set(23)
	}
	if !(.EditDate == 0) {
		.Flags.Set(15)
	}
	if !(.PostAuthor == "") {
		.Flags.Set(16)
	}
	if !(.GroupedID == 0) {
		.Flags.Set(17)
	}
	if !(.Reactions.Zero()) {
		.Flags.Set(20)
	}
	if !(.RestrictionReason == nil) {
		.Flags.Set(22)
	}
	if !(.TTLPeriod == 0) {
		.Flags.Set(25)
	}
}

// Encode implements bin.Encoder.
func ( *Message) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode message#38116ee0 as nil")
	}
	.PutID(MessageTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *Message) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode message#38116ee0 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode message#38116ee0: field flags: %w", )
	}
	.PutInt(.ID)
	if .Flags.Has(8) {
		if .FromID == nil {
			return fmt.Errorf("unable to encode message#38116ee0: field from_id is nil")
		}
		if  := .FromID.Encode();  != nil {
			return fmt.Errorf("unable to encode message#38116ee0: field from_id: %w", )
		}
	}
	if .PeerID == nil {
		return fmt.Errorf("unable to encode message#38116ee0: field peer_id is nil")
	}
	if  := .PeerID.Encode();  != nil {
		return fmt.Errorf("unable to encode message#38116ee0: field peer_id: %w", )
	}
	if .Flags.Has(2) {
		if  := .FwdFrom.Encode();  != nil {
			return fmt.Errorf("unable to encode message#38116ee0: field fwd_from: %w", )
		}
	}
	if .Flags.Has(11) {
		.PutLong(.ViaBotID)
	}
	if .Flags.Has(3) {
		if .ReplyTo == nil {
			return fmt.Errorf("unable to encode message#38116ee0: field reply_to is nil")
		}
		if  := .ReplyTo.Encode();  != nil {
			return fmt.Errorf("unable to encode message#38116ee0: field reply_to: %w", )
		}
	}
	.PutInt(.Date)
	.PutString(.Message)
	if .Flags.Has(9) {
		if .Media == nil {
			return fmt.Errorf("unable to encode message#38116ee0: field media is nil")
		}
		if  := .Media.Encode();  != nil {
			return fmt.Errorf("unable to encode message#38116ee0: field media: %w", )
		}
	}
	if .Flags.Has(6) {
		if .ReplyMarkup == nil {
			return fmt.Errorf("unable to encode message#38116ee0: field reply_markup is nil")
		}
		if  := .ReplyMarkup.Encode();  != nil {
			return fmt.Errorf("unable to encode message#38116ee0: field reply_markup: %w", )
		}
	}
	if .Flags.Has(7) {
		.PutVectorHeader(len(.Entities))
		for ,  := range .Entities {
			if  == nil {
				return fmt.Errorf("unable to encode message#38116ee0: field entities element with index %d is nil", )
			}
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode message#38116ee0: field entities element with index %d: %w", , )
			}
		}
	}
	if .Flags.Has(10) {
		.PutInt(.Views)
	}
	if .Flags.Has(10) {
		.PutInt(.Forwards)
	}
	if .Flags.Has(23) {
		if  := .Replies.Encode();  != nil {
			return fmt.Errorf("unable to encode message#38116ee0: field replies: %w", )
		}
	}
	if .Flags.Has(15) {
		.PutInt(.EditDate)
	}
	if .Flags.Has(16) {
		.PutString(.PostAuthor)
	}
	if .Flags.Has(17) {
		.PutLong(.GroupedID)
	}
	if .Flags.Has(20) {
		if  := .Reactions.Encode();  != nil {
			return fmt.Errorf("unable to encode message#38116ee0: field reactions: %w", )
		}
	}
	if .Flags.Has(22) {
		.PutVectorHeader(len(.RestrictionReason))
		for ,  := range .RestrictionReason {
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode message#38116ee0: field restriction_reason element with index %d: %w", , )
			}
		}
	}
	if .Flags.Has(25) {
		.PutInt(.TTLPeriod)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *Message) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode message#38116ee0 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode message#38116ee0: field flags: %w", )
		}
	}
	.Out = .Flags.Has(1)
	.Mentioned = .Flags.Has(4)
	.MediaUnread = .Flags.Has(5)
	.Silent = .Flags.Has(13)
	.Post = .Flags.Has(14)
	.FromScheduled = .Flags.Has(18)
	.Legacy = .Flags.Has(19)
	.EditHide = .Flags.Has(21)
	.Pinned = .Flags.Has(24)
	.Noforwards = .Flags.Has(26)
	.InvertMedia = .Flags.Has(27)
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode message#38116ee0: field id: %w", )
		}
		.ID = 
	}
	if .Flags.Has(8) {
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode message#38116ee0: field from_id: %w", )
		}
		.FromID = 
	}
	{
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode message#38116ee0: field peer_id: %w", )
		}
		.PeerID = 
	}
	if .Flags.Has(2) {
		if  := .FwdFrom.Decode();  != nil {
			return fmt.Errorf("unable to decode message#38116ee0: field fwd_from: %w", )
		}
	}
	if .Flags.Has(11) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode message#38116ee0: field via_bot_id: %w", )
		}
		.ViaBotID = 
	}
	if .Flags.Has(3) {
		,  := DecodeMessageReplyHeader()
		if  != nil {
			return fmt.Errorf("unable to decode message#38116ee0: field reply_to: %w", )
		}
		.ReplyTo = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode message#38116ee0: field date: %w", )
		}
		.Date = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode message#38116ee0: field message: %w", )
		}
		.Message = 
	}
	if .Flags.Has(9) {
		,  := DecodeMessageMedia()
		if  != nil {
			return fmt.Errorf("unable to decode message#38116ee0: field media: %w", )
		}
		.Media = 
	}
	if .Flags.Has(6) {
		,  := DecodeReplyMarkup()
		if  != nil {
			return fmt.Errorf("unable to decode message#38116ee0: field reply_markup: %w", )
		}
		.ReplyMarkup = 
	}
	if .Flags.Has(7) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode message#38116ee0: field entities: %w", )
		}

		if  > 0 {
			.Entities = make([]MessageEntityClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeMessageEntity()
			if  != nil {
				return fmt.Errorf("unable to decode message#38116ee0: field entities: %w", )
			}
			.Entities = append(.Entities, )
		}
	}
	if .Flags.Has(10) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode message#38116ee0: field views: %w", )
		}
		.Views = 
	}
	if .Flags.Has(10) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode message#38116ee0: field forwards: %w", )
		}
		.Forwards = 
	}
	if .Flags.Has(23) {
		if  := .Replies.Decode();  != nil {
			return fmt.Errorf("unable to decode message#38116ee0: field replies: %w", )
		}
	}
	if .Flags.Has(15) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode message#38116ee0: field edit_date: %w", )
		}
		.EditDate = 
	}
	if .Flags.Has(16) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode message#38116ee0: field post_author: %w", )
		}
		.PostAuthor = 
	}
	if .Flags.Has(17) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode message#38116ee0: field grouped_id: %w", )
		}
		.GroupedID = 
	}
	if .Flags.Has(20) {
		if  := .Reactions.Decode();  != nil {
			return fmt.Errorf("unable to decode message#38116ee0: field reactions: %w", )
		}
	}
	if .Flags.Has(22) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode message#38116ee0: field restriction_reason: %w", )
		}

		if  > 0 {
			.RestrictionReason = make([]RestrictionReason, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  RestrictionReason
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode message#38116ee0: field restriction_reason: %w", )
			}
			.RestrictionReason = append(.RestrictionReason, )
		}
	}
	if .Flags.Has(25) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode message#38116ee0: field ttl_period: %w", )
		}
		.TTLPeriod = 
	}
	return nil
}

// SetOut sets value of Out conditional field.
func ( *Message) ( bool) {
	if  {
		.Flags.Set(1)
		.Out = true
	} else {
		.Flags.Unset(1)
		.Out = false
	}
}

// GetOut returns value of Out conditional field.
func ( *Message) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetMentioned sets value of Mentioned conditional field.
func ( *Message) ( bool) {
	if  {
		.Flags.Set(4)
		.Mentioned = true
	} else {
		.Flags.Unset(4)
		.Mentioned = false
	}
}

// GetMentioned returns value of Mentioned conditional field.
func ( *Message) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(4)
}

// SetMediaUnread sets value of MediaUnread conditional field.
func ( *Message) ( bool) {
	if  {
		.Flags.Set(5)
		.MediaUnread = true
	} else {
		.Flags.Unset(5)
		.MediaUnread = false
	}
}

// GetMediaUnread returns value of MediaUnread conditional field.
func ( *Message) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(5)
}

// SetSilent sets value of Silent conditional field.
func ( *Message) ( bool) {
	if  {
		.Flags.Set(13)
		.Silent = true
	} else {
		.Flags.Unset(13)
		.Silent = false
	}
}

// GetSilent returns value of Silent conditional field.
func ( *Message) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(13)
}

// SetPost sets value of Post conditional field.
func ( *Message) ( bool) {
	if  {
		.Flags.Set(14)
		.Post = true
	} else {
		.Flags.Unset(14)
		.Post = false
	}
}

// GetPost returns value of Post conditional field.
func ( *Message) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(14)
}

// SetFromScheduled sets value of FromScheduled conditional field.
func ( *Message) ( bool) {
	if  {
		.Flags.Set(18)
		.FromScheduled = true
	} else {
		.Flags.Unset(18)
		.FromScheduled = false
	}
}

// GetFromScheduled returns value of FromScheduled conditional field.
func ( *Message) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(18)
}

// SetLegacy sets value of Legacy conditional field.
func ( *Message) ( bool) {
	if  {
		.Flags.Set(19)
		.Legacy = true
	} else {
		.Flags.Unset(19)
		.Legacy = false
	}
}

// GetLegacy returns value of Legacy conditional field.
func ( *Message) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(19)
}

// SetEditHide sets value of EditHide conditional field.
func ( *Message) ( bool) {
	if  {
		.Flags.Set(21)
		.EditHide = true
	} else {
		.Flags.Unset(21)
		.EditHide = false
	}
}

// GetEditHide returns value of EditHide conditional field.
func ( *Message) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(21)
}

// SetPinned sets value of Pinned conditional field.
func ( *Message) ( bool) {
	if  {
		.Flags.Set(24)
		.Pinned = true
	} else {
		.Flags.Unset(24)
		.Pinned = false
	}
}

// GetPinned returns value of Pinned conditional field.
func ( *Message) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(24)
}

// SetNoforwards sets value of Noforwards conditional field.
func ( *Message) ( bool) {
	if  {
		.Flags.Set(26)
		.Noforwards = true
	} else {
		.Flags.Unset(26)
		.Noforwards = false
	}
}

// GetNoforwards returns value of Noforwards conditional field.
func ( *Message) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(26)
}

// SetInvertMedia sets value of InvertMedia conditional field.
func ( *Message) ( bool) {
	if  {
		.Flags.Set(27)
		.InvertMedia = true
	} else {
		.Flags.Unset(27)
		.InvertMedia = false
	}
}

// GetInvertMedia returns value of InvertMedia conditional field.
func ( *Message) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(27)
}

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

// SetFromID sets value of FromID conditional field.
func ( *Message) ( PeerClass) {
	.Flags.Set(8)
	.FromID = 
}

// GetFromID returns value of FromID conditional field and
// boolean which is true if field was set.
func ( *Message) () ( PeerClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(8) {
		return , false
	}
	return .FromID, true
}

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

// SetFwdFrom sets value of FwdFrom conditional field.
func ( *Message) ( MessageFwdHeader) {
	.Flags.Set(2)
	.FwdFrom = 
}

// GetFwdFrom returns value of FwdFrom conditional field and
// boolean which is true if field was set.
func ( *Message) () ( MessageFwdHeader,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .FwdFrom, true
}

// SetViaBotID sets value of ViaBotID conditional field.
func ( *Message) ( int64) {
	.Flags.Set(11)
	.ViaBotID = 
}

// GetViaBotID returns value of ViaBotID conditional field and
// boolean which is true if field was set.
func ( *Message) () ( int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(11) {
		return , false
	}
	return .ViaBotID, true
}

// SetReplyTo sets value of ReplyTo conditional field.
func ( *Message) ( MessageReplyHeaderClass) {
	.Flags.Set(3)
	.ReplyTo = 
}

// GetReplyTo returns value of ReplyTo conditional field and
// boolean which is true if field was set.
func ( *Message) () ( MessageReplyHeaderClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .ReplyTo, true
}

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

// GetMessage returns value of Message field.
func ( *Message) () ( string) {
	if  == nil {
		return
	}
	return .Message
}

// SetMedia sets value of Media conditional field.
func ( *Message) ( MessageMediaClass) {
	.Flags.Set(9)
	.Media = 
}

// GetMedia returns value of Media conditional field and
// boolean which is true if field was set.
func ( *Message) () ( MessageMediaClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(9) {
		return , false
	}
	return .Media, true
}

// SetReplyMarkup sets value of ReplyMarkup conditional field.
func ( *Message) ( ReplyMarkupClass) {
	.Flags.Set(6)
	.ReplyMarkup = 
}

// GetReplyMarkup returns value of ReplyMarkup conditional field and
// boolean which is true if field was set.
func ( *Message) () ( ReplyMarkupClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(6) {
		return , false
	}
	return .ReplyMarkup, true
}

// SetEntities sets value of Entities conditional field.
func ( *Message) ( []MessageEntityClass) {
	.Flags.Set(7)
	.Entities = 
}

// GetEntities returns value of Entities conditional field and
// boolean which is true if field was set.
func ( *Message) () ( []MessageEntityClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(7) {
		return , false
	}
	return .Entities, true
}

// SetViews sets value of Views conditional field.
func ( *Message) ( int) {
	.Flags.Set(10)
	.Views = 
}

// GetViews returns value of Views conditional field and
// boolean which is true if field was set.
func ( *Message) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(10) {
		return , false
	}
	return .Views, true
}

// SetForwards sets value of Forwards conditional field.
func ( *Message) ( int) {
	.Flags.Set(10)
	.Forwards = 
}

// GetForwards returns value of Forwards conditional field and
// boolean which is true if field was set.
func ( *Message) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(10) {
		return , false
	}
	return .Forwards, true
}

// SetReplies sets value of Replies conditional field.
func ( *Message) ( MessageReplies) {
	.Flags.Set(23)
	.Replies = 
}

// GetReplies returns value of Replies conditional field and
// boolean which is true if field was set.
func ( *Message) () ( MessageReplies,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(23) {
		return , false
	}
	return .Replies, true
}

// SetEditDate sets value of EditDate conditional field.
func ( *Message) ( int) {
	.Flags.Set(15)
	.EditDate = 
}

// GetEditDate returns value of EditDate conditional field and
// boolean which is true if field was set.
func ( *Message) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(15) {
		return , false
	}
	return .EditDate, true
}

// SetPostAuthor sets value of PostAuthor conditional field.
func ( *Message) ( string) {
	.Flags.Set(16)
	.PostAuthor = 
}

// GetPostAuthor returns value of PostAuthor conditional field and
// boolean which is true if field was set.
func ( *Message) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(16) {
		return , false
	}
	return .PostAuthor, true
}

// SetGroupedID sets value of GroupedID conditional field.
func ( *Message) ( int64) {
	.Flags.Set(17)
	.GroupedID = 
}

// GetGroupedID returns value of GroupedID conditional field and
// boolean which is true if field was set.
func ( *Message) () ( int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(17) {
		return , false
	}
	return .GroupedID, true
}

// SetReactions sets value of Reactions conditional field.
func ( *Message) ( MessageReactions) {
	.Flags.Set(20)
	.Reactions = 
}

// GetReactions returns value of Reactions conditional field and
// boolean which is true if field was set.
func ( *Message) () ( MessageReactions,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(20) {
		return , false
	}
	return .Reactions, true
}

// SetRestrictionReason sets value of RestrictionReason conditional field.
func ( *Message) ( []RestrictionReason) {
	.Flags.Set(22)
	.RestrictionReason = 
}

// GetRestrictionReason returns value of RestrictionReason conditional field and
// boolean which is true if field was set.
func ( *Message) () ( []RestrictionReason,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(22) {
		return , false
	}
	return .RestrictionReason, true
}

// SetTTLPeriod sets value of TTLPeriod conditional field.
func ( *Message) ( int) {
	.Flags.Set(25)
	.TTLPeriod = 
}

// GetTTLPeriod returns value of TTLPeriod conditional field and
// boolean which is true if field was set.
func ( *Message) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(25) {
		return , false
	}
	return .TTLPeriod, true
}

// MapEntities returns field Entities wrapped in MessageEntityClassArray helper.
func ( *Message) () ( MessageEntityClassArray,  bool) {
	if !.Flags.Has(7) {
		return , false
	}
	return MessageEntityClassArray(.Entities), true
}

// MessageService represents TL type `messageService#2b085862`.
// Indicates a service message
//
// See https://core.telegram.org/constructor/messageService for reference.
type MessageService struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the message is outgoing
	Out bool
	// Whether we were mentioned in the message
	Mentioned bool
	// Whether the message contains unread media
	MediaUnread bool
	// Whether the message is silent
	Silent bool
	// Whether it's a channel post
	Post bool
	// This is a legacy message: it has to be refetched with the new layer
	Legacy bool
	// Message ID
	ID int
	// ID of the sender of this message
	//
	// Use SetFromID and GetFromID helpers.
	FromID PeerClass
	// Sender of service message
	PeerID PeerClass
	// Reply (thread) information
	//
	// Use SetReplyTo and GetReplyTo helpers.
	ReplyTo MessageReplyHeaderClass
	// Message date
	Date int
	// Event connected with the service message
	Action MessageActionClass
	// Time To Live of the message, once message.date+message.ttl_period === time(), the
	// message will be deleted on the server, and must be deleted locally as well.
	//
	// Use SetTTLPeriod and GetTTLPeriod helpers.
	TTLPeriod int
}

// MessageServiceTypeID is TL type id of MessageService.
const MessageServiceTypeID = 0x2b085862

// construct implements constructor of MessageClass.
func ( MessageService) () MessageClass { return & }

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

	_ MessageClass = &MessageService{}
)

func ( *MessageService) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Out == false) {
		return false
	}
	if !(.Mentioned == false) {
		return false
	}
	if !(.MediaUnread == false) {
		return false
	}
	if !(.Silent == false) {
		return false
	}
	if !(.Post == false) {
		return false
	}
	if !(.Legacy == false) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.FromID == nil) {
		return false
	}
	if !(.PeerID == nil) {
		return false
	}
	if !(.ReplyTo == nil) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.Action == nil) {
		return false
	}
	if !(.TTLPeriod == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageService from given interface.
func ( *MessageService) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( int)
	() ( PeerClass,  bool)
	() ( PeerClass)
	() ( MessageReplyHeaderClass,  bool)
	() ( int)
	() ( MessageActionClass)
	() ( int,  bool)
}) {
	.Out = .()
	.Mentioned = .()
	.MediaUnread = .()
	.Silent = .()
	.Post = .()
	.Legacy = .()
	.ID = .()
	if ,  := .();  {
		.FromID = 
	}

	.PeerID = .()
	if ,  := .();  {
		.ReplyTo = 
	}

	.Date = .()
	.Action = .()
	if ,  := .();  {
		.TTLPeriod = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *MessageService) () tdp.Type {
	 := tdp.Type{
		Name: "messageService",
		ID:   MessageServiceTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Out",
			SchemaName: "out",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Mentioned",
			SchemaName: "mentioned",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "MediaUnread",
			SchemaName: "media_unread",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "Silent",
			SchemaName: "silent",
			Null:       !.Flags.Has(13),
		},
		{
			Name:       "Post",
			SchemaName: "post",
			Null:       !.Flags.Has(14),
		},
		{
			Name:       "Legacy",
			SchemaName: "legacy",
			Null:       !.Flags.Has(19),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "FromID",
			SchemaName: "from_id",
			Null:       !.Flags.Has(8),
		},
		{
			Name:       "PeerID",
			SchemaName: "peer_id",
		},
		{
			Name:       "ReplyTo",
			SchemaName: "reply_to",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "Action",
			SchemaName: "action",
		},
		{
			Name:       "TTLPeriod",
			SchemaName: "ttl_period",
			Null:       !.Flags.Has(25),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessageService) () {
	if !(.Out == false) {
		.Flags.Set(1)
	}
	if !(.Mentioned == false) {
		.Flags.Set(4)
	}
	if !(.MediaUnread == false) {
		.Flags.Set(5)
	}
	if !(.Silent == false) {
		.Flags.Set(13)
	}
	if !(.Post == false) {
		.Flags.Set(14)
	}
	if !(.Legacy == false) {
		.Flags.Set(19)
	}
	if !(.FromID == nil) {
		.Flags.Set(8)
	}
	if !(.ReplyTo == nil) {
		.Flags.Set(3)
	}
	if !(.TTLPeriod == 0) {
		.Flags.Set(25)
	}
}

// Encode implements bin.Encoder.
func ( *MessageService) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messageService#2b085862 as nil")
	}
	.PutID(MessageServiceTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessageService) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messageService#2b085862 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messageService#2b085862: field flags: %w", )
	}
	.PutInt(.ID)
	if .Flags.Has(8) {
		if .FromID == nil {
			return fmt.Errorf("unable to encode messageService#2b085862: field from_id is nil")
		}
		if  := .FromID.Encode();  != nil {
			return fmt.Errorf("unable to encode messageService#2b085862: field from_id: %w", )
		}
	}
	if .PeerID == nil {
		return fmt.Errorf("unable to encode messageService#2b085862: field peer_id is nil")
	}
	if  := .PeerID.Encode();  != nil {
		return fmt.Errorf("unable to encode messageService#2b085862: field peer_id: %w", )
	}
	if .Flags.Has(3) {
		if .ReplyTo == nil {
			return fmt.Errorf("unable to encode messageService#2b085862: field reply_to is nil")
		}
		if  := .ReplyTo.Encode();  != nil {
			return fmt.Errorf("unable to encode messageService#2b085862: field reply_to: %w", )
		}
	}
	.PutInt(.Date)
	if .Action == nil {
		return fmt.Errorf("unable to encode messageService#2b085862: field action is nil")
	}
	if  := .Action.Encode();  != nil {
		return fmt.Errorf("unable to encode messageService#2b085862: field action: %w", )
	}
	if .Flags.Has(25) {
		.PutInt(.TTLPeriod)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessageService) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messageService#2b085862 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messageService#2b085862: field flags: %w", )
		}
	}
	.Out = .Flags.Has(1)
	.Mentioned = .Flags.Has(4)
	.MediaUnread = .Flags.Has(5)
	.Silent = .Flags.Has(13)
	.Post = .Flags.Has(14)
	.Legacy = .Flags.Has(19)
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messageService#2b085862: field id: %w", )
		}
		.ID = 
	}
	if .Flags.Has(8) {
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode messageService#2b085862: field from_id: %w", )
		}
		.FromID = 
	}
	{
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode messageService#2b085862: field peer_id: %w", )
		}
		.PeerID = 
	}
	if .Flags.Has(3) {
		,  := DecodeMessageReplyHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messageService#2b085862: field reply_to: %w", )
		}
		.ReplyTo = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messageService#2b085862: field date: %w", )
		}
		.Date = 
	}
	{
		,  := DecodeMessageAction()
		if  != nil {
			return fmt.Errorf("unable to decode messageService#2b085862: field action: %w", )
		}
		.Action = 
	}
	if .Flags.Has(25) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messageService#2b085862: field ttl_period: %w", )
		}
		.TTLPeriod = 
	}
	return nil
}

// SetOut sets value of Out conditional field.
func ( *MessageService) ( bool) {
	if  {
		.Flags.Set(1)
		.Out = true
	} else {
		.Flags.Unset(1)
		.Out = false
	}
}

// GetOut returns value of Out conditional field.
func ( *MessageService) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetMentioned sets value of Mentioned conditional field.
func ( *MessageService) ( bool) {
	if  {
		.Flags.Set(4)
		.Mentioned = true
	} else {
		.Flags.Unset(4)
		.Mentioned = false
	}
}

// GetMentioned returns value of Mentioned conditional field.
func ( *MessageService) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(4)
}

// SetMediaUnread sets value of MediaUnread conditional field.
func ( *MessageService) ( bool) {
	if  {
		.Flags.Set(5)
		.MediaUnread = true
	} else {
		.Flags.Unset(5)
		.MediaUnread = false
	}
}

// GetMediaUnread returns value of MediaUnread conditional field.
func ( *MessageService) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(5)
}

// SetSilent sets value of Silent conditional field.
func ( *MessageService) ( bool) {
	if  {
		.Flags.Set(13)
		.Silent = true
	} else {
		.Flags.Unset(13)
		.Silent = false
	}
}

// GetSilent returns value of Silent conditional field.
func ( *MessageService) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(13)
}

// SetPost sets value of Post conditional field.
func ( *MessageService) ( bool) {
	if  {
		.Flags.Set(14)
		.Post = true
	} else {
		.Flags.Unset(14)
		.Post = false
	}
}

// GetPost returns value of Post conditional field.
func ( *MessageService) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(14)
}

// SetLegacy sets value of Legacy conditional field.
func ( *MessageService) ( bool) {
	if  {
		.Flags.Set(19)
		.Legacy = true
	} else {
		.Flags.Unset(19)
		.Legacy = false
	}
}

// GetLegacy returns value of Legacy conditional field.
func ( *MessageService) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(19)
}

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

// SetFromID sets value of FromID conditional field.
func ( *MessageService) ( PeerClass) {
	.Flags.Set(8)
	.FromID = 
}

// GetFromID returns value of FromID conditional field and
// boolean which is true if field was set.
func ( *MessageService) () ( PeerClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(8) {
		return , false
	}
	return .FromID, true
}

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

// SetReplyTo sets value of ReplyTo conditional field.
func ( *MessageService) ( MessageReplyHeaderClass) {
	.Flags.Set(3)
	.ReplyTo = 
}

// GetReplyTo returns value of ReplyTo conditional field and
// boolean which is true if field was set.
func ( *MessageService) () ( MessageReplyHeaderClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .ReplyTo, true
}

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

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

// SetTTLPeriod sets value of TTLPeriod conditional field.
func ( *MessageService) ( int) {
	.Flags.Set(25)
	.TTLPeriod = 
}

// GetTTLPeriod returns value of TTLPeriod conditional field and
// boolean which is true if field was set.
func ( *MessageService) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(25) {
		return , false
	}
	return .TTLPeriod, true
}

// MessageClassName is schema name of MessageClass.
const MessageClassName = "Message"

// MessageClass represents Message generic type.
//
// See https://core.telegram.org/type/Message for reference.
//
// Example:
//
//	g, err := tg.DecodeMessage(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.MessageEmpty: // messageEmpty#90a6ca84
//	case *tg.Message: // message#38116ee0
//	case *tg.MessageService: // messageService#2b085862
//	default: panic(v)
//	}
type MessageClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() MessageClass

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

	// Message identifier
	GetID() (value int)

	// AsNotEmpty tries to map MessageClass to NotEmptyMessage.
	AsNotEmpty() (NotEmptyMessage, bool)
}

// AsInputMessageID tries to map Message to InputMessageID.
func ( *Message) () *InputMessageID {
	 := new(InputMessageID)
	.ID = .GetID()

	return 
}

// AsInputMessageReplyTo tries to map Message to InputMessageReplyTo.
func ( *Message) () *InputMessageReplyTo {
	 := new(InputMessageReplyTo)
	.ID = .GetID()

	return 
}

// NotEmptyMessage represents NotEmpty subset of MessageClass.
type NotEmptyMessage interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() MessageClass

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

	// Is this an outgoing message
	GetOut() (value bool)

	// Whether we were mentionedĀ¹ in this message
	//
	// Links:
	//  1) https://core.telegram.org/api/mentions
	GetMentioned() (value bool)

	// Whether there are unread media attachments in this message
	GetMediaUnread() (value bool)

	// Whether this is a silent message (no notification triggered)
	GetSilent() (value bool)

	// Whether this is a channel post
	GetPost() (value bool)

	// This is a legacy message: it has to be refetched with the new layer
	GetLegacy() (value bool)

	// ID of the message
	GetID() (value int)

	// ID of the sender of the message
	GetFromID() (value PeerClass, ok bool)

	// Peer ID, the chat where this message was sent
	GetPeerID() (value PeerClass)

	// Reply information
	GetReplyTo() (value MessageReplyHeaderClass, ok bool)

	// Date of the message
	GetDate() (value int)

	// Time To Live of the message, once message.date+message.ttl_period === time(), the
	// message will be deleted on the server, and must be deleted locally as well.
	GetTTLPeriod() (value int, ok bool)
}

// AsNotEmpty tries to map MessageEmpty to NotEmptyMessage.
func ( *MessageEmpty) () (NotEmptyMessage, bool) {
	,  := (MessageClass()).(NotEmptyMessage)
	return , 
}

// AsNotEmpty tries to map Message to NotEmptyMessage.
func ( *Message) () (NotEmptyMessage, bool) {
	,  := (MessageClass()).(NotEmptyMessage)
	return , 
}

// AsNotEmpty tries to map MessageService to NotEmptyMessage.
func ( *MessageService) () (NotEmptyMessage, bool) {
	,  := (MessageClass()).(NotEmptyMessage)
	return , 
}

// DecodeMessage implements binary de-serialization for MessageClass.
func ( *bin.Buffer) (MessageClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case MessageEmptyTypeID:
		// Decoding messageEmpty#90a6ca84.
		 := MessageEmpty{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode MessageClass: %w", )
		}
		return &, nil
	case MessageTypeID:
		// Decoding message#38116ee0.
		 := Message{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode MessageClass: %w", )
		}
		return &, nil
	case MessageServiceTypeID:
		// Decoding messageService#2b085862.
		 := MessageService{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode MessageClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode MessageClass: %w", bin.NewUnexpectedID())
	}
}

// Message boxes the MessageClass providing a helper.
type MessageBox struct {
	Message MessageClass
}

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

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