// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	"context"
	"errors"
	"fmt"
	"sort"
	"strings"

	"go.uber.org/multierr"

	"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
)

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

// MessageEntityUnknown represents TL type `messageEntityUnknown#bb92ba95`.
// Unknown message entity
//
// See https://core.telegram.org/constructor/messageEntityUnknown for reference.
type MessageEntityUnknown struct {
	// Offset of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Offset int
	// Length of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Length int
}

// MessageEntityUnknownTypeID is TL type id of MessageEntityUnknown.
const MessageEntityUnknownTypeID = 0xbb92ba95

// construct implements constructor of MessageEntityClass.
func (m MessageEntityUnknown) construct() MessageEntityClass { return &m }

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

	_ MessageEntityClass = &MessageEntityUnknown{}
)

func (m *MessageEntityUnknown) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Offset == 0) {
		return false
	}
	if !(m.Length == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageEntityUnknown from given interface.
func (m *MessageEntityUnknown) FillFrom(from interface {
	GetOffset() (value int)
	GetLength() (value int)
}) {
	m.Offset = from.GetOffset()
	m.Length = from.GetLength()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageEntityUnknown) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageEntityUnknown",
		ID:   MessageEntityUnknownTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageEntityUnknown) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityUnknown#bb92ba95 as nil")
	}
	b.PutID(MessageEntityUnknownTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageEntityUnknown) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityUnknown#bb92ba95 as nil")
	}
	b.PutInt(m.Offset)
	b.PutInt(m.Length)
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageEntityUnknown) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityUnknown#bb92ba95 to nil")
	}
	if err := b.ConsumeID(MessageEntityUnknownTypeID); err != nil {
		return fmt.Errorf("unable to decode messageEntityUnknown#bb92ba95: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageEntityUnknown) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityUnknown#bb92ba95 to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityUnknown#bb92ba95: field offset: %w", err)
		}
		m.Offset = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityUnknown#bb92ba95: field length: %w", err)
		}
		m.Length = value
	}
	return nil
}

// GetOffset returns value of Offset field.
func (m *MessageEntityUnknown) GetOffset() (value int) {
	if m == nil {
		return
	}
	return m.Offset
}

// GetLength returns value of Length field.
func (m *MessageEntityUnknown) GetLength() (value int) {
	if m == nil {
		return
	}
	return m.Length
}

// MessageEntityMention represents TL type `messageEntityMention#fa04579d`.
// Message entity mentioning¹ a user by @username; messageEntityMentionName² can also
// be used to mention users by their ID.
//
// Links:
//  1. https://core.telegram.org/api/mentions
//  2. https://core.telegram.org/constructor/messageEntityMentionName
//
// See https://core.telegram.org/constructor/messageEntityMention for reference.
type MessageEntityMention struct {
	// Offset of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Offset int
	// Length of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Length int
}

// MessageEntityMentionTypeID is TL type id of MessageEntityMention.
const MessageEntityMentionTypeID = 0xfa04579d

// construct implements constructor of MessageEntityClass.
func (m MessageEntityMention) construct() MessageEntityClass { return &m }

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

	_ MessageEntityClass = &MessageEntityMention{}
)

func (m *MessageEntityMention) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Offset == 0) {
		return false
	}
	if !(m.Length == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageEntityMention from given interface.
func (m *MessageEntityMention) FillFrom(from interface {
	GetOffset() (value int)
	GetLength() (value int)
}) {
	m.Offset = from.GetOffset()
	m.Length = from.GetLength()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageEntityMention) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageEntityMention",
		ID:   MessageEntityMentionTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageEntityMention) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityMention#fa04579d as nil")
	}
	b.PutID(MessageEntityMentionTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageEntityMention) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityMention#fa04579d as nil")
	}
	b.PutInt(m.Offset)
	b.PutInt(m.Length)
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageEntityMention) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityMention#fa04579d to nil")
	}
	if err := b.ConsumeID(MessageEntityMentionTypeID); err != nil {
		return fmt.Errorf("unable to decode messageEntityMention#fa04579d: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageEntityMention) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityMention#fa04579d to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityMention#fa04579d: field offset: %w", err)
		}
		m.Offset = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityMention#fa04579d: field length: %w", err)
		}
		m.Length = value
	}
	return nil
}

// GetOffset returns value of Offset field.
func (m *MessageEntityMention) GetOffset() (value int) {
	if m == nil {
		return
	}
	return m.Offset
}

// GetLength returns value of Length field.
func (m *MessageEntityMention) GetLength() (value int) {
	if m == nil {
		return
	}
	return m.Length
}

// MessageEntityHashtag represents TL type `messageEntityHashtag#6f635b0d`.
// #hashtag message entity
//
// See https://core.telegram.org/constructor/messageEntityHashtag for reference.
type MessageEntityHashtag struct {
	// Offset of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Offset int
	// Length of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Length int
}

// MessageEntityHashtagTypeID is TL type id of MessageEntityHashtag.
const MessageEntityHashtagTypeID = 0x6f635b0d

// construct implements constructor of MessageEntityClass.
func (m MessageEntityHashtag) construct() MessageEntityClass { return &m }

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

	_ MessageEntityClass = &MessageEntityHashtag{}
)

func (m *MessageEntityHashtag) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Offset == 0) {
		return false
	}
	if !(m.Length == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageEntityHashtag from given interface.
func (m *MessageEntityHashtag) FillFrom(from interface {
	GetOffset() (value int)
	GetLength() (value int)
}) {
	m.Offset = from.GetOffset()
	m.Length = from.GetLength()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageEntityHashtag) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageEntityHashtag",
		ID:   MessageEntityHashtagTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageEntityHashtag) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityHashtag#6f635b0d as nil")
	}
	b.PutID(MessageEntityHashtagTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageEntityHashtag) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityHashtag#6f635b0d as nil")
	}
	b.PutInt(m.Offset)
	b.PutInt(m.Length)
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageEntityHashtag) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityHashtag#6f635b0d to nil")
	}
	if err := b.ConsumeID(MessageEntityHashtagTypeID); err != nil {
		return fmt.Errorf("unable to decode messageEntityHashtag#6f635b0d: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageEntityHashtag) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityHashtag#6f635b0d to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityHashtag#6f635b0d: field offset: %w", err)
		}
		m.Offset = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityHashtag#6f635b0d: field length: %w", err)
		}
		m.Length = value
	}
	return nil
}

// GetOffset returns value of Offset field.
func (m *MessageEntityHashtag) GetOffset() (value int) {
	if m == nil {
		return
	}
	return m.Offset
}

// GetLength returns value of Length field.
func (m *MessageEntityHashtag) GetLength() (value int) {
	if m == nil {
		return
	}
	return m.Length
}

// MessageEntityBotCommand represents TL type `messageEntityBotCommand#6cef8ac7`.
// Message entity representing a bot /command
//
// See https://core.telegram.org/constructor/messageEntityBotCommand for reference.
type MessageEntityBotCommand struct {
	// Offset of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Offset int
	// Length of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Length int
}

// MessageEntityBotCommandTypeID is TL type id of MessageEntityBotCommand.
const MessageEntityBotCommandTypeID = 0x6cef8ac7

// construct implements constructor of MessageEntityClass.
func (m MessageEntityBotCommand) construct() MessageEntityClass { return &m }

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

	_ MessageEntityClass = &MessageEntityBotCommand{}
)

func (m *MessageEntityBotCommand) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Offset == 0) {
		return false
	}
	if !(m.Length == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageEntityBotCommand from given interface.
func (m *MessageEntityBotCommand) FillFrom(from interface {
	GetOffset() (value int)
	GetLength() (value int)
}) {
	m.Offset = from.GetOffset()
	m.Length = from.GetLength()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageEntityBotCommand) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageEntityBotCommand",
		ID:   MessageEntityBotCommandTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageEntityBotCommand) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityBotCommand#6cef8ac7 as nil")
	}
	b.PutID(MessageEntityBotCommandTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageEntityBotCommand) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityBotCommand#6cef8ac7 as nil")
	}
	b.PutInt(m.Offset)
	b.PutInt(m.Length)
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageEntityBotCommand) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityBotCommand#6cef8ac7 to nil")
	}
	if err := b.ConsumeID(MessageEntityBotCommandTypeID); err != nil {
		return fmt.Errorf("unable to decode messageEntityBotCommand#6cef8ac7: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageEntityBotCommand) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityBotCommand#6cef8ac7 to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityBotCommand#6cef8ac7: field offset: %w", err)
		}
		m.Offset = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityBotCommand#6cef8ac7: field length: %w", err)
		}
		m.Length = value
	}
	return nil
}

// GetOffset returns value of Offset field.
func (m *MessageEntityBotCommand) GetOffset() (value int) {
	if m == nil {
		return
	}
	return m.Offset
}

// GetLength returns value of Length field.
func (m *MessageEntityBotCommand) GetLength() (value int) {
	if m == nil {
		return
	}
	return m.Length
}

// MessageEntityURL represents TL type `messageEntityUrl#6ed02538`.
// Message entity representing an in-text url: https://google.com¹; for text urls², use
// messageEntityTextUrl³.
//
// Links:
//  1. https://google.com
//  2. https://google.com
//  3. https://core.telegram.org/constructor/messageEntityTextUrl
//
// See https://core.telegram.org/constructor/messageEntityUrl for reference.
type MessageEntityURL struct {
	// Offset of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Offset int
	// Length of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Length int
}

// MessageEntityURLTypeID is TL type id of MessageEntityURL.
const MessageEntityURLTypeID = 0x6ed02538

// construct implements constructor of MessageEntityClass.
func (m MessageEntityURL) construct() MessageEntityClass { return &m }

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

	_ MessageEntityClass = &MessageEntityURL{}
)

func (m *MessageEntityURL) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Offset == 0) {
		return false
	}
	if !(m.Length == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageEntityURL from given interface.
func (m *MessageEntityURL) FillFrom(from interface {
	GetOffset() (value int)
	GetLength() (value int)
}) {
	m.Offset = from.GetOffset()
	m.Length = from.GetLength()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageEntityURL) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageEntityUrl",
		ID:   MessageEntityURLTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageEntityURL) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityUrl#6ed02538 as nil")
	}
	b.PutID(MessageEntityURLTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageEntityURL) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityUrl#6ed02538 as nil")
	}
	b.PutInt(m.Offset)
	b.PutInt(m.Length)
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageEntityURL) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityUrl#6ed02538 to nil")
	}
	if err := b.ConsumeID(MessageEntityURLTypeID); err != nil {
		return fmt.Errorf("unable to decode messageEntityUrl#6ed02538: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageEntityURL) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityUrl#6ed02538 to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityUrl#6ed02538: field offset: %w", err)
		}
		m.Offset = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityUrl#6ed02538: field length: %w", err)
		}
		m.Length = value
	}
	return nil
}

// GetOffset returns value of Offset field.
func (m *MessageEntityURL) GetOffset() (value int) {
	if m == nil {
		return
	}
	return m.Offset
}

// GetLength returns value of Length field.
func (m *MessageEntityURL) GetLength() (value int) {
	if m == nil {
		return
	}
	return m.Length
}

// MessageEntityEmail represents TL type `messageEntityEmail#64e475c2`.
// Message entity representing an email@example.com¹.
//
// Links:
//  1. https://core.telegram.orgmailto:email@example.com
//
// See https://core.telegram.org/constructor/messageEntityEmail for reference.
type MessageEntityEmail struct {
	// Offset of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Offset int
	// Length of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Length int
}

// MessageEntityEmailTypeID is TL type id of MessageEntityEmail.
const MessageEntityEmailTypeID = 0x64e475c2

// construct implements constructor of MessageEntityClass.
func (m MessageEntityEmail) construct() MessageEntityClass { return &m }

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

	_ MessageEntityClass = &MessageEntityEmail{}
)

func (m *MessageEntityEmail) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Offset == 0) {
		return false
	}
	if !(m.Length == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageEntityEmail from given interface.
func (m *MessageEntityEmail) FillFrom(from interface {
	GetOffset() (value int)
	GetLength() (value int)
}) {
	m.Offset = from.GetOffset()
	m.Length = from.GetLength()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageEntityEmail) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageEntityEmail",
		ID:   MessageEntityEmailTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageEntityEmail) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityEmail#64e475c2 as nil")
	}
	b.PutID(MessageEntityEmailTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageEntityEmail) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityEmail#64e475c2 as nil")
	}
	b.PutInt(m.Offset)
	b.PutInt(m.Length)
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageEntityEmail) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityEmail#64e475c2 to nil")
	}
	if err := b.ConsumeID(MessageEntityEmailTypeID); err != nil {
		return fmt.Errorf("unable to decode messageEntityEmail#64e475c2: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageEntityEmail) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityEmail#64e475c2 to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityEmail#64e475c2: field offset: %w", err)
		}
		m.Offset = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityEmail#64e475c2: field length: %w", err)
		}
		m.Length = value
	}
	return nil
}

// GetOffset returns value of Offset field.
func (m *MessageEntityEmail) GetOffset() (value int) {
	if m == nil {
		return
	}
	return m.Offset
}

// GetLength returns value of Length field.
func (m *MessageEntityEmail) GetLength() (value int) {
	if m == nil {
		return
	}
	return m.Length
}

// MessageEntityBold represents TL type `messageEntityBold#bd610bc9`.
// Message entity representing bold text.
//
// See https://core.telegram.org/constructor/messageEntityBold for reference.
type MessageEntityBold struct {
	// Offset of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Offset int
	// Length of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Length int
}

// MessageEntityBoldTypeID is TL type id of MessageEntityBold.
const MessageEntityBoldTypeID = 0xbd610bc9

// construct implements constructor of MessageEntityClass.
func (m MessageEntityBold) construct() MessageEntityClass { return &m }

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

	_ MessageEntityClass = &MessageEntityBold{}
)

func (m *MessageEntityBold) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Offset == 0) {
		return false
	}
	if !(m.Length == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageEntityBold from given interface.
func (m *MessageEntityBold) FillFrom(from interface {
	GetOffset() (value int)
	GetLength() (value int)
}) {
	m.Offset = from.GetOffset()
	m.Length = from.GetLength()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageEntityBold) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageEntityBold",
		ID:   MessageEntityBoldTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageEntityBold) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityBold#bd610bc9 as nil")
	}
	b.PutID(MessageEntityBoldTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageEntityBold) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityBold#bd610bc9 as nil")
	}
	b.PutInt(m.Offset)
	b.PutInt(m.Length)
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageEntityBold) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityBold#bd610bc9 to nil")
	}
	if err := b.ConsumeID(MessageEntityBoldTypeID); err != nil {
		return fmt.Errorf("unable to decode messageEntityBold#bd610bc9: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageEntityBold) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityBold#bd610bc9 to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityBold#bd610bc9: field offset: %w", err)
		}
		m.Offset = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityBold#bd610bc9: field length: %w", err)
		}
		m.Length = value
	}
	return nil
}

// GetOffset returns value of Offset field.
func (m *MessageEntityBold) GetOffset() (value int) {
	if m == nil {
		return
	}
	return m.Offset
}

// GetLength returns value of Length field.
func (m *MessageEntityBold) GetLength() (value int) {
	if m == nil {
		return
	}
	return m.Length
}

// MessageEntityItalic represents TL type `messageEntityItalic#826f8b60`.
// Message entity representing italic text.
//
// See https://core.telegram.org/constructor/messageEntityItalic for reference.
type MessageEntityItalic struct {
	// Offset of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Offset int
	// Length of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Length int
}

// MessageEntityItalicTypeID is TL type id of MessageEntityItalic.
const MessageEntityItalicTypeID = 0x826f8b60

// construct implements constructor of MessageEntityClass.
func (m MessageEntityItalic) construct() MessageEntityClass { return &m }

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

	_ MessageEntityClass = &MessageEntityItalic{}
)

func (m *MessageEntityItalic) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Offset == 0) {
		return false
	}
	if !(m.Length == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageEntityItalic from given interface.
func (m *MessageEntityItalic) FillFrom(from interface {
	GetOffset() (value int)
	GetLength() (value int)
}) {
	m.Offset = from.GetOffset()
	m.Length = from.GetLength()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageEntityItalic) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageEntityItalic",
		ID:   MessageEntityItalicTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageEntityItalic) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityItalic#826f8b60 as nil")
	}
	b.PutID(MessageEntityItalicTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageEntityItalic) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityItalic#826f8b60 as nil")
	}
	b.PutInt(m.Offset)
	b.PutInt(m.Length)
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageEntityItalic) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityItalic#826f8b60 to nil")
	}
	if err := b.ConsumeID(MessageEntityItalicTypeID); err != nil {
		return fmt.Errorf("unable to decode messageEntityItalic#826f8b60: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageEntityItalic) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityItalic#826f8b60 to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityItalic#826f8b60: field offset: %w", err)
		}
		m.Offset = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityItalic#826f8b60: field length: %w", err)
		}
		m.Length = value
	}
	return nil
}

// GetOffset returns value of Offset field.
func (m *MessageEntityItalic) GetOffset() (value int) {
	if m == nil {
		return
	}
	return m.Offset
}

// GetLength returns value of Length field.
func (m *MessageEntityItalic) GetLength() (value int) {
	if m == nil {
		return
	}
	return m.Length
}

// MessageEntityCode represents TL type `messageEntityCode#28a20571`.
// Message entity representing a codeblock.
//
// See https://core.telegram.org/constructor/messageEntityCode for reference.
type MessageEntityCode struct {
	// Offset of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Offset int
	// Length of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Length int
}

// MessageEntityCodeTypeID is TL type id of MessageEntityCode.
const MessageEntityCodeTypeID = 0x28a20571

// construct implements constructor of MessageEntityClass.
func (m MessageEntityCode) construct() MessageEntityClass { return &m }

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

	_ MessageEntityClass = &MessageEntityCode{}
)

func (m *MessageEntityCode) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Offset == 0) {
		return false
	}
	if !(m.Length == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageEntityCode from given interface.
func (m *MessageEntityCode) FillFrom(from interface {
	GetOffset() (value int)
	GetLength() (value int)
}) {
	m.Offset = from.GetOffset()
	m.Length = from.GetLength()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageEntityCode) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageEntityCode",
		ID:   MessageEntityCodeTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageEntityCode) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityCode#28a20571 as nil")
	}
	b.PutID(MessageEntityCodeTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageEntityCode) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityCode#28a20571 as nil")
	}
	b.PutInt(m.Offset)
	b.PutInt(m.Length)
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageEntityCode) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityCode#28a20571 to nil")
	}
	if err := b.ConsumeID(MessageEntityCodeTypeID); err != nil {
		return fmt.Errorf("unable to decode messageEntityCode#28a20571: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageEntityCode) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityCode#28a20571 to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityCode#28a20571: field offset: %w", err)
		}
		m.Offset = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityCode#28a20571: field length: %w", err)
		}
		m.Length = value
	}
	return nil
}

// GetOffset returns value of Offset field.
func (m *MessageEntityCode) GetOffset() (value int) {
	if m == nil {
		return
	}
	return m.Offset
}

// GetLength returns value of Length field.
func (m *MessageEntityCode) GetLength() (value int) {
	if m == nil {
		return
	}
	return m.Length
}

// MessageEntityPre represents TL type `messageEntityPre#73924be0`.
// Message entity representing a preformatted codeblock, allowing the user to specify a
// programming language for the codeblock.
//
// See https://core.telegram.org/constructor/messageEntityPre for reference.
type MessageEntityPre struct {
	// Offset of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Offset int
	// Length of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Length int
	// Programming language of the code
	Language string
}

// MessageEntityPreTypeID is TL type id of MessageEntityPre.
const MessageEntityPreTypeID = 0x73924be0

// construct implements constructor of MessageEntityClass.
func (m MessageEntityPre) construct() MessageEntityClass { return &m }

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

	_ MessageEntityClass = &MessageEntityPre{}
)

func (m *MessageEntityPre) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Offset == 0) {
		return false
	}
	if !(m.Length == 0) {
		return false
	}
	if !(m.Language == "") {
		return false
	}

	return true
}

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

// FillFrom fills MessageEntityPre from given interface.
func (m *MessageEntityPre) FillFrom(from interface {
	GetOffset() (value int)
	GetLength() (value int)
	GetLanguage() (value string)
}) {
	m.Offset = from.GetOffset()
	m.Length = from.GetLength()
	m.Language = from.GetLanguage()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageEntityPre) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageEntityPre",
		ID:   MessageEntityPreTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
		{
			Name:       "Language",
			SchemaName: "language",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageEntityPre) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityPre#73924be0 as nil")
	}
	b.PutID(MessageEntityPreTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageEntityPre) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityPre#73924be0 as nil")
	}
	b.PutInt(m.Offset)
	b.PutInt(m.Length)
	b.PutString(m.Language)
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageEntityPre) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityPre#73924be0 to nil")
	}
	if err := b.ConsumeID(MessageEntityPreTypeID); err != nil {
		return fmt.Errorf("unable to decode messageEntityPre#73924be0: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageEntityPre) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityPre#73924be0 to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityPre#73924be0: field offset: %w", err)
		}
		m.Offset = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityPre#73924be0: field length: %w", err)
		}
		m.Length = value
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityPre#73924be0: field language: %w", err)
		}
		m.Language = value
	}
	return nil
}

// GetOffset returns value of Offset field.
func (m *MessageEntityPre) GetOffset() (value int) {
	if m == nil {
		return
	}
	return m.Offset
}

// GetLength returns value of Length field.
func (m *MessageEntityPre) GetLength() (value int) {
	if m == nil {
		return
	}
	return m.Length
}

// GetLanguage returns value of Language field.
func (m *MessageEntityPre) GetLanguage() (value string) {
	if m == nil {
		return
	}
	return m.Language
}

// MessageEntityTextURL represents TL type `messageEntityTextUrl#76a6d327`.
// Message entity representing a text url¹: for in-text urls like https://google.com²
// use messageEntityUrl³.
// Note that an additional confirmation popup with the full URL must be displayed to the
// user before opening this link, unless the domain satisfies the conditions specified in
// the domain whitelist documentation »¹.
//
// Links:
//  1. https://google.com
//  2. https://google.com
//  3. https://core.telegram.org/constructor/messageEntityUrl
//  4. https://core.telegram.org/api/config#whitelisted-domains
//
// See https://core.telegram.org/constructor/messageEntityTextUrl for reference.
type MessageEntityTextURL struct {
	// Offset of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Offset int
	// Length of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Length int
	// The actual URL
	URL string
}

// MessageEntityTextURLTypeID is TL type id of MessageEntityTextURL.
const MessageEntityTextURLTypeID = 0x76a6d327

// construct implements constructor of MessageEntityClass.
func (m MessageEntityTextURL) construct() MessageEntityClass { return &m }

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

	_ MessageEntityClass = &MessageEntityTextURL{}
)

func (m *MessageEntityTextURL) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Offset == 0) {
		return false
	}
	if !(m.Length == 0) {
		return false
	}
	if !(m.URL == "") {
		return false
	}

	return true
}

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

// FillFrom fills MessageEntityTextURL from given interface.
func (m *MessageEntityTextURL) FillFrom(from interface {
	GetOffset() (value int)
	GetLength() (value int)
	GetURL() (value string)
}) {
	m.Offset = from.GetOffset()
	m.Length = from.GetLength()
	m.URL = from.GetURL()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageEntityTextURL) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageEntityTextUrl",
		ID:   MessageEntityTextURLTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
		{
			Name:       "URL",
			SchemaName: "url",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageEntityTextURL) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityTextUrl#76a6d327 as nil")
	}
	b.PutID(MessageEntityTextURLTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageEntityTextURL) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityTextUrl#76a6d327 as nil")
	}
	b.PutInt(m.Offset)
	b.PutInt(m.Length)
	b.PutString(m.URL)
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageEntityTextURL) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityTextUrl#76a6d327 to nil")
	}
	if err := b.ConsumeID(MessageEntityTextURLTypeID); err != nil {
		return fmt.Errorf("unable to decode messageEntityTextUrl#76a6d327: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageEntityTextURL) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityTextUrl#76a6d327 to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityTextUrl#76a6d327: field offset: %w", err)
		}
		m.Offset = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityTextUrl#76a6d327: field length: %w", err)
		}
		m.Length = value
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityTextUrl#76a6d327: field url: %w", err)
		}
		m.URL = value
	}
	return nil
}

// GetOffset returns value of Offset field.
func (m *MessageEntityTextURL) GetOffset() (value int) {
	if m == nil {
		return
	}
	return m.Offset
}

// GetLength returns value of Length field.
func (m *MessageEntityTextURL) GetLength() (value int) {
	if m == nil {
		return
	}
	return m.Length
}

// GetURL returns value of URL field.
func (m *MessageEntityTextURL) GetURL() (value string) {
	if m == nil {
		return
	}
	return m.URL
}

// MessageEntityMentionName represents TL type `messageEntityMentionName#dc7b1140`.
// Message entity representing a user mention¹: for creating a mention use
// inputMessageEntityMentionName².
//
// Links:
//  1. https://core.telegram.org/api/mentions
//  2. https://core.telegram.org/constructor/inputMessageEntityMentionName
//
// See https://core.telegram.org/constructor/messageEntityMentionName for reference.
type MessageEntityMentionName struct {
	// Offset of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Offset int
	// Length of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Length int
	// Identifier of the user that was mentioned
	UserID int64
}

// MessageEntityMentionNameTypeID is TL type id of MessageEntityMentionName.
const MessageEntityMentionNameTypeID = 0xdc7b1140

// construct implements constructor of MessageEntityClass.
func (m MessageEntityMentionName) construct() MessageEntityClass { return &m }

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

	_ MessageEntityClass = &MessageEntityMentionName{}
)

func (m *MessageEntityMentionName) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Offset == 0) {
		return false
	}
	if !(m.Length == 0) {
		return false
	}
	if !(m.UserID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageEntityMentionName from given interface.
func (m *MessageEntityMentionName) FillFrom(from interface {
	GetOffset() (value int)
	GetLength() (value int)
	GetUserID() (value int64)
}) {
	m.Offset = from.GetOffset()
	m.Length = from.GetLength()
	m.UserID = from.GetUserID()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageEntityMentionName) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageEntityMentionName",
		ID:   MessageEntityMentionNameTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageEntityMentionName) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityMentionName#dc7b1140 as nil")
	}
	b.PutID(MessageEntityMentionNameTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageEntityMentionName) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityMentionName#dc7b1140 as nil")
	}
	b.PutInt(m.Offset)
	b.PutInt(m.Length)
	b.PutLong(m.UserID)
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageEntityMentionName) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityMentionName#dc7b1140 to nil")
	}
	if err := b.ConsumeID(MessageEntityMentionNameTypeID); err != nil {
		return fmt.Errorf("unable to decode messageEntityMentionName#dc7b1140: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageEntityMentionName) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityMentionName#dc7b1140 to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityMentionName#dc7b1140: field offset: %w", err)
		}
		m.Offset = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityMentionName#dc7b1140: field length: %w", err)
		}
		m.Length = value
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityMentionName#dc7b1140: field user_id: %w", err)
		}
		m.UserID = value
	}
	return nil
}

// GetOffset returns value of Offset field.
func (m *MessageEntityMentionName) GetOffset() (value int) {
	if m == nil {
		return
	}
	return m.Offset
}

// GetLength returns value of Length field.
func (m *MessageEntityMentionName) GetLength() (value int) {
	if m == nil {
		return
	}
	return m.Length
}

// GetUserID returns value of UserID field.
func (m *MessageEntityMentionName) GetUserID() (value int64) {
	if m == nil {
		return
	}
	return m.UserID
}

// InputMessageEntityMentionName represents TL type `inputMessageEntityMentionName#208e68c9`.
// Message entity that can be used to create a user user mention¹: received mentions use
// the messageEntityMentionName² constructor, instead.
//
// Links:
//  1. https://core.telegram.org/api/mentions
//  2. https://core.telegram.org/constructor/messageEntityMentionName
//
// See https://core.telegram.org/constructor/inputMessageEntityMentionName for reference.
type InputMessageEntityMentionName struct {
	// Offset of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Offset int
	// Length of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Length int
	// Identifier of the user that was mentioned
	UserID InputUserClass
}

// InputMessageEntityMentionNameTypeID is TL type id of InputMessageEntityMentionName.
const InputMessageEntityMentionNameTypeID = 0x208e68c9

// construct implements constructor of MessageEntityClass.
func (i InputMessageEntityMentionName) construct() MessageEntityClass { return &i }

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

	_ MessageEntityClass = &InputMessageEntityMentionName{}
)

func (i *InputMessageEntityMentionName) Zero() bool {
	if i == nil {
		return true
	}
	if !(i.Offset == 0) {
		return false
	}
	if !(i.Length == 0) {
		return false
	}
	if !(i.UserID == nil) {
		return false
	}

	return true
}

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

// FillFrom fills InputMessageEntityMentionName from given interface.
func (i *InputMessageEntityMentionName) FillFrom(from interface {
	GetOffset() (value int)
	GetLength() (value int)
	GetUserID() (value InputUserClass)
}) {
	i.Offset = from.GetOffset()
	i.Length = from.GetLength()
	i.UserID = from.GetUserID()
}

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

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

// TypeInfo returns info about TL type.
func (i *InputMessageEntityMentionName) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inputMessageEntityMentionName",
		ID:   InputMessageEntityMentionNameTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (i *InputMessageEntityMentionName) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputMessageEntityMentionName#208e68c9 as nil")
	}
	b.PutID(InputMessageEntityMentionNameTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InputMessageEntityMentionName) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputMessageEntityMentionName#208e68c9 as nil")
	}
	b.PutInt(i.Offset)
	b.PutInt(i.Length)
	if i.UserID == nil {
		return fmt.Errorf("unable to encode inputMessageEntityMentionName#208e68c9: field user_id is nil")
	}
	if err := i.UserID.Encode(b); err != nil {
		return fmt.Errorf("unable to encode inputMessageEntityMentionName#208e68c9: field user_id: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (i *InputMessageEntityMentionName) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputMessageEntityMentionName#208e68c9 to nil")
	}
	if err := b.ConsumeID(InputMessageEntityMentionNameTypeID); err != nil {
		return fmt.Errorf("unable to decode inputMessageEntityMentionName#208e68c9: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *InputMessageEntityMentionName) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputMessageEntityMentionName#208e68c9 to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode inputMessageEntityMentionName#208e68c9: field offset: %w", err)
		}
		i.Offset = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode inputMessageEntityMentionName#208e68c9: field length: %w", err)
		}
		i.Length = value
	}
	{
		value, err := DecodeInputUser(b)
		if err != nil {
			return fmt.Errorf("unable to decode inputMessageEntityMentionName#208e68c9: field user_id: %w", err)
		}
		i.UserID = value
	}
	return nil
}

// GetOffset returns value of Offset field.
func (i *InputMessageEntityMentionName) GetOffset() (value int) {
	if i == nil {
		return
	}
	return i.Offset
}

// GetLength returns value of Length field.
func (i *InputMessageEntityMentionName) GetLength() (value int) {
	if i == nil {
		return
	}
	return i.Length
}

// GetUserID returns value of UserID field.
func (i *InputMessageEntityMentionName) GetUserID() (value InputUserClass) {
	if i == nil {
		return
	}
	return i.UserID
}

// MessageEntityPhone represents TL type `messageEntityPhone#9b69e34b`.
// Message entity representing a phone number.
//
// See https://core.telegram.org/constructor/messageEntityPhone for reference.
type MessageEntityPhone struct {
	// Offset of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Offset int
	// Length of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Length int
}

// MessageEntityPhoneTypeID is TL type id of MessageEntityPhone.
const MessageEntityPhoneTypeID = 0x9b69e34b

// construct implements constructor of MessageEntityClass.
func (m MessageEntityPhone) construct() MessageEntityClass { return &m }

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

	_ MessageEntityClass = &MessageEntityPhone{}
)

func (m *MessageEntityPhone) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Offset == 0) {
		return false
	}
	if !(m.Length == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageEntityPhone from given interface.
func (m *MessageEntityPhone) FillFrom(from interface {
	GetOffset() (value int)
	GetLength() (value int)
}) {
	m.Offset = from.GetOffset()
	m.Length = from.GetLength()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageEntityPhone) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageEntityPhone",
		ID:   MessageEntityPhoneTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageEntityPhone) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityPhone#9b69e34b as nil")
	}
	b.PutID(MessageEntityPhoneTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageEntityPhone) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityPhone#9b69e34b as nil")
	}
	b.PutInt(m.Offset)
	b.PutInt(m.Length)
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageEntityPhone) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityPhone#9b69e34b to nil")
	}
	if err := b.ConsumeID(MessageEntityPhoneTypeID); err != nil {
		return fmt.Errorf("unable to decode messageEntityPhone#9b69e34b: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageEntityPhone) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityPhone#9b69e34b to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityPhone#9b69e34b: field offset: %w", err)
		}
		m.Offset = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityPhone#9b69e34b: field length: %w", err)
		}
		m.Length = value
	}
	return nil
}

// GetOffset returns value of Offset field.
func (m *MessageEntityPhone) GetOffset() (value int) {
	if m == nil {
		return
	}
	return m.Offset
}

// GetLength returns value of Length field.
func (m *MessageEntityPhone) GetLength() (value int) {
	if m == nil {
		return
	}
	return m.Length
}

// MessageEntityCashtag represents TL type `messageEntityCashtag#4c4e743f`.
// Message entity representing a $cashtag.
//
// See https://core.telegram.org/constructor/messageEntityCashtag for reference.
type MessageEntityCashtag struct {
	// Offset of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Offset int
	// Length of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Length int
}

// MessageEntityCashtagTypeID is TL type id of MessageEntityCashtag.
const MessageEntityCashtagTypeID = 0x4c4e743f

// construct implements constructor of MessageEntityClass.
func (m MessageEntityCashtag) construct() MessageEntityClass { return &m }

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

	_ MessageEntityClass = &MessageEntityCashtag{}
)

func (m *MessageEntityCashtag) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Offset == 0) {
		return false
	}
	if !(m.Length == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageEntityCashtag from given interface.
func (m *MessageEntityCashtag) FillFrom(from interface {
	GetOffset() (value int)
	GetLength() (value int)
}) {
	m.Offset = from.GetOffset()
	m.Length = from.GetLength()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageEntityCashtag) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageEntityCashtag",
		ID:   MessageEntityCashtagTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageEntityCashtag) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityCashtag#4c4e743f as nil")
	}
	b.PutID(MessageEntityCashtagTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageEntityCashtag) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityCashtag#4c4e743f as nil")
	}
	b.PutInt(m.Offset)
	b.PutInt(m.Length)
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageEntityCashtag) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityCashtag#4c4e743f to nil")
	}
	if err := b.ConsumeID(MessageEntityCashtagTypeID); err != nil {
		return fmt.Errorf("unable to decode messageEntityCashtag#4c4e743f: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageEntityCashtag) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityCashtag#4c4e743f to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityCashtag#4c4e743f: field offset: %w", err)
		}
		m.Offset = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityCashtag#4c4e743f: field length: %w", err)
		}
		m.Length = value
	}
	return nil
}

// GetOffset returns value of Offset field.
func (m *MessageEntityCashtag) GetOffset() (value int) {
	if m == nil {
		return
	}
	return m.Offset
}

// GetLength returns value of Length field.
func (m *MessageEntityCashtag) GetLength() (value int) {
	if m == nil {
		return
	}
	return m.Length
}

// MessageEntityUnderline represents TL type `messageEntityUnderline#9c4e7e8b`.
// Message entity representing underlined text.
//
// See https://core.telegram.org/constructor/messageEntityUnderline for reference.
type MessageEntityUnderline struct {
	// Offset of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Offset int
	// Length of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Length int
}

// MessageEntityUnderlineTypeID is TL type id of MessageEntityUnderline.
const MessageEntityUnderlineTypeID = 0x9c4e7e8b

// construct implements constructor of MessageEntityClass.
func (m MessageEntityUnderline) construct() MessageEntityClass { return &m }

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

	_ MessageEntityClass = &MessageEntityUnderline{}
)

func (m *MessageEntityUnderline) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Offset == 0) {
		return false
	}
	if !(m.Length == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageEntityUnderline from given interface.
func (m *MessageEntityUnderline) FillFrom(from interface {
	GetOffset() (value int)
	GetLength() (value int)
}) {
	m.Offset = from.GetOffset()
	m.Length = from.GetLength()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageEntityUnderline) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageEntityUnderline",
		ID:   MessageEntityUnderlineTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageEntityUnderline) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityUnderline#9c4e7e8b as nil")
	}
	b.PutID(MessageEntityUnderlineTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageEntityUnderline) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityUnderline#9c4e7e8b as nil")
	}
	b.PutInt(m.Offset)
	b.PutInt(m.Length)
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageEntityUnderline) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityUnderline#9c4e7e8b to nil")
	}
	if err := b.ConsumeID(MessageEntityUnderlineTypeID); err != nil {
		return fmt.Errorf("unable to decode messageEntityUnderline#9c4e7e8b: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageEntityUnderline) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityUnderline#9c4e7e8b to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityUnderline#9c4e7e8b: field offset: %w", err)
		}
		m.Offset = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityUnderline#9c4e7e8b: field length: %w", err)
		}
		m.Length = value
	}
	return nil
}

// GetOffset returns value of Offset field.
func (m *MessageEntityUnderline) GetOffset() (value int) {
	if m == nil {
		return
	}
	return m.Offset
}

// GetLength returns value of Length field.
func (m *MessageEntityUnderline) GetLength() (value int) {
	if m == nil {
		return
	}
	return m.Length
}

// MessageEntityStrike represents TL type `messageEntityStrike#bf0693d4`.
// Message entity representing strikethrough text.
//
// See https://core.telegram.org/constructor/messageEntityStrike for reference.
type MessageEntityStrike struct {
	// Offset of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Offset int
	// Length of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Length int
}

// MessageEntityStrikeTypeID is TL type id of MessageEntityStrike.
const MessageEntityStrikeTypeID = 0xbf0693d4

// construct implements constructor of MessageEntityClass.
func (m MessageEntityStrike) construct() MessageEntityClass { return &m }

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

	_ MessageEntityClass = &MessageEntityStrike{}
)

func (m *MessageEntityStrike) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Offset == 0) {
		return false
	}
	if !(m.Length == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageEntityStrike from given interface.
func (m *MessageEntityStrike) FillFrom(from interface {
	GetOffset() (value int)
	GetLength() (value int)
}) {
	m.Offset = from.GetOffset()
	m.Length = from.GetLength()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageEntityStrike) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageEntityStrike",
		ID:   MessageEntityStrikeTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageEntityStrike) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityStrike#bf0693d4 as nil")
	}
	b.PutID(MessageEntityStrikeTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageEntityStrike) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityStrike#bf0693d4 as nil")
	}
	b.PutInt(m.Offset)
	b.PutInt(m.Length)
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageEntityStrike) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityStrike#bf0693d4 to nil")
	}
	if err := b.ConsumeID(MessageEntityStrikeTypeID); err != nil {
		return fmt.Errorf("unable to decode messageEntityStrike#bf0693d4: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageEntityStrike) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityStrike#bf0693d4 to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityStrike#bf0693d4: field offset: %w", err)
		}
		m.Offset = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityStrike#bf0693d4: field length: %w", err)
		}
		m.Length = value
	}
	return nil
}

// GetOffset returns value of Offset field.
func (m *MessageEntityStrike) GetOffset() (value int) {
	if m == nil {
		return
	}
	return m.Offset
}

// GetLength returns value of Length field.
func (m *MessageEntityStrike) GetLength() (value int) {
	if m == nil {
		return
	}
	return m.Length
}

// MessageEntityBankCard represents TL type `messageEntityBankCard#761e6af4`.
// Indicates a credit card number
//
// See https://core.telegram.org/constructor/messageEntityBankCard for reference.
type MessageEntityBankCard struct {
	// Offset of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Offset int
	// Length of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Length int
}

// MessageEntityBankCardTypeID is TL type id of MessageEntityBankCard.
const MessageEntityBankCardTypeID = 0x761e6af4

// construct implements constructor of MessageEntityClass.
func (m MessageEntityBankCard) construct() MessageEntityClass { return &m }

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

	_ MessageEntityClass = &MessageEntityBankCard{}
)

func (m *MessageEntityBankCard) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Offset == 0) {
		return false
	}
	if !(m.Length == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageEntityBankCard from given interface.
func (m *MessageEntityBankCard) FillFrom(from interface {
	GetOffset() (value int)
	GetLength() (value int)
}) {
	m.Offset = from.GetOffset()
	m.Length = from.GetLength()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageEntityBankCard) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageEntityBankCard",
		ID:   MessageEntityBankCardTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageEntityBankCard) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityBankCard#761e6af4 as nil")
	}
	b.PutID(MessageEntityBankCardTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageEntityBankCard) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityBankCard#761e6af4 as nil")
	}
	b.PutInt(m.Offset)
	b.PutInt(m.Length)
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageEntityBankCard) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityBankCard#761e6af4 to nil")
	}
	if err := b.ConsumeID(MessageEntityBankCardTypeID); err != nil {
		return fmt.Errorf("unable to decode messageEntityBankCard#761e6af4: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageEntityBankCard) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityBankCard#761e6af4 to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityBankCard#761e6af4: field offset: %w", err)
		}
		m.Offset = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityBankCard#761e6af4: field length: %w", err)
		}
		m.Length = value
	}
	return nil
}

// GetOffset returns value of Offset field.
func (m *MessageEntityBankCard) GetOffset() (value int) {
	if m == nil {
		return
	}
	return m.Offset
}

// GetLength returns value of Length field.
func (m *MessageEntityBankCard) GetLength() (value int) {
	if m == nil {
		return
	}
	return m.Length
}

// MessageEntitySpoiler represents TL type `messageEntitySpoiler#32ca960f`.
// Message entity representing a spoiler
//
// See https://core.telegram.org/constructor/messageEntitySpoiler for reference.
type MessageEntitySpoiler struct {
	// Offset of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Offset int
	// Length of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Length int
}

// MessageEntitySpoilerTypeID is TL type id of MessageEntitySpoiler.
const MessageEntitySpoilerTypeID = 0x32ca960f

// construct implements constructor of MessageEntityClass.
func (m MessageEntitySpoiler) construct() MessageEntityClass { return &m }

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

	_ MessageEntityClass = &MessageEntitySpoiler{}
)

func (m *MessageEntitySpoiler) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Offset == 0) {
		return false
	}
	if !(m.Length == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageEntitySpoiler from given interface.
func (m *MessageEntitySpoiler) FillFrom(from interface {
	GetOffset() (value int)
	GetLength() (value int)
}) {
	m.Offset = from.GetOffset()
	m.Length = from.GetLength()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageEntitySpoiler) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageEntitySpoiler",
		ID:   MessageEntitySpoilerTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageEntitySpoiler) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntitySpoiler#32ca960f as nil")
	}
	b.PutID(MessageEntitySpoilerTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageEntitySpoiler) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntitySpoiler#32ca960f as nil")
	}
	b.PutInt(m.Offset)
	b.PutInt(m.Length)
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageEntitySpoiler) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntitySpoiler#32ca960f to nil")
	}
	if err := b.ConsumeID(MessageEntitySpoilerTypeID); err != nil {
		return fmt.Errorf("unable to decode messageEntitySpoiler#32ca960f: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageEntitySpoiler) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntitySpoiler#32ca960f to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntitySpoiler#32ca960f: field offset: %w", err)
		}
		m.Offset = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntitySpoiler#32ca960f: field length: %w", err)
		}
		m.Length = value
	}
	return nil
}

// GetOffset returns value of Offset field.
func (m *MessageEntitySpoiler) GetOffset() (value int) {
	if m == nil {
		return
	}
	return m.Offset
}

// GetLength returns value of Length field.
func (m *MessageEntitySpoiler) GetLength() (value int) {
	if m == nil {
		return
	}
	return m.Length
}

// MessageEntityCustomEmoji represents TL type `messageEntityCustomEmoji#c8cf05f8`.
// Represents a custom emoji.
// Note that this entity must wrap exactly one regular emoji (the one contained in
// documentAttributeCustomEmoji¹.alt) in the related text, otherwise the server will
// ignore it.
//
// Links:
//  1. https://core.telegram.org/constructor/documentAttributeCustomEmoji
//
// See https://core.telegram.org/constructor/messageEntityCustomEmoji for reference.
type MessageEntityCustomEmoji struct {
	// Offset of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Offset int
	// Length of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Length int
	// Document ID of the custom emoji¹, use messages.getCustomEmojiDocuments² to fetch the
	// emoji animation and the actual emoji it represents.
	//
	// Links:
	//  1) https://core.telegram.org/api/custom-emoji
	//  2) https://core.telegram.org/method/messages.getCustomEmojiDocuments
	DocumentID int64
}

// MessageEntityCustomEmojiTypeID is TL type id of MessageEntityCustomEmoji.
const MessageEntityCustomEmojiTypeID = 0xc8cf05f8

// construct implements constructor of MessageEntityClass.
func (m MessageEntityCustomEmoji) construct() MessageEntityClass { return &m }

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

	_ MessageEntityClass = &MessageEntityCustomEmoji{}
)

func (m *MessageEntityCustomEmoji) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Offset == 0) {
		return false
	}
	if !(m.Length == 0) {
		return false
	}
	if !(m.DocumentID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageEntityCustomEmoji from given interface.
func (m *MessageEntityCustomEmoji) FillFrom(from interface {
	GetOffset() (value int)
	GetLength() (value int)
	GetDocumentID() (value int64)
}) {
	m.Offset = from.GetOffset()
	m.Length = from.GetLength()
	m.DocumentID = from.GetDocumentID()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageEntityCustomEmoji) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageEntityCustomEmoji",
		ID:   MessageEntityCustomEmojiTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
		{
			Name:       "DocumentID",
			SchemaName: "document_id",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageEntityCustomEmoji) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityCustomEmoji#c8cf05f8 as nil")
	}
	b.PutID(MessageEntityCustomEmojiTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageEntityCustomEmoji) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityCustomEmoji#c8cf05f8 as nil")
	}
	b.PutInt(m.Offset)
	b.PutInt(m.Length)
	b.PutLong(m.DocumentID)
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageEntityCustomEmoji) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityCustomEmoji#c8cf05f8 to nil")
	}
	if err := b.ConsumeID(MessageEntityCustomEmojiTypeID); err != nil {
		return fmt.Errorf("unable to decode messageEntityCustomEmoji#c8cf05f8: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageEntityCustomEmoji) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityCustomEmoji#c8cf05f8 to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityCustomEmoji#c8cf05f8: field offset: %w", err)
		}
		m.Offset = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityCustomEmoji#c8cf05f8: field length: %w", err)
		}
		m.Length = value
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityCustomEmoji#c8cf05f8: field document_id: %w", err)
		}
		m.DocumentID = value
	}
	return nil
}

// GetOffset returns value of Offset field.
func (m *MessageEntityCustomEmoji) GetOffset() (value int) {
	if m == nil {
		return
	}
	return m.Offset
}

// GetLength returns value of Length field.
func (m *MessageEntityCustomEmoji) GetLength() (value int) {
	if m == nil {
		return
	}
	return m.Length
}

// GetDocumentID returns value of DocumentID field.
func (m *MessageEntityCustomEmoji) GetDocumentID() (value int64) {
	if m == nil {
		return
	}
	return m.DocumentID
}

// MessageEntityBlockquote represents TL type `messageEntityBlockquote#f1ccaaac`.
// Message entity representing a block quote.
//
// See https://core.telegram.org/constructor/messageEntityBlockquote for reference.
type MessageEntityBlockquote struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the quote is collapsed by default.
	Collapsed bool
	// Offset of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Offset int
	// Length of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	Length int
}

// MessageEntityBlockquoteTypeID is TL type id of MessageEntityBlockquote.
const MessageEntityBlockquoteTypeID = 0xf1ccaaac

// construct implements constructor of MessageEntityClass.
func (m MessageEntityBlockquote) construct() MessageEntityClass { return &m }

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

	_ MessageEntityClass = &MessageEntityBlockquote{}
)

func (m *MessageEntityBlockquote) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.Collapsed == false) {
		return false
	}
	if !(m.Offset == 0) {
		return false
	}
	if !(m.Length == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageEntityBlockquote from given interface.
func (m *MessageEntityBlockquote) FillFrom(from interface {
	GetCollapsed() (value bool)
	GetOffset() (value int)
	GetLength() (value int)
}) {
	m.Collapsed = from.GetCollapsed()
	m.Offset = from.GetOffset()
	m.Length = from.GetLength()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageEntityBlockquote) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageEntityBlockquote",
		ID:   MessageEntityBlockquoteTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Collapsed",
			SchemaName: "collapsed",
			Null:       !m.Flags.Has(0),
		},
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return typ
}

// SetFlags sets flags for non-zero fields.
func (m *MessageEntityBlockquote) SetFlags() {
	if !(m.Collapsed == false) {
		m.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func (m *MessageEntityBlockquote) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityBlockquote#f1ccaaac as nil")
	}
	b.PutID(MessageEntityBlockquoteTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageEntityBlockquote) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageEntityBlockquote#f1ccaaac as nil")
	}
	m.SetFlags()
	if err := m.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageEntityBlockquote#f1ccaaac: field flags: %w", err)
	}
	b.PutInt(m.Offset)
	b.PutInt(m.Length)
	return nil
}

// Decode implements bin.Decoder.
func (m *MessageEntityBlockquote) Decode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityBlockquote#f1ccaaac to nil")
	}
	if err := b.ConsumeID(MessageEntityBlockquoteTypeID); err != nil {
		return fmt.Errorf("unable to decode messageEntityBlockquote#f1ccaaac: %w", err)
	}
	return m.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (m *MessageEntityBlockquote) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageEntityBlockquote#f1ccaaac to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageEntityBlockquote#f1ccaaac: field flags: %w", err)
		}
	}
	m.Collapsed = m.Flags.Has(0)
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityBlockquote#f1ccaaac: field offset: %w", err)
		}
		m.Offset = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageEntityBlockquote#f1ccaaac: field length: %w", err)
		}
		m.Length = value
	}
	return nil
}

// SetCollapsed sets value of Collapsed conditional field.
func (m *MessageEntityBlockquote) SetCollapsed(value bool) {
	if value {
		m.Flags.Set(0)
		m.Collapsed = true
	} else {
		m.Flags.Unset(0)
		m.Collapsed = false
	}
}

// GetCollapsed returns value of Collapsed conditional field.
func (m *MessageEntityBlockquote) GetCollapsed() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(0)
}

// GetOffset returns value of Offset field.
func (m *MessageEntityBlockquote) GetOffset() (value int) {
	if m == nil {
		return
	}
	return m.Offset
}

// GetLength returns value of Length field.
func (m *MessageEntityBlockquote) GetLength() (value int) {
	if m == nil {
		return
	}
	return m.Length
}

// MessageEntityClassName is schema name of MessageEntityClass.
const MessageEntityClassName = "MessageEntity"

// MessageEntityClass represents MessageEntity generic type.
//
// See https://core.telegram.org/type/MessageEntity for reference.
//
// Example:
//
//	g, err := tg.DecodeMessageEntity(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.MessageEntityUnknown: // messageEntityUnknown#bb92ba95
//	case *tg.MessageEntityMention: // messageEntityMention#fa04579d
//	case *tg.MessageEntityHashtag: // messageEntityHashtag#6f635b0d
//	case *tg.MessageEntityBotCommand: // messageEntityBotCommand#6cef8ac7
//	case *tg.MessageEntityURL: // messageEntityUrl#6ed02538
//	case *tg.MessageEntityEmail: // messageEntityEmail#64e475c2
//	case *tg.MessageEntityBold: // messageEntityBold#bd610bc9
//	case *tg.MessageEntityItalic: // messageEntityItalic#826f8b60
//	case *tg.MessageEntityCode: // messageEntityCode#28a20571
//	case *tg.MessageEntityPre: // messageEntityPre#73924be0
//	case *tg.MessageEntityTextURL: // messageEntityTextUrl#76a6d327
//	case *tg.MessageEntityMentionName: // messageEntityMentionName#dc7b1140
//	case *tg.InputMessageEntityMentionName: // inputMessageEntityMentionName#208e68c9
//	case *tg.MessageEntityPhone: // messageEntityPhone#9b69e34b
//	case *tg.MessageEntityCashtag: // messageEntityCashtag#4c4e743f
//	case *tg.MessageEntityUnderline: // messageEntityUnderline#9c4e7e8b
//	case *tg.MessageEntityStrike: // messageEntityStrike#bf0693d4
//	case *tg.MessageEntityBankCard: // messageEntityBankCard#761e6af4
//	case *tg.MessageEntitySpoiler: // messageEntitySpoiler#32ca960f
//	case *tg.MessageEntityCustomEmoji: // messageEntityCustomEmoji#c8cf05f8
//	case *tg.MessageEntityBlockquote: // messageEntityBlockquote#f1ccaaac
//	default: panic(v)
//	}
type MessageEntityClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() MessageEntityClass

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

	// Offset of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	GetOffset() (value int)

	// Length of message entity within message (in UTF-16 code units¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/entities#entity-length
	GetLength() (value int)
}

// DecodeMessageEntity implements binary de-serialization for MessageEntityClass.
func DecodeMessageEntity(buf *bin.Buffer) (MessageEntityClass, error) {
	id, err := buf.PeekID()
	if err != nil {
		return nil, err
	}
	switch id {
	case MessageEntityUnknownTypeID:
		// Decoding messageEntityUnknown#bb92ba95.
		v := MessageEntityUnknown{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err)
		}
		return &v, nil
	case MessageEntityMentionTypeID:
		// Decoding messageEntityMention#fa04579d.
		v := MessageEntityMention{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err)
		}
		return &v, nil
	case MessageEntityHashtagTypeID:
		// Decoding messageEntityHashtag#6f635b0d.
		v := MessageEntityHashtag{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err)
		}
		return &v, nil
	case MessageEntityBotCommandTypeID:
		// Decoding messageEntityBotCommand#6cef8ac7.
		v := MessageEntityBotCommand{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err)
		}
		return &v, nil
	case MessageEntityURLTypeID:
		// Decoding messageEntityUrl#6ed02538.
		v := MessageEntityURL{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err)
		}
		return &v, nil
	case MessageEntityEmailTypeID:
		// Decoding messageEntityEmail#64e475c2.
		v := MessageEntityEmail{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err)
		}
		return &v, nil
	case MessageEntityBoldTypeID:
		// Decoding messageEntityBold#bd610bc9.
		v := MessageEntityBold{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err)
		}
		return &v, nil
	case MessageEntityItalicTypeID:
		// Decoding messageEntityItalic#826f8b60.
		v := MessageEntityItalic{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err)
		}
		return &v, nil
	case MessageEntityCodeTypeID:
		// Decoding messageEntityCode#28a20571.
		v := MessageEntityCode{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err)
		}
		return &v, nil
	case MessageEntityPreTypeID:
		// Decoding messageEntityPre#73924be0.
		v := MessageEntityPre{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err)
		}
		return &v, nil
	case MessageEntityTextURLTypeID:
		// Decoding messageEntityTextUrl#76a6d327.
		v := MessageEntityTextURL{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err)
		}
		return &v, nil
	case MessageEntityMentionNameTypeID:
		// Decoding messageEntityMentionName#dc7b1140.
		v := MessageEntityMentionName{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err)
		}
		return &v, nil
	case InputMessageEntityMentionNameTypeID:
		// Decoding inputMessageEntityMentionName#208e68c9.
		v := InputMessageEntityMentionName{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err)
		}
		return &v, nil
	case MessageEntityPhoneTypeID:
		// Decoding messageEntityPhone#9b69e34b.
		v := MessageEntityPhone{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err)
		}
		return &v, nil
	case MessageEntityCashtagTypeID:
		// Decoding messageEntityCashtag#4c4e743f.
		v := MessageEntityCashtag{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err)
		}
		return &v, nil
	case MessageEntityUnderlineTypeID:
		// Decoding messageEntityUnderline#9c4e7e8b.
		v := MessageEntityUnderline{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err)
		}
		return &v, nil
	case MessageEntityStrikeTypeID:
		// Decoding messageEntityStrike#bf0693d4.
		v := MessageEntityStrike{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err)
		}
		return &v, nil
	case MessageEntityBankCardTypeID:
		// Decoding messageEntityBankCard#761e6af4.
		v := MessageEntityBankCard{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err)
		}
		return &v, nil
	case MessageEntitySpoilerTypeID:
		// Decoding messageEntitySpoiler#32ca960f.
		v := MessageEntitySpoiler{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err)
		}
		return &v, nil
	case MessageEntityCustomEmojiTypeID:
		// Decoding messageEntityCustomEmoji#c8cf05f8.
		v := MessageEntityCustomEmoji{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err)
		}
		return &v, nil
	case MessageEntityBlockquoteTypeID:
		// Decoding messageEntityBlockquote#f1ccaaac.
		v := MessageEntityBlockquote{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode MessageEntityClass: %w", bin.NewUnexpectedID(id))
	}
}

// MessageEntity boxes the MessageEntityClass providing a helper.
type MessageEntityBox struct {
	MessageEntity MessageEntityClass
}

// Decode implements bin.Decoder for MessageEntityBox.
func (b *MessageEntityBox) Decode(buf *bin.Buffer) error {
	if b == nil {
		return fmt.Errorf("unable to decode MessageEntityBox to nil")
	}
	v, err := DecodeMessageEntity(buf)
	if err != nil {
		return fmt.Errorf("unable to decode boxed value: %w", err)
	}
	b.MessageEntity = v
	return nil
}

// Encode implements bin.Encode for MessageEntityBox.
func (b *MessageEntityBox) Encode(buf *bin.Buffer) error {
	if b == nil || b.MessageEntity == nil {
		return fmt.Errorf("unable to encode MessageEntityClass as nil")
	}
	return b.MessageEntity.Encode(buf)
}
