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

// MessageActionEmpty represents TL type `messageActionEmpty#b6aef7b0`.
// Empty constructor.
//
// See https://core.telegram.org/constructor/messageActionEmpty for reference.
type MessageActionEmpty struct {
}

// MessageActionEmptyTypeID is TL type id of MessageActionEmpty.
const MessageActionEmptyTypeID = 0xb6aef7b0

// construct implements constructor of MessageActionClass.
func (m MessageActionEmpty) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionEmpty{}
)

func (m *MessageActionEmpty) Zero() bool {
	if m == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionEmpty) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionEmpty",
		ID:   MessageActionEmptyTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionEmpty) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionEmpty#b6aef7b0 as nil")
	}
	b.PutID(MessageActionEmptyTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionEmpty) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionEmpty#b6aef7b0 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionEmpty) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionEmpty#b6aef7b0 to nil")
	}
	return nil
}

// MessageActionChatCreate represents TL type `messageActionChatCreate#bd47cbad`.
// Group created
//
// See https://core.telegram.org/constructor/messageActionChatCreate for reference.
type MessageActionChatCreate struct {
	// Group name
	Title string
	// List of group members
	Users []int64
}

// MessageActionChatCreateTypeID is TL type id of MessageActionChatCreate.
const MessageActionChatCreateTypeID = 0xbd47cbad

// construct implements constructor of MessageActionClass.
func (m MessageActionChatCreate) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionChatCreate{}
)

func (m *MessageActionChatCreate) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Title == "") {
		return false
	}
	if !(m.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionChatCreate from given interface.
func (m *MessageActionChatCreate) FillFrom(from interface {
	GetTitle() (value string)
	GetUsers() (value []int64)
}) {
	m.Title = from.GetTitle()
	m.Users = from.GetUsers()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionChatCreate) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionChatCreate",
		ID:   MessageActionChatCreateTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionChatCreate) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionChatCreate#bd47cbad as nil")
	}
	b.PutID(MessageActionChatCreateTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionChatCreate) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionChatCreate#bd47cbad as nil")
	}
	b.PutString(m.Title)
	b.PutVectorHeader(len(m.Users))
	for _, v := range m.Users {
		b.PutLong(v)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionChatCreate) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionChatCreate#bd47cbad to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionChatCreate#bd47cbad: field title: %w", err)
		}
		m.Title = value
	}
	{
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionChatCreate#bd47cbad: field users: %w", err)
		}

		if headerLen > 0 {
			m.Users = make([]int64, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := b.Long()
			if err != nil {
				return fmt.Errorf("unable to decode messageActionChatCreate#bd47cbad: field users: %w", err)
			}
			m.Users = append(m.Users, value)
		}
	}
	return nil
}

// GetTitle returns value of Title field.
func (m *MessageActionChatCreate) GetTitle() (value string) {
	if m == nil {
		return
	}
	return m.Title
}

// GetUsers returns value of Users field.
func (m *MessageActionChatCreate) GetUsers() (value []int64) {
	if m == nil {
		return
	}
	return m.Users
}

// MessageActionChatEditTitle represents TL type `messageActionChatEditTitle#b5a1ce5a`.
// Group name changed.
//
// See https://core.telegram.org/constructor/messageActionChatEditTitle for reference.
type MessageActionChatEditTitle struct {
	// New group name
	Title string
}

// MessageActionChatEditTitleTypeID is TL type id of MessageActionChatEditTitle.
const MessageActionChatEditTitleTypeID = 0xb5a1ce5a

// construct implements constructor of MessageActionClass.
func (m MessageActionChatEditTitle) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionChatEditTitle{}
)

func (m *MessageActionChatEditTitle) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Title == "") {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionChatEditTitle from given interface.
func (m *MessageActionChatEditTitle) FillFrom(from interface {
	GetTitle() (value string)
}) {
	m.Title = from.GetTitle()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionChatEditTitle) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionChatEditTitle",
		ID:   MessageActionChatEditTitleTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Title",
			SchemaName: "title",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionChatEditTitle) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionChatEditTitle#b5a1ce5a as nil")
	}
	b.PutID(MessageActionChatEditTitleTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionChatEditTitle) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionChatEditTitle#b5a1ce5a as nil")
	}
	b.PutString(m.Title)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionChatEditTitle) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionChatEditTitle#b5a1ce5a to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionChatEditTitle#b5a1ce5a: field title: %w", err)
		}
		m.Title = value
	}
	return nil
}

// GetTitle returns value of Title field.
func (m *MessageActionChatEditTitle) GetTitle() (value string) {
	if m == nil {
		return
	}
	return m.Title
}

// MessageActionChatEditPhoto represents TL type `messageActionChatEditPhoto#7fcb13a8`.
// Group profile changed
//
// See https://core.telegram.org/constructor/messageActionChatEditPhoto for reference.
type MessageActionChatEditPhoto struct {
	// New group profile photo
	Photo PhotoClass
}

// MessageActionChatEditPhotoTypeID is TL type id of MessageActionChatEditPhoto.
const MessageActionChatEditPhotoTypeID = 0x7fcb13a8

// construct implements constructor of MessageActionClass.
func (m MessageActionChatEditPhoto) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionChatEditPhoto{}
)

func (m *MessageActionChatEditPhoto) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Photo == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionChatEditPhoto from given interface.
func (m *MessageActionChatEditPhoto) FillFrom(from interface {
	GetPhoto() (value PhotoClass)
}) {
	m.Photo = from.GetPhoto()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionChatEditPhoto) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionChatEditPhoto",
		ID:   MessageActionChatEditPhotoTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Photo",
			SchemaName: "photo",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionChatEditPhoto) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionChatEditPhoto#7fcb13a8 as nil")
	}
	b.PutID(MessageActionChatEditPhotoTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionChatEditPhoto) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionChatEditPhoto#7fcb13a8 as nil")
	}
	if m.Photo == nil {
		return fmt.Errorf("unable to encode messageActionChatEditPhoto#7fcb13a8: field photo is nil")
	}
	if err := m.Photo.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionChatEditPhoto#7fcb13a8: field photo: %w", err)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionChatEditPhoto) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionChatEditPhoto#7fcb13a8 to nil")
	}
	{
		value, err := DecodePhoto(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionChatEditPhoto#7fcb13a8: field photo: %w", err)
		}
		m.Photo = value
	}
	return nil
}

// GetPhoto returns value of Photo field.
func (m *MessageActionChatEditPhoto) GetPhoto() (value PhotoClass) {
	if m == nil {
		return
	}
	return m.Photo
}

// MessageActionChatDeletePhoto represents TL type `messageActionChatDeletePhoto#95e3fbef`.
// Group profile photo removed.
//
// See https://core.telegram.org/constructor/messageActionChatDeletePhoto for reference.
type MessageActionChatDeletePhoto struct {
}

// MessageActionChatDeletePhotoTypeID is TL type id of MessageActionChatDeletePhoto.
const MessageActionChatDeletePhotoTypeID = 0x95e3fbef

// construct implements constructor of MessageActionClass.
func (m MessageActionChatDeletePhoto) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionChatDeletePhoto{}
)

func (m *MessageActionChatDeletePhoto) Zero() bool {
	if m == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionChatDeletePhoto) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionChatDeletePhoto",
		ID:   MessageActionChatDeletePhotoTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionChatDeletePhoto) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionChatDeletePhoto#95e3fbef as nil")
	}
	b.PutID(MessageActionChatDeletePhotoTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionChatDeletePhoto) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionChatDeletePhoto#95e3fbef as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionChatDeletePhoto) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionChatDeletePhoto#95e3fbef to nil")
	}
	return nil
}

// MessageActionChatAddUser represents TL type `messageActionChatAddUser#15cefd00`.
// New member in the group
//
// See https://core.telegram.org/constructor/messageActionChatAddUser for reference.
type MessageActionChatAddUser struct {
	// Users that were invited to the chat
	Users []int64
}

// MessageActionChatAddUserTypeID is TL type id of MessageActionChatAddUser.
const MessageActionChatAddUserTypeID = 0x15cefd00

// construct implements constructor of MessageActionClass.
func (m MessageActionChatAddUser) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionChatAddUser{}
)

func (m *MessageActionChatAddUser) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionChatAddUser from given interface.
func (m *MessageActionChatAddUser) FillFrom(from interface {
	GetUsers() (value []int64)
}) {
	m.Users = from.GetUsers()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionChatAddUser) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionChatAddUser",
		ID:   MessageActionChatAddUserTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionChatAddUser) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionChatAddUser#15cefd00 as nil")
	}
	b.PutID(MessageActionChatAddUserTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionChatAddUser) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionChatAddUser#15cefd00 as nil")
	}
	b.PutVectorHeader(len(m.Users))
	for _, v := range m.Users {
		b.PutLong(v)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionChatAddUser) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionChatAddUser#15cefd00 to nil")
	}
	{
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionChatAddUser#15cefd00: field users: %w", err)
		}

		if headerLen > 0 {
			m.Users = make([]int64, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := b.Long()
			if err != nil {
				return fmt.Errorf("unable to decode messageActionChatAddUser#15cefd00: field users: %w", err)
			}
			m.Users = append(m.Users, value)
		}
	}
	return nil
}

// GetUsers returns value of Users field.
func (m *MessageActionChatAddUser) GetUsers() (value []int64) {
	if m == nil {
		return
	}
	return m.Users
}

// MessageActionChatDeleteUser represents TL type `messageActionChatDeleteUser#a43f30cc`.
// User left the group.
//
// See https://core.telegram.org/constructor/messageActionChatDeleteUser for reference.
type MessageActionChatDeleteUser struct {
	// Leaving user ID
	UserID int64
}

// MessageActionChatDeleteUserTypeID is TL type id of MessageActionChatDeleteUser.
const MessageActionChatDeleteUserTypeID = 0xa43f30cc

// construct implements constructor of MessageActionClass.
func (m MessageActionChatDeleteUser) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionChatDeleteUser{}
)

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

	return true
}

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

// FillFrom fills MessageActionChatDeleteUser from given interface.
func (m *MessageActionChatDeleteUser) FillFrom(from interface {
	GetUserID() (value int64)
}) {
	m.UserID = from.GetUserID()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionChatDeleteUser) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionChatDeleteUser",
		ID:   MessageActionChatDeleteUserTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionChatDeleteUser) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionChatDeleteUser#a43f30cc as nil")
	}
	b.PutID(MessageActionChatDeleteUserTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionChatDeleteUser) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionChatDeleteUser#a43f30cc as nil")
	}
	b.PutLong(m.UserID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionChatDeleteUser) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionChatDeleteUser#a43f30cc to nil")
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionChatDeleteUser#a43f30cc: field user_id: %w", err)
		}
		m.UserID = value
	}
	return nil
}

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

// MessageActionChatJoinedByLink represents TL type `messageActionChatJoinedByLink#31224c3`.
// A user joined the chat via an invite link
//
// See https://core.telegram.org/constructor/messageActionChatJoinedByLink for reference.
type MessageActionChatJoinedByLink struct {
	// ID of the user that created the invite link
	InviterID int64
}

// MessageActionChatJoinedByLinkTypeID is TL type id of MessageActionChatJoinedByLink.
const MessageActionChatJoinedByLinkTypeID = 0x31224c3

// construct implements constructor of MessageActionClass.
func (m MessageActionChatJoinedByLink) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionChatJoinedByLink{}
)

func (m *MessageActionChatJoinedByLink) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.InviterID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionChatJoinedByLink from given interface.
func (m *MessageActionChatJoinedByLink) FillFrom(from interface {
	GetInviterID() (value int64)
}) {
	m.InviterID = from.GetInviterID()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionChatJoinedByLink) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionChatJoinedByLink",
		ID:   MessageActionChatJoinedByLinkTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "InviterID",
			SchemaName: "inviter_id",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionChatJoinedByLink) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionChatJoinedByLink#31224c3 as nil")
	}
	b.PutID(MessageActionChatJoinedByLinkTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionChatJoinedByLink) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionChatJoinedByLink#31224c3 as nil")
	}
	b.PutLong(m.InviterID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionChatJoinedByLink) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionChatJoinedByLink#31224c3 to nil")
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionChatJoinedByLink#31224c3: field inviter_id: %w", err)
		}
		m.InviterID = value
	}
	return nil
}

// GetInviterID returns value of InviterID field.
func (m *MessageActionChatJoinedByLink) GetInviterID() (value int64) {
	if m == nil {
		return
	}
	return m.InviterID
}

// MessageActionChannelCreate represents TL type `messageActionChannelCreate#95d2ac92`.
// The channel was created
//
// See https://core.telegram.org/constructor/messageActionChannelCreate for reference.
type MessageActionChannelCreate struct {
	// Original channel/supergroup title
	Title string
}

// MessageActionChannelCreateTypeID is TL type id of MessageActionChannelCreate.
const MessageActionChannelCreateTypeID = 0x95d2ac92

// construct implements constructor of MessageActionClass.
func (m MessageActionChannelCreate) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionChannelCreate{}
)

func (m *MessageActionChannelCreate) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Title == "") {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionChannelCreate from given interface.
func (m *MessageActionChannelCreate) FillFrom(from interface {
	GetTitle() (value string)
}) {
	m.Title = from.GetTitle()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionChannelCreate) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionChannelCreate",
		ID:   MessageActionChannelCreateTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Title",
			SchemaName: "title",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionChannelCreate) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionChannelCreate#95d2ac92 as nil")
	}
	b.PutID(MessageActionChannelCreateTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionChannelCreate) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionChannelCreate#95d2ac92 as nil")
	}
	b.PutString(m.Title)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionChannelCreate) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionChannelCreate#95d2ac92 to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionChannelCreate#95d2ac92: field title: %w", err)
		}
		m.Title = value
	}
	return nil
}

// GetTitle returns value of Title field.
func (m *MessageActionChannelCreate) GetTitle() (value string) {
	if m == nil {
		return
	}
	return m.Title
}

// MessageActionChatMigrateTo represents TL type `messageActionChatMigrateTo#e1037f92`.
// Indicates the chat was migrated¹ to the specified supergroup
//
// Links:
//  1. https://core.telegram.org/api/channel
//
// See https://core.telegram.org/constructor/messageActionChatMigrateTo for reference.
type MessageActionChatMigrateTo struct {
	// The supergroup it was migrated to
	ChannelID int64
}

// MessageActionChatMigrateToTypeID is TL type id of MessageActionChatMigrateTo.
const MessageActionChatMigrateToTypeID = 0xe1037f92

// construct implements constructor of MessageActionClass.
func (m MessageActionChatMigrateTo) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionChatMigrateTo{}
)

func (m *MessageActionChatMigrateTo) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.ChannelID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionChatMigrateTo from given interface.
func (m *MessageActionChatMigrateTo) FillFrom(from interface {
	GetChannelID() (value int64)
}) {
	m.ChannelID = from.GetChannelID()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionChatMigrateTo) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionChatMigrateTo",
		ID:   MessageActionChatMigrateToTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "ChannelID",
			SchemaName: "channel_id",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionChatMigrateTo) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionChatMigrateTo#e1037f92 as nil")
	}
	b.PutID(MessageActionChatMigrateToTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionChatMigrateTo) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionChatMigrateTo#e1037f92 as nil")
	}
	b.PutLong(m.ChannelID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionChatMigrateTo) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionChatMigrateTo#e1037f92 to nil")
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionChatMigrateTo#e1037f92: field channel_id: %w", err)
		}
		m.ChannelID = value
	}
	return nil
}

// GetChannelID returns value of ChannelID field.
func (m *MessageActionChatMigrateTo) GetChannelID() (value int64) {
	if m == nil {
		return
	}
	return m.ChannelID
}

// MessageActionChannelMigrateFrom represents TL type `messageActionChannelMigrateFrom#ea3948e9`.
// Indicates the channel was migrated¹ from the specified chat
//
// Links:
//  1. https://core.telegram.org/api/channel
//
// See https://core.telegram.org/constructor/messageActionChannelMigrateFrom for reference.
type MessageActionChannelMigrateFrom struct {
	// The old chat title
	Title string
	// The old chat ID
	ChatID int64
}

// MessageActionChannelMigrateFromTypeID is TL type id of MessageActionChannelMigrateFrom.
const MessageActionChannelMigrateFromTypeID = 0xea3948e9

// construct implements constructor of MessageActionClass.
func (m MessageActionChannelMigrateFrom) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionChannelMigrateFrom{}
)

func (m *MessageActionChannelMigrateFrom) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Title == "") {
		return false
	}
	if !(m.ChatID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionChannelMigrateFrom from given interface.
func (m *MessageActionChannelMigrateFrom) FillFrom(from interface {
	GetTitle() (value string)
	GetChatID() (value int64)
}) {
	m.Title = from.GetTitle()
	m.ChatID = from.GetChatID()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionChannelMigrateFrom) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionChannelMigrateFrom",
		ID:   MessageActionChannelMigrateFromTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "ChatID",
			SchemaName: "chat_id",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionChannelMigrateFrom) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionChannelMigrateFrom#ea3948e9 as nil")
	}
	b.PutID(MessageActionChannelMigrateFromTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionChannelMigrateFrom) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionChannelMigrateFrom#ea3948e9 as nil")
	}
	b.PutString(m.Title)
	b.PutLong(m.ChatID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionChannelMigrateFrom) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionChannelMigrateFrom#ea3948e9 to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionChannelMigrateFrom#ea3948e9: field title: %w", err)
		}
		m.Title = value
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionChannelMigrateFrom#ea3948e9: field chat_id: %w", err)
		}
		m.ChatID = value
	}
	return nil
}

// GetTitle returns value of Title field.
func (m *MessageActionChannelMigrateFrom) GetTitle() (value string) {
	if m == nil {
		return
	}
	return m.Title
}

// GetChatID returns value of ChatID field.
func (m *MessageActionChannelMigrateFrom) GetChatID() (value int64) {
	if m == nil {
		return
	}
	return m.ChatID
}

// MessageActionPinMessage represents TL type `messageActionPinMessage#94bd38ed`.
// A message was pinned
//
// See https://core.telegram.org/constructor/messageActionPinMessage for reference.
type MessageActionPinMessage struct {
}

// MessageActionPinMessageTypeID is TL type id of MessageActionPinMessage.
const MessageActionPinMessageTypeID = 0x94bd38ed

// construct implements constructor of MessageActionClass.
func (m MessageActionPinMessage) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionPinMessage{}
)

func (m *MessageActionPinMessage) Zero() bool {
	if m == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionPinMessage) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionPinMessage",
		ID:   MessageActionPinMessageTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionPinMessage) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionPinMessage#94bd38ed as nil")
	}
	b.PutID(MessageActionPinMessageTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionPinMessage) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionPinMessage#94bd38ed as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionPinMessage) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionPinMessage#94bd38ed to nil")
	}
	return nil
}

// MessageActionHistoryClear represents TL type `messageActionHistoryClear#9fbab604`.
// Chat history was cleared
//
// See https://core.telegram.org/constructor/messageActionHistoryClear for reference.
type MessageActionHistoryClear struct {
}

// MessageActionHistoryClearTypeID is TL type id of MessageActionHistoryClear.
const MessageActionHistoryClearTypeID = 0x9fbab604

// construct implements constructor of MessageActionClass.
func (m MessageActionHistoryClear) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionHistoryClear{}
)

func (m *MessageActionHistoryClear) Zero() bool {
	if m == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionHistoryClear) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionHistoryClear",
		ID:   MessageActionHistoryClearTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

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

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionHistoryClear) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionHistoryClear#9fbab604 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionHistoryClear) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionHistoryClear#9fbab604 to nil")
	}
	return nil
}

// MessageActionGameScore represents TL type `messageActionGameScore#92a72876`.
// Someone scored in a game
//
// See https://core.telegram.org/constructor/messageActionGameScore for reference.
type MessageActionGameScore struct {
	// Game ID
	GameID int64
	// Score
	Score int
}

// MessageActionGameScoreTypeID is TL type id of MessageActionGameScore.
const MessageActionGameScoreTypeID = 0x92a72876

// construct implements constructor of MessageActionClass.
func (m MessageActionGameScore) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionGameScore{}
)

func (m *MessageActionGameScore) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.GameID == 0) {
		return false
	}
	if !(m.Score == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionGameScore from given interface.
func (m *MessageActionGameScore) FillFrom(from interface {
	GetGameID() (value int64)
	GetScore() (value int)
}) {
	m.GameID = from.GetGameID()
	m.Score = from.GetScore()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionGameScore) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionGameScore",
		ID:   MessageActionGameScoreTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "GameID",
			SchemaName: "game_id",
		},
		{
			Name:       "Score",
			SchemaName: "score",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionGameScore) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionGameScore#92a72876 as nil")
	}
	b.PutID(MessageActionGameScoreTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionGameScore) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionGameScore#92a72876 as nil")
	}
	b.PutLong(m.GameID)
	b.PutInt(m.Score)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionGameScore) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionGameScore#92a72876 to nil")
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGameScore#92a72876: field game_id: %w", err)
		}
		m.GameID = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGameScore#92a72876: field score: %w", err)
		}
		m.Score = value
	}
	return nil
}

// GetGameID returns value of GameID field.
func (m *MessageActionGameScore) GetGameID() (value int64) {
	if m == nil {
		return
	}
	return m.GameID
}

// GetScore returns value of Score field.
func (m *MessageActionGameScore) GetScore() (value int) {
	if m == nil {
		return
	}
	return m.Score
}

// MessageActionPaymentSentMe represents TL type `messageActionPaymentSentMe#ffa00ccc`.
// A user just sent a payment to me (a bot)
//
// See https://core.telegram.org/constructor/messageActionPaymentSentMe for reference.
type MessageActionPaymentSentMe struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether this is the first payment of a recurring payment we just subscribed to
	RecurringInit bool
	// Whether this payment is part of a recurring payment
	RecurringUsed bool
	// Three-letter ISO 4217 currency¹ code, or XTR for Telegram Stars².
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments#supported-currencies
	//  2) https://core.telegram.org/api/stars
	Currency string
	// Price of the product in the smallest units of the currency (integer, not float/double)
	// For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in
	// currencies.json¹, it shows the number of digits past the decimal point for each
	// currency (2 for the majority of currencies).
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments/currencies.json
	TotalAmount int64
	// Bot specified invoice payload
	Payload []byte
	// Order info provided by the user
	//
	// Use SetInfo and GetInfo helpers.
	Info PaymentRequestedInfo
	// Identifier of the shipping option chosen by the user
	//
	// Use SetShippingOptionID and GetShippingOptionID helpers.
	ShippingOptionID string
	// Provider payment identifier
	Charge PaymentCharge
	// Expiration date of the Telegram Star subscription »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/stars#star-subscriptions
	//
	// Use SetSubscriptionUntilDate and GetSubscriptionUntilDate helpers.
	SubscriptionUntilDate int
}

// MessageActionPaymentSentMeTypeID is TL type id of MessageActionPaymentSentMe.
const MessageActionPaymentSentMeTypeID = 0xffa00ccc

// construct implements constructor of MessageActionClass.
func (m MessageActionPaymentSentMe) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionPaymentSentMe{}
)

func (m *MessageActionPaymentSentMe) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.RecurringInit == false) {
		return false
	}
	if !(m.RecurringUsed == false) {
		return false
	}
	if !(m.Currency == "") {
		return false
	}
	if !(m.TotalAmount == 0) {
		return false
	}
	if !(m.Payload == nil) {
		return false
	}
	if !(m.Info.Zero()) {
		return false
	}
	if !(m.ShippingOptionID == "") {
		return false
	}
	if !(m.Charge.Zero()) {
		return false
	}
	if !(m.SubscriptionUntilDate == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionPaymentSentMe from given interface.
func (m *MessageActionPaymentSentMe) FillFrom(from interface {
	GetRecurringInit() (value bool)
	GetRecurringUsed() (value bool)
	GetCurrency() (value string)
	GetTotalAmount() (value int64)
	GetPayload() (value []byte)
	GetInfo() (value PaymentRequestedInfo, ok bool)
	GetShippingOptionID() (value string, ok bool)
	GetCharge() (value PaymentCharge)
	GetSubscriptionUntilDate() (value int, ok bool)
}) {
	m.RecurringInit = from.GetRecurringInit()
	m.RecurringUsed = from.GetRecurringUsed()
	m.Currency = from.GetCurrency()
	m.TotalAmount = from.GetTotalAmount()
	m.Payload = from.GetPayload()
	if val, ok := from.GetInfo(); ok {
		m.Info = val
	}

	if val, ok := from.GetShippingOptionID(); ok {
		m.ShippingOptionID = val
	}

	m.Charge = from.GetCharge()
	if val, ok := from.GetSubscriptionUntilDate(); ok {
		m.SubscriptionUntilDate = val
	}

}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionPaymentSentMe) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionPaymentSentMe",
		ID:   MessageActionPaymentSentMeTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "RecurringInit",
			SchemaName: "recurring_init",
			Null:       !m.Flags.Has(2),
		},
		{
			Name:       "RecurringUsed",
			SchemaName: "recurring_used",
			Null:       !m.Flags.Has(3),
		},
		{
			Name:       "Currency",
			SchemaName: "currency",
		},
		{
			Name:       "TotalAmount",
			SchemaName: "total_amount",
		},
		{
			Name:       "Payload",
			SchemaName: "payload",
		},
		{
			Name:       "Info",
			SchemaName: "info",
			Null:       !m.Flags.Has(0),
		},
		{
			Name:       "ShippingOptionID",
			SchemaName: "shipping_option_id",
			Null:       !m.Flags.Has(1),
		},
		{
			Name:       "Charge",
			SchemaName: "charge",
		},
		{
			Name:       "SubscriptionUntilDate",
			SchemaName: "subscription_until_date",
			Null:       !m.Flags.Has(4),
		},
	}
	return typ
}

// SetFlags sets flags for non-zero fields.
func (m *MessageActionPaymentSentMe) SetFlags() {
	if !(m.RecurringInit == false) {
		m.Flags.Set(2)
	}
	if !(m.RecurringUsed == false) {
		m.Flags.Set(3)
	}
	if !(m.Info.Zero()) {
		m.Flags.Set(0)
	}
	if !(m.ShippingOptionID == "") {
		m.Flags.Set(1)
	}
	if !(m.SubscriptionUntilDate == 0) {
		m.Flags.Set(4)
	}
}

// Encode implements bin.Encoder.
func (m *MessageActionPaymentSentMe) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionPaymentSentMe#ffa00ccc as nil")
	}
	b.PutID(MessageActionPaymentSentMeTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionPaymentSentMe) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionPaymentSentMe#ffa00ccc as nil")
	}
	m.SetFlags()
	if err := m.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionPaymentSentMe#ffa00ccc: field flags: %w", err)
	}
	b.PutString(m.Currency)
	b.PutLong(m.TotalAmount)
	b.PutBytes(m.Payload)
	if m.Flags.Has(0) {
		if err := m.Info.Encode(b); err != nil {
			return fmt.Errorf("unable to encode messageActionPaymentSentMe#ffa00ccc: field info: %w", err)
		}
	}
	if m.Flags.Has(1) {
		b.PutString(m.ShippingOptionID)
	}
	if err := m.Charge.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionPaymentSentMe#ffa00ccc: field charge: %w", err)
	}
	if m.Flags.Has(4) {
		b.PutInt(m.SubscriptionUntilDate)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionPaymentSentMe) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionPaymentSentMe#ffa00ccc to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionPaymentSentMe#ffa00ccc: field flags: %w", err)
		}
	}
	m.RecurringInit = m.Flags.Has(2)
	m.RecurringUsed = m.Flags.Has(3)
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPaymentSentMe#ffa00ccc: field currency: %w", err)
		}
		m.Currency = value
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPaymentSentMe#ffa00ccc: field total_amount: %w", err)
		}
		m.TotalAmount = value
	}
	{
		value, err := b.Bytes()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPaymentSentMe#ffa00ccc: field payload: %w", err)
		}
		m.Payload = value
	}
	if m.Flags.Has(0) {
		if err := m.Info.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionPaymentSentMe#ffa00ccc: field info: %w", err)
		}
	}
	if m.Flags.Has(1) {
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPaymentSentMe#ffa00ccc: field shipping_option_id: %w", err)
		}
		m.ShippingOptionID = value
	}
	{
		if err := m.Charge.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionPaymentSentMe#ffa00ccc: field charge: %w", err)
		}
	}
	if m.Flags.Has(4) {
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPaymentSentMe#ffa00ccc: field subscription_until_date: %w", err)
		}
		m.SubscriptionUntilDate = value
	}
	return nil
}

// SetRecurringInit sets value of RecurringInit conditional field.
func (m *MessageActionPaymentSentMe) SetRecurringInit(value bool) {
	if value {
		m.Flags.Set(2)
		m.RecurringInit = true
	} else {
		m.Flags.Unset(2)
		m.RecurringInit = false
	}
}

// GetRecurringInit returns value of RecurringInit conditional field.
func (m *MessageActionPaymentSentMe) GetRecurringInit() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(2)
}

// SetRecurringUsed sets value of RecurringUsed conditional field.
func (m *MessageActionPaymentSentMe) SetRecurringUsed(value bool) {
	if value {
		m.Flags.Set(3)
		m.RecurringUsed = true
	} else {
		m.Flags.Unset(3)
		m.RecurringUsed = false
	}
}

// GetRecurringUsed returns value of RecurringUsed conditional field.
func (m *MessageActionPaymentSentMe) GetRecurringUsed() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(3)
}

// GetCurrency returns value of Currency field.
func (m *MessageActionPaymentSentMe) GetCurrency() (value string) {
	if m == nil {
		return
	}
	return m.Currency
}

// GetTotalAmount returns value of TotalAmount field.
func (m *MessageActionPaymentSentMe) GetTotalAmount() (value int64) {
	if m == nil {
		return
	}
	return m.TotalAmount
}

// GetPayload returns value of Payload field.
func (m *MessageActionPaymentSentMe) GetPayload() (value []byte) {
	if m == nil {
		return
	}
	return m.Payload
}

// SetInfo sets value of Info conditional field.
func (m *MessageActionPaymentSentMe) SetInfo(value PaymentRequestedInfo) {
	m.Flags.Set(0)
	m.Info = value
}

// GetInfo returns value of Info conditional field and
// boolean which is true if field was set.
func (m *MessageActionPaymentSentMe) GetInfo() (value PaymentRequestedInfo, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(0) {
		return value, false
	}
	return m.Info, true
}

// SetShippingOptionID sets value of ShippingOptionID conditional field.
func (m *MessageActionPaymentSentMe) SetShippingOptionID(value string) {
	m.Flags.Set(1)
	m.ShippingOptionID = value
}

// GetShippingOptionID returns value of ShippingOptionID conditional field and
// boolean which is true if field was set.
func (m *MessageActionPaymentSentMe) GetShippingOptionID() (value string, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(1) {
		return value, false
	}
	return m.ShippingOptionID, true
}

// GetCharge returns value of Charge field.
func (m *MessageActionPaymentSentMe) GetCharge() (value PaymentCharge) {
	if m == nil {
		return
	}
	return m.Charge
}

// SetSubscriptionUntilDate sets value of SubscriptionUntilDate conditional field.
func (m *MessageActionPaymentSentMe) SetSubscriptionUntilDate(value int) {
	m.Flags.Set(4)
	m.SubscriptionUntilDate = value
}

// GetSubscriptionUntilDate returns value of SubscriptionUntilDate conditional field and
// boolean which is true if field was set.
func (m *MessageActionPaymentSentMe) GetSubscriptionUntilDate() (value int, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(4) {
		return value, false
	}
	return m.SubscriptionUntilDate, true
}

// MessageActionPaymentSent represents TL type `messageActionPaymentSent#c624b16e`.
// A payment was sent
//
// See https://core.telegram.org/constructor/messageActionPaymentSent for reference.
type MessageActionPaymentSent struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether this is the first payment of a recurring payment we just subscribed to
	RecurringInit bool
	// Whether this payment is part of a recurring payment
	RecurringUsed bool
	// Three-letter ISO 4217 currency¹ code, or XTR for Telegram Stars².
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments#supported-currencies
	//  2) https://core.telegram.org/api/stars
	Currency string
	// Price of the product in the smallest units of the currency (integer, not float/double)
	// For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in
	// currencies.json¹, it shows the number of digits past the decimal point for each
	// currency (2 for the majority of currencies).
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments/currencies.json
	TotalAmount int64
	// An invoice slug taken from an invoice deep link¹ or from the premium_invoice_slug app
	// config parameter »²
	//
	// Links:
	//  1) https://core.telegram.org/api/links#invoice-links
	//  2) https://core.telegram.org/api/config#premium-invoice-slug
	//
	// Use SetInvoiceSlug and GetInvoiceSlug helpers.
	InvoiceSlug string
	// Expiration date of the Telegram Star subscription »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/stars#star-subscriptions
	//
	// Use SetSubscriptionUntilDate and GetSubscriptionUntilDate helpers.
	SubscriptionUntilDate int
}

// MessageActionPaymentSentTypeID is TL type id of MessageActionPaymentSent.
const MessageActionPaymentSentTypeID = 0xc624b16e

// construct implements constructor of MessageActionClass.
func (m MessageActionPaymentSent) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionPaymentSent{}
)

func (m *MessageActionPaymentSent) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.RecurringInit == false) {
		return false
	}
	if !(m.RecurringUsed == false) {
		return false
	}
	if !(m.Currency == "") {
		return false
	}
	if !(m.TotalAmount == 0) {
		return false
	}
	if !(m.InvoiceSlug == "") {
		return false
	}
	if !(m.SubscriptionUntilDate == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionPaymentSent from given interface.
func (m *MessageActionPaymentSent) FillFrom(from interface {
	GetRecurringInit() (value bool)
	GetRecurringUsed() (value bool)
	GetCurrency() (value string)
	GetTotalAmount() (value int64)
	GetInvoiceSlug() (value string, ok bool)
	GetSubscriptionUntilDate() (value int, ok bool)
}) {
	m.RecurringInit = from.GetRecurringInit()
	m.RecurringUsed = from.GetRecurringUsed()
	m.Currency = from.GetCurrency()
	m.TotalAmount = from.GetTotalAmount()
	if val, ok := from.GetInvoiceSlug(); ok {
		m.InvoiceSlug = val
	}

	if val, ok := from.GetSubscriptionUntilDate(); ok {
		m.SubscriptionUntilDate = val
	}

}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionPaymentSent) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionPaymentSent",
		ID:   MessageActionPaymentSentTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "RecurringInit",
			SchemaName: "recurring_init",
			Null:       !m.Flags.Has(2),
		},
		{
			Name:       "RecurringUsed",
			SchemaName: "recurring_used",
			Null:       !m.Flags.Has(3),
		},
		{
			Name:       "Currency",
			SchemaName: "currency",
		},
		{
			Name:       "TotalAmount",
			SchemaName: "total_amount",
		},
		{
			Name:       "InvoiceSlug",
			SchemaName: "invoice_slug",
			Null:       !m.Flags.Has(0),
		},
		{
			Name:       "SubscriptionUntilDate",
			SchemaName: "subscription_until_date",
			Null:       !m.Flags.Has(4),
		},
	}
	return typ
}

// SetFlags sets flags for non-zero fields.
func (m *MessageActionPaymentSent) SetFlags() {
	if !(m.RecurringInit == false) {
		m.Flags.Set(2)
	}
	if !(m.RecurringUsed == false) {
		m.Flags.Set(3)
	}
	if !(m.InvoiceSlug == "") {
		m.Flags.Set(0)
	}
	if !(m.SubscriptionUntilDate == 0) {
		m.Flags.Set(4)
	}
}

// Encode implements bin.Encoder.
func (m *MessageActionPaymentSent) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionPaymentSent#c624b16e as nil")
	}
	b.PutID(MessageActionPaymentSentTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionPaymentSent) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionPaymentSent#c624b16e as nil")
	}
	m.SetFlags()
	if err := m.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionPaymentSent#c624b16e: field flags: %w", err)
	}
	b.PutString(m.Currency)
	b.PutLong(m.TotalAmount)
	if m.Flags.Has(0) {
		b.PutString(m.InvoiceSlug)
	}
	if m.Flags.Has(4) {
		b.PutInt(m.SubscriptionUntilDate)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionPaymentSent) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionPaymentSent#c624b16e to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionPaymentSent#c624b16e: field flags: %w", err)
		}
	}
	m.RecurringInit = m.Flags.Has(2)
	m.RecurringUsed = m.Flags.Has(3)
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPaymentSent#c624b16e: field currency: %w", err)
		}
		m.Currency = value
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPaymentSent#c624b16e: field total_amount: %w", err)
		}
		m.TotalAmount = value
	}
	if m.Flags.Has(0) {
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPaymentSent#c624b16e: field invoice_slug: %w", err)
		}
		m.InvoiceSlug = value
	}
	if m.Flags.Has(4) {
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPaymentSent#c624b16e: field subscription_until_date: %w", err)
		}
		m.SubscriptionUntilDate = value
	}
	return nil
}

// SetRecurringInit sets value of RecurringInit conditional field.
func (m *MessageActionPaymentSent) SetRecurringInit(value bool) {
	if value {
		m.Flags.Set(2)
		m.RecurringInit = true
	} else {
		m.Flags.Unset(2)
		m.RecurringInit = false
	}
}

// GetRecurringInit returns value of RecurringInit conditional field.
func (m *MessageActionPaymentSent) GetRecurringInit() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(2)
}

// SetRecurringUsed sets value of RecurringUsed conditional field.
func (m *MessageActionPaymentSent) SetRecurringUsed(value bool) {
	if value {
		m.Flags.Set(3)
		m.RecurringUsed = true
	} else {
		m.Flags.Unset(3)
		m.RecurringUsed = false
	}
}

// GetRecurringUsed returns value of RecurringUsed conditional field.
func (m *MessageActionPaymentSent) GetRecurringUsed() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(3)
}

// GetCurrency returns value of Currency field.
func (m *MessageActionPaymentSent) GetCurrency() (value string) {
	if m == nil {
		return
	}
	return m.Currency
}

// GetTotalAmount returns value of TotalAmount field.
func (m *MessageActionPaymentSent) GetTotalAmount() (value int64) {
	if m == nil {
		return
	}
	return m.TotalAmount
}

// SetInvoiceSlug sets value of InvoiceSlug conditional field.
func (m *MessageActionPaymentSent) SetInvoiceSlug(value string) {
	m.Flags.Set(0)
	m.InvoiceSlug = value
}

// GetInvoiceSlug returns value of InvoiceSlug conditional field and
// boolean which is true if field was set.
func (m *MessageActionPaymentSent) GetInvoiceSlug() (value string, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(0) {
		return value, false
	}
	return m.InvoiceSlug, true
}

// SetSubscriptionUntilDate sets value of SubscriptionUntilDate conditional field.
func (m *MessageActionPaymentSent) SetSubscriptionUntilDate(value int) {
	m.Flags.Set(4)
	m.SubscriptionUntilDate = value
}

// GetSubscriptionUntilDate returns value of SubscriptionUntilDate conditional field and
// boolean which is true if field was set.
func (m *MessageActionPaymentSent) GetSubscriptionUntilDate() (value int, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(4) {
		return value, false
	}
	return m.SubscriptionUntilDate, true
}

// MessageActionPhoneCall represents TL type `messageActionPhoneCall#80e11a7f`.
// A phone call
//
// See https://core.telegram.org/constructor/messageActionPhoneCall for reference.
type MessageActionPhoneCall struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Is this a video call?
	Video bool
	// Call ID
	CallID int64
	// If the call has ended, the reason why it ended
	//
	// Use SetReason and GetReason helpers.
	Reason PhoneCallDiscardReasonClass
	// Duration of the call in seconds
	//
	// Use SetDuration and GetDuration helpers.
	Duration int
}

// MessageActionPhoneCallTypeID is TL type id of MessageActionPhoneCall.
const MessageActionPhoneCallTypeID = 0x80e11a7f

// construct implements constructor of MessageActionClass.
func (m MessageActionPhoneCall) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionPhoneCall{}
)

func (m *MessageActionPhoneCall) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.Video == false) {
		return false
	}
	if !(m.CallID == 0) {
		return false
	}
	if !(m.Reason == nil) {
		return false
	}
	if !(m.Duration == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionPhoneCall from given interface.
func (m *MessageActionPhoneCall) FillFrom(from interface {
	GetVideo() (value bool)
	GetCallID() (value int64)
	GetReason() (value PhoneCallDiscardReasonClass, ok bool)
	GetDuration() (value int, ok bool)
}) {
	m.Video = from.GetVideo()
	m.CallID = from.GetCallID()
	if val, ok := from.GetReason(); ok {
		m.Reason = val
	}

	if val, ok := from.GetDuration(); ok {
		m.Duration = val
	}

}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionPhoneCall) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionPhoneCall",
		ID:   MessageActionPhoneCallTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Video",
			SchemaName: "video",
			Null:       !m.Flags.Has(2),
		},
		{
			Name:       "CallID",
			SchemaName: "call_id",
		},
		{
			Name:       "Reason",
			SchemaName: "reason",
			Null:       !m.Flags.Has(0),
		},
		{
			Name:       "Duration",
			SchemaName: "duration",
			Null:       !m.Flags.Has(1),
		},
	}
	return typ
}

// SetFlags sets flags for non-zero fields.
func (m *MessageActionPhoneCall) SetFlags() {
	if !(m.Video == false) {
		m.Flags.Set(2)
	}
	if !(m.Reason == nil) {
		m.Flags.Set(0)
	}
	if !(m.Duration == 0) {
		m.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func (m *MessageActionPhoneCall) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionPhoneCall#80e11a7f as nil")
	}
	b.PutID(MessageActionPhoneCallTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionPhoneCall) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionPhoneCall#80e11a7f as nil")
	}
	m.SetFlags()
	if err := m.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionPhoneCall#80e11a7f: field flags: %w", err)
	}
	b.PutLong(m.CallID)
	if m.Flags.Has(0) {
		if m.Reason == nil {
			return fmt.Errorf("unable to encode messageActionPhoneCall#80e11a7f: field reason is nil")
		}
		if err := m.Reason.Encode(b); err != nil {
			return fmt.Errorf("unable to encode messageActionPhoneCall#80e11a7f: field reason: %w", err)
		}
	}
	if m.Flags.Has(1) {
		b.PutInt(m.Duration)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionPhoneCall) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionPhoneCall#80e11a7f to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionPhoneCall#80e11a7f: field flags: %w", err)
		}
	}
	m.Video = m.Flags.Has(2)
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPhoneCall#80e11a7f: field call_id: %w", err)
		}
		m.CallID = value
	}
	if m.Flags.Has(0) {
		value, err := DecodePhoneCallDiscardReason(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPhoneCall#80e11a7f: field reason: %w", err)
		}
		m.Reason = value
	}
	if m.Flags.Has(1) {
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPhoneCall#80e11a7f: field duration: %w", err)
		}
		m.Duration = value
	}
	return nil
}

// SetVideo sets value of Video conditional field.
func (m *MessageActionPhoneCall) SetVideo(value bool) {
	if value {
		m.Flags.Set(2)
		m.Video = true
	} else {
		m.Flags.Unset(2)
		m.Video = false
	}
}

// GetVideo returns value of Video conditional field.
func (m *MessageActionPhoneCall) GetVideo() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(2)
}

// GetCallID returns value of CallID field.
func (m *MessageActionPhoneCall) GetCallID() (value int64) {
	if m == nil {
		return
	}
	return m.CallID
}

// SetReason sets value of Reason conditional field.
func (m *MessageActionPhoneCall) SetReason(value PhoneCallDiscardReasonClass) {
	m.Flags.Set(0)
	m.Reason = value
}

// GetReason returns value of Reason conditional field and
// boolean which is true if field was set.
func (m *MessageActionPhoneCall) GetReason() (value PhoneCallDiscardReasonClass, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(0) {
		return value, false
	}
	return m.Reason, true
}

// SetDuration sets value of Duration conditional field.
func (m *MessageActionPhoneCall) SetDuration(value int) {
	m.Flags.Set(1)
	m.Duration = value
}

// GetDuration returns value of Duration conditional field and
// boolean which is true if field was set.
func (m *MessageActionPhoneCall) GetDuration() (value int, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(1) {
		return value, false
	}
	return m.Duration, true
}

// MessageActionScreenshotTaken represents TL type `messageActionScreenshotTaken#4792929b`.
// A screenshot of the chat was taken
//
// See https://core.telegram.org/constructor/messageActionScreenshotTaken for reference.
type MessageActionScreenshotTaken struct {
}

// MessageActionScreenshotTakenTypeID is TL type id of MessageActionScreenshotTaken.
const MessageActionScreenshotTakenTypeID = 0x4792929b

// construct implements constructor of MessageActionClass.
func (m MessageActionScreenshotTaken) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionScreenshotTaken{}
)

func (m *MessageActionScreenshotTaken) Zero() bool {
	if m == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionScreenshotTaken) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionScreenshotTaken",
		ID:   MessageActionScreenshotTakenTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionScreenshotTaken) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionScreenshotTaken#4792929b as nil")
	}
	b.PutID(MessageActionScreenshotTakenTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionScreenshotTaken) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionScreenshotTaken#4792929b as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionScreenshotTaken) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionScreenshotTaken#4792929b to nil")
	}
	return nil
}

// MessageActionCustomAction represents TL type `messageActionCustomAction#fae69f56`.
// Custom action (most likely not supported by the current layer, an upgrade might be
// needed)
//
// See https://core.telegram.org/constructor/messageActionCustomAction for reference.
type MessageActionCustomAction struct {
	// Action message
	Message string
}

// MessageActionCustomActionTypeID is TL type id of MessageActionCustomAction.
const MessageActionCustomActionTypeID = 0xfae69f56

// construct implements constructor of MessageActionClass.
func (m MessageActionCustomAction) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionCustomAction{}
)

func (m *MessageActionCustomAction) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Message == "") {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionCustomAction from given interface.
func (m *MessageActionCustomAction) FillFrom(from interface {
	GetMessage() (value string)
}) {
	m.Message = from.GetMessage()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionCustomAction) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionCustomAction",
		ID:   MessageActionCustomActionTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Message",
			SchemaName: "message",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionCustomAction) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionCustomAction#fae69f56 as nil")
	}
	b.PutID(MessageActionCustomActionTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionCustomAction) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionCustomAction#fae69f56 as nil")
	}
	b.PutString(m.Message)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionCustomAction) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionCustomAction#fae69f56 to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionCustomAction#fae69f56: field message: %w", err)
		}
		m.Message = value
	}
	return nil
}

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

// MessageActionBotAllowed represents TL type `messageActionBotAllowed#c516d679`.
// We have given the bot permission to send us direct messages.
// The optional fields specify how did we authorize the bot to send us messages.
//
// See https://core.telegram.org/constructor/messageActionBotAllowed for reference.
type MessageActionBotAllowed struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// We have authorized the bot to send us messages by installing the bot's attachment
	// menu¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/attach
	AttachMenu bool
	// We have allowed the bot to send us messages using bots.allowSendMessage »¹.
	//
	// Links:
	//  1) https://core.telegram.org/method/bots.allowSendMessage
	FromRequest bool
	// We have authorized the bot to send us messages by logging into a website via Telegram
	// Login »¹; this field contains the domain name of the website on which the user has
	// logged in.
	//
	// Links:
	//  1) https://core.telegram.org/widgets/login
	//
	// Use SetDomain and GetDomain helpers.
	Domain string
	// We have authorized the bot to send us messages by opening the specified bot mini app¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/webapps
	//
	// Use SetApp and GetApp helpers.
	App BotAppClass
}

// MessageActionBotAllowedTypeID is TL type id of MessageActionBotAllowed.
const MessageActionBotAllowedTypeID = 0xc516d679

// construct implements constructor of MessageActionClass.
func (m MessageActionBotAllowed) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionBotAllowed{}
)

func (m *MessageActionBotAllowed) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.AttachMenu == false) {
		return false
	}
	if !(m.FromRequest == false) {
		return false
	}
	if !(m.Domain == "") {
		return false
	}
	if !(m.App == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionBotAllowed from given interface.
func (m *MessageActionBotAllowed) FillFrom(from interface {
	GetAttachMenu() (value bool)
	GetFromRequest() (value bool)
	GetDomain() (value string, ok bool)
	GetApp() (value BotAppClass, ok bool)
}) {
	m.AttachMenu = from.GetAttachMenu()
	m.FromRequest = from.GetFromRequest()
	if val, ok := from.GetDomain(); ok {
		m.Domain = val
	}

	if val, ok := from.GetApp(); ok {
		m.App = val
	}

}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionBotAllowed) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionBotAllowed",
		ID:   MessageActionBotAllowedTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "AttachMenu",
			SchemaName: "attach_menu",
			Null:       !m.Flags.Has(1),
		},
		{
			Name:       "FromRequest",
			SchemaName: "from_request",
			Null:       !m.Flags.Has(3),
		},
		{
			Name:       "Domain",
			SchemaName: "domain",
			Null:       !m.Flags.Has(0),
		},
		{
			Name:       "App",
			SchemaName: "app",
			Null:       !m.Flags.Has(2),
		},
	}
	return typ
}

// SetFlags sets flags for non-zero fields.
func (m *MessageActionBotAllowed) SetFlags() {
	if !(m.AttachMenu == false) {
		m.Flags.Set(1)
	}
	if !(m.FromRequest == false) {
		m.Flags.Set(3)
	}
	if !(m.Domain == "") {
		m.Flags.Set(0)
	}
	if !(m.App == nil) {
		m.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func (m *MessageActionBotAllowed) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionBotAllowed#c516d679 as nil")
	}
	b.PutID(MessageActionBotAllowedTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionBotAllowed) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionBotAllowed#c516d679 as nil")
	}
	m.SetFlags()
	if err := m.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionBotAllowed#c516d679: field flags: %w", err)
	}
	if m.Flags.Has(0) {
		b.PutString(m.Domain)
	}
	if m.Flags.Has(2) {
		if m.App == nil {
			return fmt.Errorf("unable to encode messageActionBotAllowed#c516d679: field app is nil")
		}
		if err := m.App.Encode(b); err != nil {
			return fmt.Errorf("unable to encode messageActionBotAllowed#c516d679: field app: %w", err)
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionBotAllowed) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionBotAllowed#c516d679 to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionBotAllowed#c516d679: field flags: %w", err)
		}
	}
	m.AttachMenu = m.Flags.Has(1)
	m.FromRequest = m.Flags.Has(3)
	if m.Flags.Has(0) {
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionBotAllowed#c516d679: field domain: %w", err)
		}
		m.Domain = value
	}
	if m.Flags.Has(2) {
		value, err := DecodeBotApp(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionBotAllowed#c516d679: field app: %w", err)
		}
		m.App = value
	}
	return nil
}

// SetAttachMenu sets value of AttachMenu conditional field.
func (m *MessageActionBotAllowed) SetAttachMenu(value bool) {
	if value {
		m.Flags.Set(1)
		m.AttachMenu = true
	} else {
		m.Flags.Unset(1)
		m.AttachMenu = false
	}
}

// GetAttachMenu returns value of AttachMenu conditional field.
func (m *MessageActionBotAllowed) GetAttachMenu() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(1)
}

// SetFromRequest sets value of FromRequest conditional field.
func (m *MessageActionBotAllowed) SetFromRequest(value bool) {
	if value {
		m.Flags.Set(3)
		m.FromRequest = true
	} else {
		m.Flags.Unset(3)
		m.FromRequest = false
	}
}

// GetFromRequest returns value of FromRequest conditional field.
func (m *MessageActionBotAllowed) GetFromRequest() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(3)
}

// SetDomain sets value of Domain conditional field.
func (m *MessageActionBotAllowed) SetDomain(value string) {
	m.Flags.Set(0)
	m.Domain = value
}

// GetDomain returns value of Domain conditional field and
// boolean which is true if field was set.
func (m *MessageActionBotAllowed) GetDomain() (value string, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(0) {
		return value, false
	}
	return m.Domain, true
}

// SetApp sets value of App conditional field.
func (m *MessageActionBotAllowed) SetApp(value BotAppClass) {
	m.Flags.Set(2)
	m.App = value
}

// GetApp returns value of App conditional field and
// boolean which is true if field was set.
func (m *MessageActionBotAllowed) GetApp() (value BotAppClass, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(2) {
		return value, false
	}
	return m.App, true
}

// MessageActionSecureValuesSentMe represents TL type `messageActionSecureValuesSentMe#1b287353`.
// Secure telegram passport¹ values were received
//
// Links:
//  1. https://core.telegram.org/passport
//
// See https://core.telegram.org/constructor/messageActionSecureValuesSentMe for reference.
type MessageActionSecureValuesSentMe struct {
	// Vector with information about documents and other Telegram Passport elements that were
	// shared with the bot
	Values []SecureValue
	// Encrypted credentials required to decrypt the data
	Credentials SecureCredentialsEncrypted
}

// MessageActionSecureValuesSentMeTypeID is TL type id of MessageActionSecureValuesSentMe.
const MessageActionSecureValuesSentMeTypeID = 0x1b287353

// construct implements constructor of MessageActionClass.
func (m MessageActionSecureValuesSentMe) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionSecureValuesSentMe{}
)

func (m *MessageActionSecureValuesSentMe) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Values == nil) {
		return false
	}
	if !(m.Credentials.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionSecureValuesSentMe from given interface.
func (m *MessageActionSecureValuesSentMe) FillFrom(from interface {
	GetValues() (value []SecureValue)
	GetCredentials() (value SecureCredentialsEncrypted)
}) {
	m.Values = from.GetValues()
	m.Credentials = from.GetCredentials()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionSecureValuesSentMe) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionSecureValuesSentMe",
		ID:   MessageActionSecureValuesSentMeTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Values",
			SchemaName: "values",
		},
		{
			Name:       "Credentials",
			SchemaName: "credentials",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionSecureValuesSentMe) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionSecureValuesSentMe#1b287353 as nil")
	}
	b.PutID(MessageActionSecureValuesSentMeTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionSecureValuesSentMe) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionSecureValuesSentMe#1b287353 as nil")
	}
	b.PutVectorHeader(len(m.Values))
	for idx, v := range m.Values {
		if err := v.Encode(b); err != nil {
			return fmt.Errorf("unable to encode messageActionSecureValuesSentMe#1b287353: field values element with index %d: %w", idx, err)
		}
	}
	if err := m.Credentials.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionSecureValuesSentMe#1b287353: field credentials: %w", err)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionSecureValuesSentMe) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionSecureValuesSentMe#1b287353 to nil")
	}
	{
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionSecureValuesSentMe#1b287353: field values: %w", err)
		}

		if headerLen > 0 {
			m.Values = make([]SecureValue, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			var value SecureValue
			if err := value.Decode(b); err != nil {
				return fmt.Errorf("unable to decode messageActionSecureValuesSentMe#1b287353: field values: %w", err)
			}
			m.Values = append(m.Values, value)
		}
	}
	{
		if err := m.Credentials.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionSecureValuesSentMe#1b287353: field credentials: %w", err)
		}
	}
	return nil
}

// GetValues returns value of Values field.
func (m *MessageActionSecureValuesSentMe) GetValues() (value []SecureValue) {
	if m == nil {
		return
	}
	return m.Values
}

// GetCredentials returns value of Credentials field.
func (m *MessageActionSecureValuesSentMe) GetCredentials() (value SecureCredentialsEncrypted) {
	if m == nil {
		return
	}
	return m.Credentials
}

// MessageActionSecureValuesSent represents TL type `messageActionSecureValuesSent#d95c6154`.
// Request for secure telegram passport¹ values was sent
//
// Links:
//  1. https://core.telegram.org/passport
//
// See https://core.telegram.org/constructor/messageActionSecureValuesSent for reference.
type MessageActionSecureValuesSent struct {
	// Secure value types
	Types []SecureValueTypeClass
}

// MessageActionSecureValuesSentTypeID is TL type id of MessageActionSecureValuesSent.
const MessageActionSecureValuesSentTypeID = 0xd95c6154

// construct implements constructor of MessageActionClass.
func (m MessageActionSecureValuesSent) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionSecureValuesSent{}
)

func (m *MessageActionSecureValuesSent) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Types == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionSecureValuesSent from given interface.
func (m *MessageActionSecureValuesSent) FillFrom(from interface {
	GetTypes() (value []SecureValueTypeClass)
}) {
	m.Types = from.GetTypes()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionSecureValuesSent) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionSecureValuesSent",
		ID:   MessageActionSecureValuesSentTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Types",
			SchemaName: "types",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionSecureValuesSent) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionSecureValuesSent#d95c6154 as nil")
	}
	b.PutID(MessageActionSecureValuesSentTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionSecureValuesSent) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionSecureValuesSent#d95c6154 as nil")
	}
	b.PutVectorHeader(len(m.Types))
	for idx, v := range m.Types {
		if v == nil {
			return fmt.Errorf("unable to encode messageActionSecureValuesSent#d95c6154: field types element with index %d is nil", idx)
		}
		if err := v.Encode(b); err != nil {
			return fmt.Errorf("unable to encode messageActionSecureValuesSent#d95c6154: field types element with index %d: %w", idx, err)
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionSecureValuesSent) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionSecureValuesSent#d95c6154 to nil")
	}
	{
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionSecureValuesSent#d95c6154: field types: %w", err)
		}

		if headerLen > 0 {
			m.Types = make([]SecureValueTypeClass, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := DecodeSecureValueType(b)
			if err != nil {
				return fmt.Errorf("unable to decode messageActionSecureValuesSent#d95c6154: field types: %w", err)
			}
			m.Types = append(m.Types, value)
		}
	}
	return nil
}

// GetTypes returns value of Types field.
func (m *MessageActionSecureValuesSent) GetTypes() (value []SecureValueTypeClass) {
	if m == nil {
		return
	}
	return m.Types
}

// MapTypes returns field Types wrapped in SecureValueTypeClassArray helper.
func (m *MessageActionSecureValuesSent) MapTypes() (value SecureValueTypeClassArray) {
	return SecureValueTypeClassArray(m.Types)
}

// MessageActionContactSignUp represents TL type `messageActionContactSignUp#f3f25f76`.
// A contact just signed up to telegram
//
// See https://core.telegram.org/constructor/messageActionContactSignUp for reference.
type MessageActionContactSignUp struct {
}

// MessageActionContactSignUpTypeID is TL type id of MessageActionContactSignUp.
const MessageActionContactSignUpTypeID = 0xf3f25f76

// construct implements constructor of MessageActionClass.
func (m MessageActionContactSignUp) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionContactSignUp{}
)

func (m *MessageActionContactSignUp) Zero() bool {
	if m == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionContactSignUp) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionContactSignUp",
		ID:   MessageActionContactSignUpTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionContactSignUp) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionContactSignUp#f3f25f76 as nil")
	}
	b.PutID(MessageActionContactSignUpTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionContactSignUp) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionContactSignUp#f3f25f76 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionContactSignUp) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionContactSignUp#f3f25f76 to nil")
	}
	return nil
}

// MessageActionGeoProximityReached represents TL type `messageActionGeoProximityReached#98e0d697`.
// A user of the chat is now in proximity of another user
//
// See https://core.telegram.org/constructor/messageActionGeoProximityReached for reference.
type MessageActionGeoProximityReached struct {
	// The user or chat that is now in proximity of to_id
	FromID PeerClass
	// The user or chat that subscribed to live geolocation proximity alerts¹
	//
	// Links:
	//  1) https://core.telegram.org/api/live-location#proximity-alert
	ToID PeerClass
	// Distance, in meters (0-100000)
	Distance int
}

// MessageActionGeoProximityReachedTypeID is TL type id of MessageActionGeoProximityReached.
const MessageActionGeoProximityReachedTypeID = 0x98e0d697

// construct implements constructor of MessageActionClass.
func (m MessageActionGeoProximityReached) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionGeoProximityReached{}
)

func (m *MessageActionGeoProximityReached) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.FromID == nil) {
		return false
	}
	if !(m.ToID == nil) {
		return false
	}
	if !(m.Distance == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionGeoProximityReached from given interface.
func (m *MessageActionGeoProximityReached) FillFrom(from interface {
	GetFromID() (value PeerClass)
	GetToID() (value PeerClass)
	GetDistance() (value int)
}) {
	m.FromID = from.GetFromID()
	m.ToID = from.GetToID()
	m.Distance = from.GetDistance()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionGeoProximityReached) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionGeoProximityReached",
		ID:   MessageActionGeoProximityReachedTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "FromID",
			SchemaName: "from_id",
		},
		{
			Name:       "ToID",
			SchemaName: "to_id",
		},
		{
			Name:       "Distance",
			SchemaName: "distance",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionGeoProximityReached) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionGeoProximityReached#98e0d697 as nil")
	}
	b.PutID(MessageActionGeoProximityReachedTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionGeoProximityReached) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionGeoProximityReached#98e0d697 as nil")
	}
	if m.FromID == nil {
		return fmt.Errorf("unable to encode messageActionGeoProximityReached#98e0d697: field from_id is nil")
	}
	if err := m.FromID.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionGeoProximityReached#98e0d697: field from_id: %w", err)
	}
	if m.ToID == nil {
		return fmt.Errorf("unable to encode messageActionGeoProximityReached#98e0d697: field to_id is nil")
	}
	if err := m.ToID.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionGeoProximityReached#98e0d697: field to_id: %w", err)
	}
	b.PutInt(m.Distance)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionGeoProximityReached) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionGeoProximityReached#98e0d697 to nil")
	}
	{
		value, err := DecodePeer(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGeoProximityReached#98e0d697: field from_id: %w", err)
		}
		m.FromID = value
	}
	{
		value, err := DecodePeer(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGeoProximityReached#98e0d697: field to_id: %w", err)
		}
		m.ToID = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGeoProximityReached#98e0d697: field distance: %w", err)
		}
		m.Distance = value
	}
	return nil
}

// GetFromID returns value of FromID field.
func (m *MessageActionGeoProximityReached) GetFromID() (value PeerClass) {
	if m == nil {
		return
	}
	return m.FromID
}

// GetToID returns value of ToID field.
func (m *MessageActionGeoProximityReached) GetToID() (value PeerClass) {
	if m == nil {
		return
	}
	return m.ToID
}

// GetDistance returns value of Distance field.
func (m *MessageActionGeoProximityReached) GetDistance() (value int) {
	if m == nil {
		return
	}
	return m.Distance
}

// MessageActionGroupCall represents TL type `messageActionGroupCall#7a0d7f42`.
// The group call has ended
//
// See https://core.telegram.org/constructor/messageActionGroupCall for reference.
type MessageActionGroupCall struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Group call
	Call InputGroupCallClass
	// Group call duration
	//
	// Use SetDuration and GetDuration helpers.
	Duration int
}

// MessageActionGroupCallTypeID is TL type id of MessageActionGroupCall.
const MessageActionGroupCallTypeID = 0x7a0d7f42

// construct implements constructor of MessageActionClass.
func (m MessageActionGroupCall) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionGroupCall{}
)

func (m *MessageActionGroupCall) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.Call == nil) {
		return false
	}
	if !(m.Duration == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionGroupCall from given interface.
func (m *MessageActionGroupCall) FillFrom(from interface {
	GetCall() (value InputGroupCallClass)
	GetDuration() (value int, ok bool)
}) {
	m.Call = from.GetCall()
	if val, ok := from.GetDuration(); ok {
		m.Duration = val
	}

}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionGroupCall) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionGroupCall",
		ID:   MessageActionGroupCallTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Call",
			SchemaName: "call",
		},
		{
			Name:       "Duration",
			SchemaName: "duration",
			Null:       !m.Flags.Has(0),
		},
	}
	return typ
}

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

// Encode implements bin.Encoder.
func (m *MessageActionGroupCall) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionGroupCall#7a0d7f42 as nil")
	}
	b.PutID(MessageActionGroupCallTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionGroupCall) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionGroupCall#7a0d7f42 as nil")
	}
	m.SetFlags()
	if err := m.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionGroupCall#7a0d7f42: field flags: %w", err)
	}
	if m.Call == nil {
		return fmt.Errorf("unable to encode messageActionGroupCall#7a0d7f42: field call is nil")
	}
	if err := m.Call.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionGroupCall#7a0d7f42: field call: %w", err)
	}
	if m.Flags.Has(0) {
		b.PutInt(m.Duration)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionGroupCall) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionGroupCall#7a0d7f42 to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionGroupCall#7a0d7f42: field flags: %w", err)
		}
	}
	{
		value, err := DecodeInputGroupCall(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGroupCall#7a0d7f42: field call: %w", err)
		}
		m.Call = value
	}
	if m.Flags.Has(0) {
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGroupCall#7a0d7f42: field duration: %w", err)
		}
		m.Duration = value
	}
	return nil
}

// GetCall returns value of Call field.
func (m *MessageActionGroupCall) GetCall() (value InputGroupCallClass) {
	if m == nil {
		return
	}
	return m.Call
}

// SetDuration sets value of Duration conditional field.
func (m *MessageActionGroupCall) SetDuration(value int) {
	m.Flags.Set(0)
	m.Duration = value
}

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

// MessageActionInviteToGroupCall represents TL type `messageActionInviteToGroupCall#502f92f7`.
// A set of users was invited to the group call
//
// See https://core.telegram.org/constructor/messageActionInviteToGroupCall for reference.
type MessageActionInviteToGroupCall struct {
	// The group call
	Call InputGroupCallClass
	// The invited users
	Users []int64
}

// MessageActionInviteToGroupCallTypeID is TL type id of MessageActionInviteToGroupCall.
const MessageActionInviteToGroupCallTypeID = 0x502f92f7

// construct implements constructor of MessageActionClass.
func (m MessageActionInviteToGroupCall) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionInviteToGroupCall{}
)

func (m *MessageActionInviteToGroupCall) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Call == nil) {
		return false
	}
	if !(m.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionInviteToGroupCall from given interface.
func (m *MessageActionInviteToGroupCall) FillFrom(from interface {
	GetCall() (value InputGroupCallClass)
	GetUsers() (value []int64)
}) {
	m.Call = from.GetCall()
	m.Users = from.GetUsers()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionInviteToGroupCall) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionInviteToGroupCall",
		ID:   MessageActionInviteToGroupCallTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Call",
			SchemaName: "call",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionInviteToGroupCall) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionInviteToGroupCall#502f92f7 as nil")
	}
	b.PutID(MessageActionInviteToGroupCallTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionInviteToGroupCall) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionInviteToGroupCall#502f92f7 as nil")
	}
	if m.Call == nil {
		return fmt.Errorf("unable to encode messageActionInviteToGroupCall#502f92f7: field call is nil")
	}
	if err := m.Call.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionInviteToGroupCall#502f92f7: field call: %w", err)
	}
	b.PutVectorHeader(len(m.Users))
	for _, v := range m.Users {
		b.PutLong(v)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionInviteToGroupCall) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionInviteToGroupCall#502f92f7 to nil")
	}
	{
		value, err := DecodeInputGroupCall(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionInviteToGroupCall#502f92f7: field call: %w", err)
		}
		m.Call = value
	}
	{
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionInviteToGroupCall#502f92f7: field users: %w", err)
		}

		if headerLen > 0 {
			m.Users = make([]int64, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := b.Long()
			if err != nil {
				return fmt.Errorf("unable to decode messageActionInviteToGroupCall#502f92f7: field users: %w", err)
			}
			m.Users = append(m.Users, value)
		}
	}
	return nil
}

// GetCall returns value of Call field.
func (m *MessageActionInviteToGroupCall) GetCall() (value InputGroupCallClass) {
	if m == nil {
		return
	}
	return m.Call
}

// GetUsers returns value of Users field.
func (m *MessageActionInviteToGroupCall) GetUsers() (value []int64) {
	if m == nil {
		return
	}
	return m.Users
}

// MessageActionSetMessagesTTL represents TL type `messageActionSetMessagesTTL#3c134d7b`.
// The Time-To-Live of messages in this chat was changed.
//
// See https://core.telegram.org/constructor/messageActionSetMessagesTTL for reference.
type MessageActionSetMessagesTTL struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// New Time-To-Live of all messages sent in this chat; if 0, autodeletion was disabled.
	Period int
	// If set, the chat TTL setting was set not due to a manual change by one of participants
	// but automatically because one of the participants has the default TTL settings
	// enabled »¹. For example, when a user writes to us for the first time and we have set
	// a default messages TTL of 1 week, this service message (with
	// auto_setting_from=our_userid) will be emitted before our first message.
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.setDefaultHistoryTTL
	//
	// Use SetAutoSettingFrom and GetAutoSettingFrom helpers.
	AutoSettingFrom int64
}

// MessageActionSetMessagesTTLTypeID is TL type id of MessageActionSetMessagesTTL.
const MessageActionSetMessagesTTLTypeID = 0x3c134d7b

// construct implements constructor of MessageActionClass.
func (m MessageActionSetMessagesTTL) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionSetMessagesTTL{}
)

func (m *MessageActionSetMessagesTTL) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.Period == 0) {
		return false
	}
	if !(m.AutoSettingFrom == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionSetMessagesTTL from given interface.
func (m *MessageActionSetMessagesTTL) FillFrom(from interface {
	GetPeriod() (value int)
	GetAutoSettingFrom() (value int64, ok bool)
}) {
	m.Period = from.GetPeriod()
	if val, ok := from.GetAutoSettingFrom(); ok {
		m.AutoSettingFrom = val
	}

}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionSetMessagesTTL) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionSetMessagesTTL",
		ID:   MessageActionSetMessagesTTLTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Period",
			SchemaName: "period",
		},
		{
			Name:       "AutoSettingFrom",
			SchemaName: "auto_setting_from",
			Null:       !m.Flags.Has(0),
		},
	}
	return typ
}

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

// Encode implements bin.Encoder.
func (m *MessageActionSetMessagesTTL) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionSetMessagesTTL#3c134d7b as nil")
	}
	b.PutID(MessageActionSetMessagesTTLTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionSetMessagesTTL) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionSetMessagesTTL#3c134d7b as nil")
	}
	m.SetFlags()
	if err := m.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionSetMessagesTTL#3c134d7b: field flags: %w", err)
	}
	b.PutInt(m.Period)
	if m.Flags.Has(0) {
		b.PutLong(m.AutoSettingFrom)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionSetMessagesTTL) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionSetMessagesTTL#3c134d7b to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionSetMessagesTTL#3c134d7b: field flags: %w", err)
		}
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionSetMessagesTTL#3c134d7b: field period: %w", err)
		}
		m.Period = value
	}
	if m.Flags.Has(0) {
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionSetMessagesTTL#3c134d7b: field auto_setting_from: %w", err)
		}
		m.AutoSettingFrom = value
	}
	return nil
}

// GetPeriod returns value of Period field.
func (m *MessageActionSetMessagesTTL) GetPeriod() (value int) {
	if m == nil {
		return
	}
	return m.Period
}

// SetAutoSettingFrom sets value of AutoSettingFrom conditional field.
func (m *MessageActionSetMessagesTTL) SetAutoSettingFrom(value int64) {
	m.Flags.Set(0)
	m.AutoSettingFrom = value
}

// GetAutoSettingFrom returns value of AutoSettingFrom conditional field and
// boolean which is true if field was set.
func (m *MessageActionSetMessagesTTL) GetAutoSettingFrom() (value int64, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(0) {
		return value, false
	}
	return m.AutoSettingFrom, true
}

// MessageActionGroupCallScheduled represents TL type `messageActionGroupCallScheduled#b3a07661`.
// A group call was scheduled
//
// See https://core.telegram.org/constructor/messageActionGroupCallScheduled for reference.
type MessageActionGroupCallScheduled struct {
	// The group call
	Call InputGroupCallClass
	// When is this group call scheduled to start
	ScheduleDate int
}

// MessageActionGroupCallScheduledTypeID is TL type id of MessageActionGroupCallScheduled.
const MessageActionGroupCallScheduledTypeID = 0xb3a07661

// construct implements constructor of MessageActionClass.
func (m MessageActionGroupCallScheduled) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionGroupCallScheduled{}
)

func (m *MessageActionGroupCallScheduled) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Call == nil) {
		return false
	}
	if !(m.ScheduleDate == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionGroupCallScheduled from given interface.
func (m *MessageActionGroupCallScheduled) FillFrom(from interface {
	GetCall() (value InputGroupCallClass)
	GetScheduleDate() (value int)
}) {
	m.Call = from.GetCall()
	m.ScheduleDate = from.GetScheduleDate()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionGroupCallScheduled) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionGroupCallScheduled",
		ID:   MessageActionGroupCallScheduledTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Call",
			SchemaName: "call",
		},
		{
			Name:       "ScheduleDate",
			SchemaName: "schedule_date",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionGroupCallScheduled) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionGroupCallScheduled#b3a07661 as nil")
	}
	b.PutID(MessageActionGroupCallScheduledTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionGroupCallScheduled) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionGroupCallScheduled#b3a07661 as nil")
	}
	if m.Call == nil {
		return fmt.Errorf("unable to encode messageActionGroupCallScheduled#b3a07661: field call is nil")
	}
	if err := m.Call.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionGroupCallScheduled#b3a07661: field call: %w", err)
	}
	b.PutInt(m.ScheduleDate)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionGroupCallScheduled) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionGroupCallScheduled#b3a07661 to nil")
	}
	{
		value, err := DecodeInputGroupCall(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGroupCallScheduled#b3a07661: field call: %w", err)
		}
		m.Call = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGroupCallScheduled#b3a07661: field schedule_date: %w", err)
		}
		m.ScheduleDate = value
	}
	return nil
}

// GetCall returns value of Call field.
func (m *MessageActionGroupCallScheduled) GetCall() (value InputGroupCallClass) {
	if m == nil {
		return
	}
	return m.Call
}

// GetScheduleDate returns value of ScheduleDate field.
func (m *MessageActionGroupCallScheduled) GetScheduleDate() (value int) {
	if m == nil {
		return
	}
	return m.ScheduleDate
}

// MessageActionSetChatTheme represents TL type `messageActionSetChatTheme#b91bbd3a`.
// The chat theme was changed
//
// See https://core.telegram.org/constructor/messageActionSetChatTheme for reference.
type MessageActionSetChatTheme struct {
	// The new chat theme.
	Theme ChatThemeClass
}

// MessageActionSetChatThemeTypeID is TL type id of MessageActionSetChatTheme.
const MessageActionSetChatThemeTypeID = 0xb91bbd3a

// construct implements constructor of MessageActionClass.
func (m MessageActionSetChatTheme) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionSetChatTheme{}
)

func (m *MessageActionSetChatTheme) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Theme == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionSetChatTheme from given interface.
func (m *MessageActionSetChatTheme) FillFrom(from interface {
	GetTheme() (value ChatThemeClass)
}) {
	m.Theme = from.GetTheme()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionSetChatTheme) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionSetChatTheme",
		ID:   MessageActionSetChatThemeTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Theme",
			SchemaName: "theme",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionSetChatTheme) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionSetChatTheme#b91bbd3a as nil")
	}
	b.PutID(MessageActionSetChatThemeTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionSetChatTheme) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionSetChatTheme#b91bbd3a as nil")
	}
	if m.Theme == nil {
		return fmt.Errorf("unable to encode messageActionSetChatTheme#b91bbd3a: field theme is nil")
	}
	if err := m.Theme.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionSetChatTheme#b91bbd3a: field theme: %w", err)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionSetChatTheme) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionSetChatTheme#b91bbd3a to nil")
	}
	{
		value, err := DecodeChatTheme(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionSetChatTheme#b91bbd3a: field theme: %w", err)
		}
		m.Theme = value
	}
	return nil
}

// GetTheme returns value of Theme field.
func (m *MessageActionSetChatTheme) GetTheme() (value ChatThemeClass) {
	if m == nil {
		return
	}
	return m.Theme
}

// MessageActionChatJoinedByRequest represents TL type `messageActionChatJoinedByRequest#ebbca3cb`.
// A user was accepted into the group by an admin
//
// See https://core.telegram.org/constructor/messageActionChatJoinedByRequest for reference.
type MessageActionChatJoinedByRequest struct {
}

// MessageActionChatJoinedByRequestTypeID is TL type id of MessageActionChatJoinedByRequest.
const MessageActionChatJoinedByRequestTypeID = 0xebbca3cb

// construct implements constructor of MessageActionClass.
func (m MessageActionChatJoinedByRequest) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionChatJoinedByRequest{}
)

func (m *MessageActionChatJoinedByRequest) Zero() bool {
	if m == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionChatJoinedByRequest) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionChatJoinedByRequest",
		ID:   MessageActionChatJoinedByRequestTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionChatJoinedByRequest) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionChatJoinedByRequest#ebbca3cb as nil")
	}
	b.PutID(MessageActionChatJoinedByRequestTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionChatJoinedByRequest) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionChatJoinedByRequest#ebbca3cb as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionChatJoinedByRequest) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionChatJoinedByRequest#ebbca3cb to nil")
	}
	return nil
}

// MessageActionWebViewDataSentMe represents TL type `messageActionWebViewDataSentMe#47dd8079`.
// Data from an opened reply keyboard bot mini app¹ was relayed to the bot that owns it
// (bot side service message).
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps
//
// See https://core.telegram.org/constructor/messageActionWebViewDataSentMe for reference.
type MessageActionWebViewDataSentMe struct {
	// Text of the keyboardButtonSimpleWebView¹ that was pressed to open the web app.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/keyboardButtonSimpleWebView
	Text string
	// Relayed data.
	Data string
}

// MessageActionWebViewDataSentMeTypeID is TL type id of MessageActionWebViewDataSentMe.
const MessageActionWebViewDataSentMeTypeID = 0x47dd8079

// construct implements constructor of MessageActionClass.
func (m MessageActionWebViewDataSentMe) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionWebViewDataSentMe{}
)

func (m *MessageActionWebViewDataSentMe) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Text == "") {
		return false
	}
	if !(m.Data == "") {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionWebViewDataSentMe from given interface.
func (m *MessageActionWebViewDataSentMe) FillFrom(from interface {
	GetText() (value string)
	GetData() (value string)
}) {
	m.Text = from.GetText()
	m.Data = from.GetData()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionWebViewDataSentMe) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionWebViewDataSentMe",
		ID:   MessageActionWebViewDataSentMeTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Text",
			SchemaName: "text",
		},
		{
			Name:       "Data",
			SchemaName: "data",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionWebViewDataSentMe) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionWebViewDataSentMe#47dd8079 as nil")
	}
	b.PutID(MessageActionWebViewDataSentMeTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionWebViewDataSentMe) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionWebViewDataSentMe#47dd8079 as nil")
	}
	b.PutString(m.Text)
	b.PutString(m.Data)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionWebViewDataSentMe) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionWebViewDataSentMe#47dd8079 to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionWebViewDataSentMe#47dd8079: field text: %w", err)
		}
		m.Text = value
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionWebViewDataSentMe#47dd8079: field data: %w", err)
		}
		m.Data = value
	}
	return nil
}

// GetText returns value of Text field.
func (m *MessageActionWebViewDataSentMe) GetText() (value string) {
	if m == nil {
		return
	}
	return m.Text
}

// GetData returns value of Data field.
func (m *MessageActionWebViewDataSentMe) GetData() (value string) {
	if m == nil {
		return
	}
	return m.Data
}

// MessageActionWebViewDataSent represents TL type `messageActionWebViewDataSent#b4c38cb5`.
// Data from an opened reply keyboard bot mini app¹ was relayed to the bot that owns it
// (user side service message).
// Clients should display a service message with the text Data from the «$text» button
// was transferred to the bot.
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps
//
// See https://core.telegram.org/constructor/messageActionWebViewDataSent for reference.
type MessageActionWebViewDataSent struct {
	// Text of the keyboardButtonSimpleWebView¹ that was pressed to open the web app.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/keyboardButtonSimpleWebView
	Text string
}

// MessageActionWebViewDataSentTypeID is TL type id of MessageActionWebViewDataSent.
const MessageActionWebViewDataSentTypeID = 0xb4c38cb5

// construct implements constructor of MessageActionClass.
func (m MessageActionWebViewDataSent) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionWebViewDataSent{}
)

func (m *MessageActionWebViewDataSent) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Text == "") {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionWebViewDataSent from given interface.
func (m *MessageActionWebViewDataSent) FillFrom(from interface {
	GetText() (value string)
}) {
	m.Text = from.GetText()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionWebViewDataSent) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionWebViewDataSent",
		ID:   MessageActionWebViewDataSentTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Text",
			SchemaName: "text",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionWebViewDataSent) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionWebViewDataSent#b4c38cb5 as nil")
	}
	b.PutID(MessageActionWebViewDataSentTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionWebViewDataSent) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionWebViewDataSent#b4c38cb5 as nil")
	}
	b.PutString(m.Text)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionWebViewDataSent) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionWebViewDataSent#b4c38cb5 to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionWebViewDataSent#b4c38cb5: field text: %w", err)
		}
		m.Text = value
	}
	return nil
}

// GetText returns value of Text field.
func (m *MessageActionWebViewDataSent) GetText() (value string) {
	if m == nil {
		return
	}
	return m.Text
}

// MessageActionGiftPremium represents TL type `messageActionGiftPremium#48e91302`.
// Info about a gifted Telegram Premium subscription
// This service message should be displayed below the appropriate sticker from the
// inputStickerSetPremiumGifts »¹ stickerset »²:
//
// Links:
//  1. https://core.telegram.org/constructor/inputStickerSetPremiumGifts
//  2. https://core.telegram.org/api/stickers#stickersets
//
// See https://core.telegram.org/constructor/messageActionGiftPremium for reference.
type MessageActionGiftPremium struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Three-letter ISO 4217 currency¹ code
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments#supported-currencies
	Currency string
	// Price of the gift in the smallest units of the currency (integer, not float/double).
	// For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in
	// currencies.json¹, it shows the number of digits past the decimal point for each
	// currency (2 for the majority of currencies).
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments/currencies.json
	Amount int64
	// Days field of MessageActionGiftPremium.
	Days int
	// If the gift was bought using a cryptocurrency, the cryptocurrency name.
	//
	// Use SetCryptoCurrency and GetCryptoCurrency helpers.
	CryptoCurrency string
	// If the gift was bought using a cryptocurrency, price of the gift in the smallest units
	// of a cryptocurrency.
	//
	// Use SetCryptoAmount and GetCryptoAmount helpers.
	CryptoAmount int64
	// Message attached with the gift
	//
	// Use SetMessage and GetMessage helpers.
	Message TextWithEntities
}

// MessageActionGiftPremiumTypeID is TL type id of MessageActionGiftPremium.
const MessageActionGiftPremiumTypeID = 0x48e91302

// construct implements constructor of MessageActionClass.
func (m MessageActionGiftPremium) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionGiftPremium{}
)

func (m *MessageActionGiftPremium) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.Currency == "") {
		return false
	}
	if !(m.Amount == 0) {
		return false
	}
	if !(m.Days == 0) {
		return false
	}
	if !(m.CryptoCurrency == "") {
		return false
	}
	if !(m.CryptoAmount == 0) {
		return false
	}
	if !(m.Message.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionGiftPremium from given interface.
func (m *MessageActionGiftPremium) FillFrom(from interface {
	GetCurrency() (value string)
	GetAmount() (value int64)
	GetDays() (value int)
	GetCryptoCurrency() (value string, ok bool)
	GetCryptoAmount() (value int64, ok bool)
	GetMessage() (value TextWithEntities, ok bool)
}) {
	m.Currency = from.GetCurrency()
	m.Amount = from.GetAmount()
	m.Days = from.GetDays()
	if val, ok := from.GetCryptoCurrency(); ok {
		m.CryptoCurrency = val
	}

	if val, ok := from.GetCryptoAmount(); ok {
		m.CryptoAmount = val
	}

	if val, ok := from.GetMessage(); ok {
		m.Message = val
	}

}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionGiftPremium) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionGiftPremium",
		ID:   MessageActionGiftPremiumTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Currency",
			SchemaName: "currency",
		},
		{
			Name:       "Amount",
			SchemaName: "amount",
		},
		{
			Name:       "Days",
			SchemaName: "days",
		},
		{
			Name:       "CryptoCurrency",
			SchemaName: "crypto_currency",
			Null:       !m.Flags.Has(0),
		},
		{
			Name:       "CryptoAmount",
			SchemaName: "crypto_amount",
			Null:       !m.Flags.Has(0),
		},
		{
			Name:       "Message",
			SchemaName: "message",
			Null:       !m.Flags.Has(1),
		},
	}
	return typ
}

// SetFlags sets flags for non-zero fields.
func (m *MessageActionGiftPremium) SetFlags() {
	if !(m.CryptoCurrency == "") {
		m.Flags.Set(0)
	}
	if !(m.CryptoAmount == 0) {
		m.Flags.Set(0)
	}
	if !(m.Message.Zero()) {
		m.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func (m *MessageActionGiftPremium) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionGiftPremium#48e91302 as nil")
	}
	b.PutID(MessageActionGiftPremiumTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionGiftPremium) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionGiftPremium#48e91302 as nil")
	}
	m.SetFlags()
	if err := m.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionGiftPremium#48e91302: field flags: %w", err)
	}
	b.PutString(m.Currency)
	b.PutLong(m.Amount)
	b.PutInt(m.Days)
	if m.Flags.Has(0) {
		b.PutString(m.CryptoCurrency)
	}
	if m.Flags.Has(0) {
		b.PutLong(m.CryptoAmount)
	}
	if m.Flags.Has(1) {
		if err := m.Message.Encode(b); err != nil {
			return fmt.Errorf("unable to encode messageActionGiftPremium#48e91302: field message: %w", err)
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionGiftPremium) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionGiftPremium#48e91302 to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionGiftPremium#48e91302: field flags: %w", err)
		}
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftPremium#48e91302: field currency: %w", err)
		}
		m.Currency = value
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftPremium#48e91302: field amount: %w", err)
		}
		m.Amount = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftPremium#48e91302: field days: %w", err)
		}
		m.Days = value
	}
	if m.Flags.Has(0) {
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftPremium#48e91302: field crypto_currency: %w", err)
		}
		m.CryptoCurrency = value
	}
	if m.Flags.Has(0) {
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftPremium#48e91302: field crypto_amount: %w", err)
		}
		m.CryptoAmount = value
	}
	if m.Flags.Has(1) {
		if err := m.Message.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionGiftPremium#48e91302: field message: %w", err)
		}
	}
	return nil
}

// GetCurrency returns value of Currency field.
func (m *MessageActionGiftPremium) GetCurrency() (value string) {
	if m == nil {
		return
	}
	return m.Currency
}

// GetAmount returns value of Amount field.
func (m *MessageActionGiftPremium) GetAmount() (value int64) {
	if m == nil {
		return
	}
	return m.Amount
}

// GetDays returns value of Days field.
func (m *MessageActionGiftPremium) GetDays() (value int) {
	if m == nil {
		return
	}
	return m.Days
}

// SetCryptoCurrency sets value of CryptoCurrency conditional field.
func (m *MessageActionGiftPremium) SetCryptoCurrency(value string) {
	m.Flags.Set(0)
	m.CryptoCurrency = value
}

// GetCryptoCurrency returns value of CryptoCurrency conditional field and
// boolean which is true if field was set.
func (m *MessageActionGiftPremium) GetCryptoCurrency() (value string, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(0) {
		return value, false
	}
	return m.CryptoCurrency, true
}

// SetCryptoAmount sets value of CryptoAmount conditional field.
func (m *MessageActionGiftPremium) SetCryptoAmount(value int64) {
	m.Flags.Set(0)
	m.CryptoAmount = value
}

// GetCryptoAmount returns value of CryptoAmount conditional field and
// boolean which is true if field was set.
func (m *MessageActionGiftPremium) GetCryptoAmount() (value int64, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(0) {
		return value, false
	}
	return m.CryptoAmount, true
}

// SetMessage sets value of Message conditional field.
func (m *MessageActionGiftPremium) SetMessage(value TextWithEntities) {
	m.Flags.Set(1)
	m.Message = value
}

// GetMessage returns value of Message conditional field and
// boolean which is true if field was set.
func (m *MessageActionGiftPremium) GetMessage() (value TextWithEntities, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(1) {
		return value, false
	}
	return m.Message, true
}

// MessageActionTopicCreate represents TL type `messageActionTopicCreate#d999256`.
// A forum topic¹ was created.
//
// Links:
//  1. https://core.telegram.org/api/forum#forum-topics
//
// See https://core.telegram.org/constructor/messageActionTopicCreate for reference.
type MessageActionTopicCreate struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// TitleMissing field of MessageActionTopicCreate.
	TitleMissing bool
	// Topic name.
	Title string
	// If no custom emoji icon is specified, specifies the color of the fallback topic icon
	// (RGB), one of 0x6FB9F0, 0xFFD67E, 0xCB86DB, 0x8EEE98, 0xFF93B2, or 0xFB6F5F.
	IconColor int
	// ID of the custom emoji¹ used as topic icon.
	//
	// Links:
	//  1) https://core.telegram.org/api/custom-emoji
	//
	// Use SetIconEmojiID and GetIconEmojiID helpers.
	IconEmojiID int64
}

// MessageActionTopicCreateTypeID is TL type id of MessageActionTopicCreate.
const MessageActionTopicCreateTypeID = 0xd999256

// construct implements constructor of MessageActionClass.
func (m MessageActionTopicCreate) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionTopicCreate{}
)

func (m *MessageActionTopicCreate) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.TitleMissing == false) {
		return false
	}
	if !(m.Title == "") {
		return false
	}
	if !(m.IconColor == 0) {
		return false
	}
	if !(m.IconEmojiID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionTopicCreate from given interface.
func (m *MessageActionTopicCreate) FillFrom(from interface {
	GetTitleMissing() (value bool)
	GetTitle() (value string)
	GetIconColor() (value int)
	GetIconEmojiID() (value int64, ok bool)
}) {
	m.TitleMissing = from.GetTitleMissing()
	m.Title = from.GetTitle()
	m.IconColor = from.GetIconColor()
	if val, ok := from.GetIconEmojiID(); ok {
		m.IconEmojiID = val
	}

}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionTopicCreate) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionTopicCreate",
		ID:   MessageActionTopicCreateTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "TitleMissing",
			SchemaName: "title_missing",
			Null:       !m.Flags.Has(1),
		},
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "IconColor",
			SchemaName: "icon_color",
		},
		{
			Name:       "IconEmojiID",
			SchemaName: "icon_emoji_id",
			Null:       !m.Flags.Has(0),
		},
	}
	return typ
}

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

// Encode implements bin.Encoder.
func (m *MessageActionTopicCreate) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionTopicCreate#d999256 as nil")
	}
	b.PutID(MessageActionTopicCreateTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionTopicCreate) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionTopicCreate#d999256 as nil")
	}
	m.SetFlags()
	if err := m.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionTopicCreate#d999256: field flags: %w", err)
	}
	b.PutString(m.Title)
	b.PutInt(m.IconColor)
	if m.Flags.Has(0) {
		b.PutLong(m.IconEmojiID)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionTopicCreate) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionTopicCreate#d999256 to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionTopicCreate#d999256: field flags: %w", err)
		}
	}
	m.TitleMissing = m.Flags.Has(1)
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionTopicCreate#d999256: field title: %w", err)
		}
		m.Title = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionTopicCreate#d999256: field icon_color: %w", err)
		}
		m.IconColor = value
	}
	if m.Flags.Has(0) {
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionTopicCreate#d999256: field icon_emoji_id: %w", err)
		}
		m.IconEmojiID = value
	}
	return nil
}

// SetTitleMissing sets value of TitleMissing conditional field.
func (m *MessageActionTopicCreate) SetTitleMissing(value bool) {
	if value {
		m.Flags.Set(1)
		m.TitleMissing = true
	} else {
		m.Flags.Unset(1)
		m.TitleMissing = false
	}
}

// GetTitleMissing returns value of TitleMissing conditional field.
func (m *MessageActionTopicCreate) GetTitleMissing() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(1)
}

// GetTitle returns value of Title field.
func (m *MessageActionTopicCreate) GetTitle() (value string) {
	if m == nil {
		return
	}
	return m.Title
}

// GetIconColor returns value of IconColor field.
func (m *MessageActionTopicCreate) GetIconColor() (value int) {
	if m == nil {
		return
	}
	return m.IconColor
}

// SetIconEmojiID sets value of IconEmojiID conditional field.
func (m *MessageActionTopicCreate) SetIconEmojiID(value int64) {
	m.Flags.Set(0)
	m.IconEmojiID = value
}

// GetIconEmojiID returns value of IconEmojiID conditional field and
// boolean which is true if field was set.
func (m *MessageActionTopicCreate) GetIconEmojiID() (value int64, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(0) {
		return value, false
	}
	return m.IconEmojiID, true
}

// MessageActionTopicEdit represents TL type `messageActionTopicEdit#c0944820`.
// Forum topic¹ information was edited.
//
// Links:
//  1. https://core.telegram.org/api/forum#forum-topics
//
// See https://core.telegram.org/constructor/messageActionTopicEdit for reference.
type MessageActionTopicEdit struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// New topic title.
	//
	// Use SetTitle and GetTitle helpers.
	Title string
	// ID of the new custom emoji¹ used as topic icon, or if it was removed.
	//
	// Links:
	//  1) https://core.telegram.org/api/custom-emoji
	//
	// Use SetIconEmojiID and GetIconEmojiID helpers.
	IconEmojiID int64
	// Whether the topic was opened or closed.
	//
	// Use SetClosed and GetClosed helpers.
	Closed bool
	// Whether the topic was hidden or unhidden (only valid for the "General" topic, id=1).
	//
	// Use SetHidden and GetHidden helpers.
	Hidden bool
}

// MessageActionTopicEditTypeID is TL type id of MessageActionTopicEdit.
const MessageActionTopicEditTypeID = 0xc0944820

// construct implements constructor of MessageActionClass.
func (m MessageActionTopicEdit) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionTopicEdit{}
)

func (m *MessageActionTopicEdit) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.Title == "") {
		return false
	}
	if !(m.IconEmojiID == 0) {
		return false
	}
	if !(m.Closed == false) {
		return false
	}
	if !(m.Hidden == false) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionTopicEdit from given interface.
func (m *MessageActionTopicEdit) FillFrom(from interface {
	GetTitle() (value string, ok bool)
	GetIconEmojiID() (value int64, ok bool)
	GetClosed() (value bool, ok bool)
	GetHidden() (value bool, ok bool)
}) {
	if val, ok := from.GetTitle(); ok {
		m.Title = val
	}

	if val, ok := from.GetIconEmojiID(); ok {
		m.IconEmojiID = val
	}

	if val, ok := from.GetClosed(); ok {
		m.Closed = val
	}

	if val, ok := from.GetHidden(); ok {
		m.Hidden = val
	}

}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionTopicEdit) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionTopicEdit",
		ID:   MessageActionTopicEditTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Title",
			SchemaName: "title",
			Null:       !m.Flags.Has(0),
		},
		{
			Name:       "IconEmojiID",
			SchemaName: "icon_emoji_id",
			Null:       !m.Flags.Has(1),
		},
		{
			Name:       "Closed",
			SchemaName: "closed",
			Null:       !m.Flags.Has(2),
		},
		{
			Name:       "Hidden",
			SchemaName: "hidden",
			Null:       !m.Flags.Has(3),
		},
	}
	return typ
}

// SetFlags sets flags for non-zero fields.
func (m *MessageActionTopicEdit) SetFlags() {
	if !(m.Title == "") {
		m.Flags.Set(0)
	}
	if !(m.IconEmojiID == 0) {
		m.Flags.Set(1)
	}
	if !(m.Closed == false) {
		m.Flags.Set(2)
	}
	if !(m.Hidden == false) {
		m.Flags.Set(3)
	}
}

// Encode implements bin.Encoder.
func (m *MessageActionTopicEdit) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionTopicEdit#c0944820 as nil")
	}
	b.PutID(MessageActionTopicEditTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionTopicEdit) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionTopicEdit#c0944820 as nil")
	}
	m.SetFlags()
	if err := m.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionTopicEdit#c0944820: field flags: %w", err)
	}
	if m.Flags.Has(0) {
		b.PutString(m.Title)
	}
	if m.Flags.Has(1) {
		b.PutLong(m.IconEmojiID)
	}
	if m.Flags.Has(2) {
		b.PutBool(m.Closed)
	}
	if m.Flags.Has(3) {
		b.PutBool(m.Hidden)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionTopicEdit) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionTopicEdit#c0944820 to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionTopicEdit#c0944820: field flags: %w", err)
		}
	}
	if m.Flags.Has(0) {
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionTopicEdit#c0944820: field title: %w", err)
		}
		m.Title = value
	}
	if m.Flags.Has(1) {
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionTopicEdit#c0944820: field icon_emoji_id: %w", err)
		}
		m.IconEmojiID = value
	}
	if m.Flags.Has(2) {
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionTopicEdit#c0944820: field closed: %w", err)
		}
		m.Closed = value
	}
	if m.Flags.Has(3) {
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionTopicEdit#c0944820: field hidden: %w", err)
		}
		m.Hidden = value
	}
	return nil
}

// SetTitle sets value of Title conditional field.
func (m *MessageActionTopicEdit) SetTitle(value string) {
	m.Flags.Set(0)
	m.Title = value
}

// GetTitle returns value of Title conditional field and
// boolean which is true if field was set.
func (m *MessageActionTopicEdit) GetTitle() (value string, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(0) {
		return value, false
	}
	return m.Title, true
}

// SetIconEmojiID sets value of IconEmojiID conditional field.
func (m *MessageActionTopicEdit) SetIconEmojiID(value int64) {
	m.Flags.Set(1)
	m.IconEmojiID = value
}

// GetIconEmojiID returns value of IconEmojiID conditional field and
// boolean which is true if field was set.
func (m *MessageActionTopicEdit) GetIconEmojiID() (value int64, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(1) {
		return value, false
	}
	return m.IconEmojiID, true
}

// SetClosed sets value of Closed conditional field.
func (m *MessageActionTopicEdit) SetClosed(value bool) {
	m.Flags.Set(2)
	m.Closed = value
}

// GetClosed returns value of Closed conditional field and
// boolean which is true if field was set.
func (m *MessageActionTopicEdit) GetClosed() (value bool, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(2) {
		return value, false
	}
	return m.Closed, true
}

// SetHidden sets value of Hidden conditional field.
func (m *MessageActionTopicEdit) SetHidden(value bool) {
	m.Flags.Set(3)
	m.Hidden = value
}

// GetHidden returns value of Hidden conditional field and
// boolean which is true if field was set.
func (m *MessageActionTopicEdit) GetHidden() (value bool, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(3) {
		return value, false
	}
	return m.Hidden, true
}

// MessageActionSuggestProfilePhoto represents TL type `messageActionSuggestProfilePhoto#57de635e`.
// A new profile picture was suggested using photos.uploadContactProfilePhoto¹.
//
// Links:
//  1. https://core.telegram.org/method/photos.uploadContactProfilePhoto
//
// See https://core.telegram.org/constructor/messageActionSuggestProfilePhoto for reference.
type MessageActionSuggestProfilePhoto struct {
	// The photo that the user suggested we set as profile picture.
	Photo PhotoClass
}

// MessageActionSuggestProfilePhotoTypeID is TL type id of MessageActionSuggestProfilePhoto.
const MessageActionSuggestProfilePhotoTypeID = 0x57de635e

// construct implements constructor of MessageActionClass.
func (m MessageActionSuggestProfilePhoto) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionSuggestProfilePhoto{}
)

func (m *MessageActionSuggestProfilePhoto) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Photo == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionSuggestProfilePhoto from given interface.
func (m *MessageActionSuggestProfilePhoto) FillFrom(from interface {
	GetPhoto() (value PhotoClass)
}) {
	m.Photo = from.GetPhoto()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionSuggestProfilePhoto) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionSuggestProfilePhoto",
		ID:   MessageActionSuggestProfilePhotoTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Photo",
			SchemaName: "photo",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionSuggestProfilePhoto) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionSuggestProfilePhoto#57de635e as nil")
	}
	b.PutID(MessageActionSuggestProfilePhotoTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionSuggestProfilePhoto) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionSuggestProfilePhoto#57de635e as nil")
	}
	if m.Photo == nil {
		return fmt.Errorf("unable to encode messageActionSuggestProfilePhoto#57de635e: field photo is nil")
	}
	if err := m.Photo.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionSuggestProfilePhoto#57de635e: field photo: %w", err)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionSuggestProfilePhoto) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionSuggestProfilePhoto#57de635e to nil")
	}
	{
		value, err := DecodePhoto(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionSuggestProfilePhoto#57de635e: field photo: %w", err)
		}
		m.Photo = value
	}
	return nil
}

// GetPhoto returns value of Photo field.
func (m *MessageActionSuggestProfilePhoto) GetPhoto() (value PhotoClass) {
	if m == nil {
		return
	}
	return m.Photo
}

// MessageActionRequestedPeer represents TL type `messageActionRequestedPeer#31518e9b`.
// Contains info about one or more peers that the we (the user) shared with the bot after
// clicking on a keyboardButtonRequestPeer¹ button (service message sent by the user).
//
// Links:
//  1. https://core.telegram.org/constructor/keyboardButtonRequestPeer
//
// See https://core.telegram.org/constructor/messageActionRequestedPeer for reference.
type MessageActionRequestedPeer struct {
	// button_id contained in the keyboardButtonRequestPeer¹
	//
	// Links:
	//  1) https://core.telegram.org/constructor/keyboardButtonRequestPeer
	ButtonID int
	// The shared peers
	Peers []PeerClass
}

// MessageActionRequestedPeerTypeID is TL type id of MessageActionRequestedPeer.
const MessageActionRequestedPeerTypeID = 0x31518e9b

// construct implements constructor of MessageActionClass.
func (m MessageActionRequestedPeer) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionRequestedPeer{}
)

func (m *MessageActionRequestedPeer) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.ButtonID == 0) {
		return false
	}
	if !(m.Peers == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionRequestedPeer from given interface.
func (m *MessageActionRequestedPeer) FillFrom(from interface {
	GetButtonID() (value int)
	GetPeers() (value []PeerClass)
}) {
	m.ButtonID = from.GetButtonID()
	m.Peers = from.GetPeers()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionRequestedPeer) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionRequestedPeer",
		ID:   MessageActionRequestedPeerTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "ButtonID",
			SchemaName: "button_id",
		},
		{
			Name:       "Peers",
			SchemaName: "peers",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionRequestedPeer) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionRequestedPeer#31518e9b as nil")
	}
	b.PutID(MessageActionRequestedPeerTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionRequestedPeer) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionRequestedPeer#31518e9b as nil")
	}
	b.PutInt(m.ButtonID)
	b.PutVectorHeader(len(m.Peers))
	for idx, v := range m.Peers {
		if v == nil {
			return fmt.Errorf("unable to encode messageActionRequestedPeer#31518e9b: field peers element with index %d is nil", idx)
		}
		if err := v.Encode(b); err != nil {
			return fmt.Errorf("unable to encode messageActionRequestedPeer#31518e9b: field peers element with index %d: %w", idx, err)
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionRequestedPeer) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionRequestedPeer#31518e9b to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionRequestedPeer#31518e9b: field button_id: %w", err)
		}
		m.ButtonID = value
	}
	{
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionRequestedPeer#31518e9b: field peers: %w", err)
		}

		if headerLen > 0 {
			m.Peers = make([]PeerClass, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := DecodePeer(b)
			if err != nil {
				return fmt.Errorf("unable to decode messageActionRequestedPeer#31518e9b: field peers: %w", err)
			}
			m.Peers = append(m.Peers, value)
		}
	}
	return nil
}

// GetButtonID returns value of ButtonID field.
func (m *MessageActionRequestedPeer) GetButtonID() (value int) {
	if m == nil {
		return
	}
	return m.ButtonID
}

// GetPeers returns value of Peers field.
func (m *MessageActionRequestedPeer) GetPeers() (value []PeerClass) {
	if m == nil {
		return
	}
	return m.Peers
}

// MapPeers returns field Peers wrapped in PeerClassArray helper.
func (m *MessageActionRequestedPeer) MapPeers() (value PeerClassArray) {
	return PeerClassArray(m.Peers)
}

// MessageActionSetChatWallPaper represents TL type `messageActionSetChatWallPaper#5060a3f4`.
// The wallpaper »¹ of the current chat was changed.
//
// Links:
//  1. https://core.telegram.org/api/wallpapers
//
// See https://core.telegram.org/constructor/messageActionSetChatWallPaper for reference.
type MessageActionSetChatWallPaper struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, indicates the user applied a wallpaper »¹ previously sent by the other user
	// in a messageActionSetChatWallPaper² message.
	//
	// Links:
	//  1) https://core.telegram.org/api/wallpapers
	//  2) https://core.telegram.org/constructor/messageActionSetChatWallPaper
	Same bool
	// If set, indicates the wallpaper was forcefully applied for both sides, without
	// explicit confirmation from the other side. If the message is incoming, and we did not
	// like the new wallpaper the other user has chosen for us, we can re-set our previous
	// wallpaper just on our side, by invoking messages.setChatWallPaper¹, providing only
	// the revert flag (and obviously the peer parameter).
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.setChatWallPaper
	ForBoth bool
	// New wallpaper¹
	//
	// Links:
	//  1) https://core.telegram.org/api/wallpapers
	Wallpaper WallPaperClass
}

// MessageActionSetChatWallPaperTypeID is TL type id of MessageActionSetChatWallPaper.
const MessageActionSetChatWallPaperTypeID = 0x5060a3f4

// construct implements constructor of MessageActionClass.
func (m MessageActionSetChatWallPaper) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionSetChatWallPaper{}
)

func (m *MessageActionSetChatWallPaper) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.Same == false) {
		return false
	}
	if !(m.ForBoth == false) {
		return false
	}
	if !(m.Wallpaper == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionSetChatWallPaper from given interface.
func (m *MessageActionSetChatWallPaper) FillFrom(from interface {
	GetSame() (value bool)
	GetForBoth() (value bool)
	GetWallpaper() (value WallPaperClass)
}) {
	m.Same = from.GetSame()
	m.ForBoth = from.GetForBoth()
	m.Wallpaper = from.GetWallpaper()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionSetChatWallPaper) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionSetChatWallPaper",
		ID:   MessageActionSetChatWallPaperTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Same",
			SchemaName: "same",
			Null:       !m.Flags.Has(0),
		},
		{
			Name:       "ForBoth",
			SchemaName: "for_both",
			Null:       !m.Flags.Has(1),
		},
		{
			Name:       "Wallpaper",
			SchemaName: "wallpaper",
		},
	}
	return typ
}

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

// Encode implements bin.Encoder.
func (m *MessageActionSetChatWallPaper) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionSetChatWallPaper#5060a3f4 as nil")
	}
	b.PutID(MessageActionSetChatWallPaperTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionSetChatWallPaper) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionSetChatWallPaper#5060a3f4 as nil")
	}
	m.SetFlags()
	if err := m.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionSetChatWallPaper#5060a3f4: field flags: %w", err)
	}
	if m.Wallpaper == nil {
		return fmt.Errorf("unable to encode messageActionSetChatWallPaper#5060a3f4: field wallpaper is nil")
	}
	if err := m.Wallpaper.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionSetChatWallPaper#5060a3f4: field wallpaper: %w", err)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionSetChatWallPaper) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionSetChatWallPaper#5060a3f4 to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionSetChatWallPaper#5060a3f4: field flags: %w", err)
		}
	}
	m.Same = m.Flags.Has(0)
	m.ForBoth = m.Flags.Has(1)
	{
		value, err := DecodeWallPaper(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionSetChatWallPaper#5060a3f4: field wallpaper: %w", err)
		}
		m.Wallpaper = value
	}
	return nil
}

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

// GetSame returns value of Same conditional field.
func (m *MessageActionSetChatWallPaper) GetSame() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(0)
}

// SetForBoth sets value of ForBoth conditional field.
func (m *MessageActionSetChatWallPaper) SetForBoth(value bool) {
	if value {
		m.Flags.Set(1)
		m.ForBoth = true
	} else {
		m.Flags.Unset(1)
		m.ForBoth = false
	}
}

// GetForBoth returns value of ForBoth conditional field.
func (m *MessageActionSetChatWallPaper) GetForBoth() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(1)
}

// GetWallpaper returns value of Wallpaper field.
func (m *MessageActionSetChatWallPaper) GetWallpaper() (value WallPaperClass) {
	if m == nil {
		return
	}
	return m.Wallpaper
}

// MessageActionGiftCode represents TL type `messageActionGiftCode#31c48347`.
// Contains a Telegram Premium giftcode link¹.
//
// Links:
//  1. https://core.telegram.org/api/links#premium-giftcode-links
//
// See https://core.telegram.org/constructor/messageActionGiftCode for reference.
type MessageActionGiftCode struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, this gift code was received from a giveaway »¹ started by a
	// channel/supergroup we're subscribed to.
	//
	// Links:
	//  1) https://core.telegram.org/api/giveaways
	ViaGiveaway bool
	// If set, the link was not redeemed¹ yet.
	//
	// Links:
	//  1) https://core.telegram.org/api/links#premium-giftcode-links
	Unclaimed bool
	// Identifier of the channel/supergroup that created the gift code either directly or
	// through a giveaway¹: if we import this giftcode link, we will also automatically
	// boost² this channel/supergroup.
	//
	// Links:
	//  1) https://core.telegram.org/api/giveaways
	//  2) https://core.telegram.org/api/boost
	//
	// Use SetBoostPeer and GetBoostPeer helpers.
	BoostPeer PeerClass
	// Days field of MessageActionGiftCode.
	Days int
	// Slug of the Telegram Premium giftcode link¹
	//
	// Links:
	//  1) https://core.telegram.org/api/links#premium-giftcode-links
	Slug string
	// Three-letter ISO 4217 currency¹ code
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments#supported-currencies
	//
	// Use SetCurrency and GetCurrency helpers.
	Currency string
	// Total price in the smallest units of the currency (integer, not float/double). For
	// example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in
	// currencies.json¹, it shows the number of digits past the decimal point for each
	// currency (2 for the majority of currencies).
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments/currencies.json
	//
	// Use SetAmount and GetAmount helpers.
	Amount int64
	// If set, the gift was made using the specified cryptocurrency.
	//
	// Use SetCryptoCurrency and GetCryptoCurrency helpers.
	CryptoCurrency string
	// If crypto_currency is set, contains the paid amount, in the smallest units of the
	// cryptocurrency.
	//
	// Use SetCryptoAmount and GetCryptoAmount helpers.
	CryptoAmount int64
	// Message attached with the gift
	//
	// Use SetMessage and GetMessage helpers.
	Message TextWithEntities
}

// MessageActionGiftCodeTypeID is TL type id of MessageActionGiftCode.
const MessageActionGiftCodeTypeID = 0x31c48347

// construct implements constructor of MessageActionClass.
func (m MessageActionGiftCode) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionGiftCode{}
)

func (m *MessageActionGiftCode) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.ViaGiveaway == false) {
		return false
	}
	if !(m.Unclaimed == false) {
		return false
	}
	if !(m.BoostPeer == nil) {
		return false
	}
	if !(m.Days == 0) {
		return false
	}
	if !(m.Slug == "") {
		return false
	}
	if !(m.Currency == "") {
		return false
	}
	if !(m.Amount == 0) {
		return false
	}
	if !(m.CryptoCurrency == "") {
		return false
	}
	if !(m.CryptoAmount == 0) {
		return false
	}
	if !(m.Message.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionGiftCode from given interface.
func (m *MessageActionGiftCode) FillFrom(from interface {
	GetViaGiveaway() (value bool)
	GetUnclaimed() (value bool)
	GetBoostPeer() (value PeerClass, ok bool)
	GetDays() (value int)
	GetSlug() (value string)
	GetCurrency() (value string, ok bool)
	GetAmount() (value int64, ok bool)
	GetCryptoCurrency() (value string, ok bool)
	GetCryptoAmount() (value int64, ok bool)
	GetMessage() (value TextWithEntities, ok bool)
}) {
	m.ViaGiveaway = from.GetViaGiveaway()
	m.Unclaimed = from.GetUnclaimed()
	if val, ok := from.GetBoostPeer(); ok {
		m.BoostPeer = val
	}

	m.Days = from.GetDays()
	m.Slug = from.GetSlug()
	if val, ok := from.GetCurrency(); ok {
		m.Currency = val
	}

	if val, ok := from.GetAmount(); ok {
		m.Amount = val
	}

	if val, ok := from.GetCryptoCurrency(); ok {
		m.CryptoCurrency = val
	}

	if val, ok := from.GetCryptoAmount(); ok {
		m.CryptoAmount = val
	}

	if val, ok := from.GetMessage(); ok {
		m.Message = val
	}

}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionGiftCode) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionGiftCode",
		ID:   MessageActionGiftCodeTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "ViaGiveaway",
			SchemaName: "via_giveaway",
			Null:       !m.Flags.Has(0),
		},
		{
			Name:       "Unclaimed",
			SchemaName: "unclaimed",
			Null:       !m.Flags.Has(5),
		},
		{
			Name:       "BoostPeer",
			SchemaName: "boost_peer",
			Null:       !m.Flags.Has(1),
		},
		{
			Name:       "Days",
			SchemaName: "days",
		},
		{
			Name:       "Slug",
			SchemaName: "slug",
		},
		{
			Name:       "Currency",
			SchemaName: "currency",
			Null:       !m.Flags.Has(2),
		},
		{
			Name:       "Amount",
			SchemaName: "amount",
			Null:       !m.Flags.Has(2),
		},
		{
			Name:       "CryptoCurrency",
			SchemaName: "crypto_currency",
			Null:       !m.Flags.Has(3),
		},
		{
			Name:       "CryptoAmount",
			SchemaName: "crypto_amount",
			Null:       !m.Flags.Has(3),
		},
		{
			Name:       "Message",
			SchemaName: "message",
			Null:       !m.Flags.Has(4),
		},
	}
	return typ
}

// SetFlags sets flags for non-zero fields.
func (m *MessageActionGiftCode) SetFlags() {
	if !(m.ViaGiveaway == false) {
		m.Flags.Set(0)
	}
	if !(m.Unclaimed == false) {
		m.Flags.Set(5)
	}
	if !(m.BoostPeer == nil) {
		m.Flags.Set(1)
	}
	if !(m.Currency == "") {
		m.Flags.Set(2)
	}
	if !(m.Amount == 0) {
		m.Flags.Set(2)
	}
	if !(m.CryptoCurrency == "") {
		m.Flags.Set(3)
	}
	if !(m.CryptoAmount == 0) {
		m.Flags.Set(3)
	}
	if !(m.Message.Zero()) {
		m.Flags.Set(4)
	}
}

// Encode implements bin.Encoder.
func (m *MessageActionGiftCode) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionGiftCode#31c48347 as nil")
	}
	b.PutID(MessageActionGiftCodeTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionGiftCode) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionGiftCode#31c48347 as nil")
	}
	m.SetFlags()
	if err := m.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionGiftCode#31c48347: field flags: %w", err)
	}
	if m.Flags.Has(1) {
		if m.BoostPeer == nil {
			return fmt.Errorf("unable to encode messageActionGiftCode#31c48347: field boost_peer is nil")
		}
		if err := m.BoostPeer.Encode(b); err != nil {
			return fmt.Errorf("unable to encode messageActionGiftCode#31c48347: field boost_peer: %w", err)
		}
	}
	b.PutInt(m.Days)
	b.PutString(m.Slug)
	if m.Flags.Has(2) {
		b.PutString(m.Currency)
	}
	if m.Flags.Has(2) {
		b.PutLong(m.Amount)
	}
	if m.Flags.Has(3) {
		b.PutString(m.CryptoCurrency)
	}
	if m.Flags.Has(3) {
		b.PutLong(m.CryptoAmount)
	}
	if m.Flags.Has(4) {
		if err := m.Message.Encode(b); err != nil {
			return fmt.Errorf("unable to encode messageActionGiftCode#31c48347: field message: %w", err)
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionGiftCode) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionGiftCode#31c48347 to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionGiftCode#31c48347: field flags: %w", err)
		}
	}
	m.ViaGiveaway = m.Flags.Has(0)
	m.Unclaimed = m.Flags.Has(5)
	if m.Flags.Has(1) {
		value, err := DecodePeer(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftCode#31c48347: field boost_peer: %w", err)
		}
		m.BoostPeer = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftCode#31c48347: field days: %w", err)
		}
		m.Days = value
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftCode#31c48347: field slug: %w", err)
		}
		m.Slug = value
	}
	if m.Flags.Has(2) {
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftCode#31c48347: field currency: %w", err)
		}
		m.Currency = value
	}
	if m.Flags.Has(2) {
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftCode#31c48347: field amount: %w", err)
		}
		m.Amount = value
	}
	if m.Flags.Has(3) {
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftCode#31c48347: field crypto_currency: %w", err)
		}
		m.CryptoCurrency = value
	}
	if m.Flags.Has(3) {
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftCode#31c48347: field crypto_amount: %w", err)
		}
		m.CryptoAmount = value
	}
	if m.Flags.Has(4) {
		if err := m.Message.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionGiftCode#31c48347: field message: %w", err)
		}
	}
	return nil
}

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

// GetViaGiveaway returns value of ViaGiveaway conditional field.
func (m *MessageActionGiftCode) GetViaGiveaway() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(0)
}

// SetUnclaimed sets value of Unclaimed conditional field.
func (m *MessageActionGiftCode) SetUnclaimed(value bool) {
	if value {
		m.Flags.Set(5)
		m.Unclaimed = true
	} else {
		m.Flags.Unset(5)
		m.Unclaimed = false
	}
}

// GetUnclaimed returns value of Unclaimed conditional field.
func (m *MessageActionGiftCode) GetUnclaimed() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(5)
}

// SetBoostPeer sets value of BoostPeer conditional field.
func (m *MessageActionGiftCode) SetBoostPeer(value PeerClass) {
	m.Flags.Set(1)
	m.BoostPeer = value
}

// GetBoostPeer returns value of BoostPeer conditional field and
// boolean which is true if field was set.
func (m *MessageActionGiftCode) GetBoostPeer() (value PeerClass, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(1) {
		return value, false
	}
	return m.BoostPeer, true
}

// GetDays returns value of Days field.
func (m *MessageActionGiftCode) GetDays() (value int) {
	if m == nil {
		return
	}
	return m.Days
}

// GetSlug returns value of Slug field.
func (m *MessageActionGiftCode) GetSlug() (value string) {
	if m == nil {
		return
	}
	return m.Slug
}

// SetCurrency sets value of Currency conditional field.
func (m *MessageActionGiftCode) SetCurrency(value string) {
	m.Flags.Set(2)
	m.Currency = value
}

// GetCurrency returns value of Currency conditional field and
// boolean which is true if field was set.
func (m *MessageActionGiftCode) GetCurrency() (value string, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(2) {
		return value, false
	}
	return m.Currency, true
}

// SetAmount sets value of Amount conditional field.
func (m *MessageActionGiftCode) SetAmount(value int64) {
	m.Flags.Set(2)
	m.Amount = value
}

// GetAmount returns value of Amount conditional field and
// boolean which is true if field was set.
func (m *MessageActionGiftCode) GetAmount() (value int64, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(2) {
		return value, false
	}
	return m.Amount, true
}

// SetCryptoCurrency sets value of CryptoCurrency conditional field.
func (m *MessageActionGiftCode) SetCryptoCurrency(value string) {
	m.Flags.Set(3)
	m.CryptoCurrency = value
}

// GetCryptoCurrency returns value of CryptoCurrency conditional field and
// boolean which is true if field was set.
func (m *MessageActionGiftCode) GetCryptoCurrency() (value string, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(3) {
		return value, false
	}
	return m.CryptoCurrency, true
}

// SetCryptoAmount sets value of CryptoAmount conditional field.
func (m *MessageActionGiftCode) SetCryptoAmount(value int64) {
	m.Flags.Set(3)
	m.CryptoAmount = value
}

// GetCryptoAmount returns value of CryptoAmount conditional field and
// boolean which is true if field was set.
func (m *MessageActionGiftCode) GetCryptoAmount() (value int64, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(3) {
		return value, false
	}
	return m.CryptoAmount, true
}

// SetMessage sets value of Message conditional field.
func (m *MessageActionGiftCode) SetMessage(value TextWithEntities) {
	m.Flags.Set(4)
	m.Message = value
}

// GetMessage returns value of Message conditional field and
// boolean which is true if field was set.
func (m *MessageActionGiftCode) GetMessage() (value TextWithEntities, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(4) {
		return value, false
	}
	return m.Message, true
}

// MessageActionGiveawayLaunch represents TL type `messageActionGiveawayLaunch#a80f51e4`.
// A giveaway¹ was started.
//
// Links:
//  1. https://core.telegram.org/api/giveaways
//
// See https://core.telegram.org/constructor/messageActionGiveawayLaunch for reference.
type MessageActionGiveawayLaunch struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// For Telegram Star giveaways¹, the total number of Telegram Stars being given away.
	//
	// Links:
	//  1) https://core.telegram.org/api/stars#star-giveaways
	//
	// Use SetStars and GetStars helpers.
	Stars int64
}

// MessageActionGiveawayLaunchTypeID is TL type id of MessageActionGiveawayLaunch.
const MessageActionGiveawayLaunchTypeID = 0xa80f51e4

// construct implements constructor of MessageActionClass.
func (m MessageActionGiveawayLaunch) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionGiveawayLaunch{}
)

func (m *MessageActionGiveawayLaunch) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.Stars == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionGiveawayLaunch from given interface.
func (m *MessageActionGiveawayLaunch) FillFrom(from interface {
	GetStars() (value int64, ok bool)
}) {
	if val, ok := from.GetStars(); ok {
		m.Stars = val
	}

}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionGiveawayLaunch) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionGiveawayLaunch",
		ID:   MessageActionGiveawayLaunchTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Stars",
			SchemaName: "stars",
			Null:       !m.Flags.Has(0),
		},
	}
	return typ
}

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

// Encode implements bin.Encoder.
func (m *MessageActionGiveawayLaunch) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionGiveawayLaunch#a80f51e4 as nil")
	}
	b.PutID(MessageActionGiveawayLaunchTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionGiveawayLaunch) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionGiveawayLaunch#a80f51e4 as nil")
	}
	m.SetFlags()
	if err := m.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionGiveawayLaunch#a80f51e4: field flags: %w", err)
	}
	if m.Flags.Has(0) {
		b.PutLong(m.Stars)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionGiveawayLaunch) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionGiveawayLaunch#a80f51e4 to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionGiveawayLaunch#a80f51e4: field flags: %w", err)
		}
	}
	if m.Flags.Has(0) {
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiveawayLaunch#a80f51e4: field stars: %w", err)
		}
		m.Stars = value
	}
	return nil
}

// SetStars sets value of Stars conditional field.
func (m *MessageActionGiveawayLaunch) SetStars(value int64) {
	m.Flags.Set(0)
	m.Stars = value
}

// GetStars returns value of Stars conditional field and
// boolean which is true if field was set.
func (m *MessageActionGiveawayLaunch) GetStars() (value int64, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(0) {
		return value, false
	}
	return m.Stars, true
}

// MessageActionGiveawayResults represents TL type `messageActionGiveawayResults#87e2f155`.
// A giveaway¹ has ended.
//
// Links:
//  1. https://core.telegram.org/api/giveaways
//
// See https://core.telegram.org/constructor/messageActionGiveawayResults for reference.
type MessageActionGiveawayResults struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, this is a Telegram Star giveaway¹
	//
	// Links:
	//  1) https://core.telegram.org/api/stars#star-giveaways
	Stars bool
	// Number of winners in the giveaway
	WinnersCount int
	// Number of undistributed prizes
	UnclaimedCount int
}

// MessageActionGiveawayResultsTypeID is TL type id of MessageActionGiveawayResults.
const MessageActionGiveawayResultsTypeID = 0x87e2f155

// construct implements constructor of MessageActionClass.
func (m MessageActionGiveawayResults) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionGiveawayResults{}
)

func (m *MessageActionGiveawayResults) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.Stars == false) {
		return false
	}
	if !(m.WinnersCount == 0) {
		return false
	}
	if !(m.UnclaimedCount == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionGiveawayResults from given interface.
func (m *MessageActionGiveawayResults) FillFrom(from interface {
	GetStars() (value bool)
	GetWinnersCount() (value int)
	GetUnclaimedCount() (value int)
}) {
	m.Stars = from.GetStars()
	m.WinnersCount = from.GetWinnersCount()
	m.UnclaimedCount = from.GetUnclaimedCount()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionGiveawayResults) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionGiveawayResults",
		ID:   MessageActionGiveawayResultsTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Stars",
			SchemaName: "stars",
			Null:       !m.Flags.Has(0),
		},
		{
			Name:       "WinnersCount",
			SchemaName: "winners_count",
		},
		{
			Name:       "UnclaimedCount",
			SchemaName: "unclaimed_count",
		},
	}
	return typ
}

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

// Encode implements bin.Encoder.
func (m *MessageActionGiveawayResults) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionGiveawayResults#87e2f155 as nil")
	}
	b.PutID(MessageActionGiveawayResultsTypeID)
	return m.EncodeBare(b)
}

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

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionGiveawayResults) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionGiveawayResults#87e2f155 to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionGiveawayResults#87e2f155: field flags: %w", err)
		}
	}
	m.Stars = m.Flags.Has(0)
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiveawayResults#87e2f155: field winners_count: %w", err)
		}
		m.WinnersCount = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiveawayResults#87e2f155: field unclaimed_count: %w", err)
		}
		m.UnclaimedCount = value
	}
	return nil
}

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

// GetStars returns value of Stars conditional field.
func (m *MessageActionGiveawayResults) GetStars() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(0)
}

// GetWinnersCount returns value of WinnersCount field.
func (m *MessageActionGiveawayResults) GetWinnersCount() (value int) {
	if m == nil {
		return
	}
	return m.WinnersCount
}

// GetUnclaimedCount returns value of UnclaimedCount field.
func (m *MessageActionGiveawayResults) GetUnclaimedCount() (value int) {
	if m == nil {
		return
	}
	return m.UnclaimedCount
}

// MessageActionBoostApply represents TL type `messageActionBoostApply#cc02aa6d`.
// Some boosts »¹ were applied to the channel or supergroup.
//
// Links:
//  1. https://core.telegram.org/api/boost
//
// See https://core.telegram.org/constructor/messageActionBoostApply for reference.
type MessageActionBoostApply struct {
	// Number of applied boosts¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/boost
	Boosts int
}

// MessageActionBoostApplyTypeID is TL type id of MessageActionBoostApply.
const MessageActionBoostApplyTypeID = 0xcc02aa6d

// construct implements constructor of MessageActionClass.
func (m MessageActionBoostApply) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionBoostApply{}
)

func (m *MessageActionBoostApply) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Boosts == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionBoostApply from given interface.
func (m *MessageActionBoostApply) FillFrom(from interface {
	GetBoosts() (value int)
}) {
	m.Boosts = from.GetBoosts()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionBoostApply) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionBoostApply",
		ID:   MessageActionBoostApplyTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Boosts",
			SchemaName: "boosts",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionBoostApply) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionBoostApply#cc02aa6d as nil")
	}
	b.PutID(MessageActionBoostApplyTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionBoostApply) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionBoostApply#cc02aa6d as nil")
	}
	b.PutInt(m.Boosts)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionBoostApply) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionBoostApply#cc02aa6d to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionBoostApply#cc02aa6d: field boosts: %w", err)
		}
		m.Boosts = value
	}
	return nil
}

// GetBoosts returns value of Boosts field.
func (m *MessageActionBoostApply) GetBoosts() (value int) {
	if m == nil {
		return
	}
	return m.Boosts
}

// MessageActionRequestedPeerSentMe represents TL type `messageActionRequestedPeerSentMe#93b31848`.
// Contains info about one or more peers that the a user shared with the me (the bot)
// after clicking on a keyboardButtonRequestPeer¹ button (service message received by
// the bot).
//
// Links:
//  1. https://core.telegram.org/constructor/keyboardButtonRequestPeer
//
// See https://core.telegram.org/constructor/messageActionRequestedPeerSentMe for reference.
type MessageActionRequestedPeerSentMe struct {
	// button_id contained in the keyboardButtonRequestPeer¹
	//
	// Links:
	//  1) https://core.telegram.org/constructor/keyboardButtonRequestPeer
	ButtonID int
	// Info about the shared peers.
	Peers []RequestedPeerClass
}

// MessageActionRequestedPeerSentMeTypeID is TL type id of MessageActionRequestedPeerSentMe.
const MessageActionRequestedPeerSentMeTypeID = 0x93b31848

// construct implements constructor of MessageActionClass.
func (m MessageActionRequestedPeerSentMe) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionRequestedPeerSentMe{}
)

func (m *MessageActionRequestedPeerSentMe) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.ButtonID == 0) {
		return false
	}
	if !(m.Peers == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionRequestedPeerSentMe from given interface.
func (m *MessageActionRequestedPeerSentMe) FillFrom(from interface {
	GetButtonID() (value int)
	GetPeers() (value []RequestedPeerClass)
}) {
	m.ButtonID = from.GetButtonID()
	m.Peers = from.GetPeers()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionRequestedPeerSentMe) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionRequestedPeerSentMe",
		ID:   MessageActionRequestedPeerSentMeTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "ButtonID",
			SchemaName: "button_id",
		},
		{
			Name:       "Peers",
			SchemaName: "peers",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionRequestedPeerSentMe) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionRequestedPeerSentMe#93b31848 as nil")
	}
	b.PutID(MessageActionRequestedPeerSentMeTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionRequestedPeerSentMe) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionRequestedPeerSentMe#93b31848 as nil")
	}
	b.PutInt(m.ButtonID)
	b.PutVectorHeader(len(m.Peers))
	for idx, v := range m.Peers {
		if v == nil {
			return fmt.Errorf("unable to encode messageActionRequestedPeerSentMe#93b31848: field peers element with index %d is nil", idx)
		}
		if err := v.Encode(b); err != nil {
			return fmt.Errorf("unable to encode messageActionRequestedPeerSentMe#93b31848: field peers element with index %d: %w", idx, err)
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionRequestedPeerSentMe) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionRequestedPeerSentMe#93b31848 to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionRequestedPeerSentMe#93b31848: field button_id: %w", err)
		}
		m.ButtonID = value
	}
	{
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionRequestedPeerSentMe#93b31848: field peers: %w", err)
		}

		if headerLen > 0 {
			m.Peers = make([]RequestedPeerClass, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := DecodeRequestedPeer(b)
			if err != nil {
				return fmt.Errorf("unable to decode messageActionRequestedPeerSentMe#93b31848: field peers: %w", err)
			}
			m.Peers = append(m.Peers, value)
		}
	}
	return nil
}

// GetButtonID returns value of ButtonID field.
func (m *MessageActionRequestedPeerSentMe) GetButtonID() (value int) {
	if m == nil {
		return
	}
	return m.ButtonID
}

// GetPeers returns value of Peers field.
func (m *MessageActionRequestedPeerSentMe) GetPeers() (value []RequestedPeerClass) {
	if m == nil {
		return
	}
	return m.Peers
}

// MapPeers returns field Peers wrapped in RequestedPeerClassArray helper.
func (m *MessageActionRequestedPeerSentMe) MapPeers() (value RequestedPeerClassArray) {
	return RequestedPeerClassArray(m.Peers)
}

// MessageActionPaymentRefunded represents TL type `messageActionPaymentRefunded#41b3e202`.
// Describes a payment refund (service message received by both users and bots).
//
// See https://core.telegram.org/constructor/messageActionPaymentRefunded for reference.
type MessageActionPaymentRefunded struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Identifier of the peer that returned the funds.
	Peer PeerClass
	// Currency, XTR for Telegram Stars.
	Currency string
	// Total price in the smallest units of the currency (integer, not float/double). For
	// example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in
	// currencies.json¹, it shows the number of digits past the decimal point for each
	// currency (2 for the majority of currencies).
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments/currencies.json
	TotalAmount int64
	// Bot specified invoice payload (only received by bots).
	//
	// Use SetPayload and GetPayload helpers.
	Payload []byte
	// Provider payment identifier
	Charge PaymentCharge
}

// MessageActionPaymentRefundedTypeID is TL type id of MessageActionPaymentRefunded.
const MessageActionPaymentRefundedTypeID = 0x41b3e202

// construct implements constructor of MessageActionClass.
func (m MessageActionPaymentRefunded) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionPaymentRefunded{}
)

func (m *MessageActionPaymentRefunded) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.Peer == nil) {
		return false
	}
	if !(m.Currency == "") {
		return false
	}
	if !(m.TotalAmount == 0) {
		return false
	}
	if !(m.Payload == nil) {
		return false
	}
	if !(m.Charge.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionPaymentRefunded from given interface.
func (m *MessageActionPaymentRefunded) FillFrom(from interface {
	GetPeer() (value PeerClass)
	GetCurrency() (value string)
	GetTotalAmount() (value int64)
	GetPayload() (value []byte, ok bool)
	GetCharge() (value PaymentCharge)
}) {
	m.Peer = from.GetPeer()
	m.Currency = from.GetCurrency()
	m.TotalAmount = from.GetTotalAmount()
	if val, ok := from.GetPayload(); ok {
		m.Payload = val
	}

	m.Charge = from.GetCharge()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionPaymentRefunded) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionPaymentRefunded",
		ID:   MessageActionPaymentRefundedTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Currency",
			SchemaName: "currency",
		},
		{
			Name:       "TotalAmount",
			SchemaName: "total_amount",
		},
		{
			Name:       "Payload",
			SchemaName: "payload",
			Null:       !m.Flags.Has(0),
		},
		{
			Name:       "Charge",
			SchemaName: "charge",
		},
	}
	return typ
}

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

// Encode implements bin.Encoder.
func (m *MessageActionPaymentRefunded) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionPaymentRefunded#41b3e202 as nil")
	}
	b.PutID(MessageActionPaymentRefundedTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionPaymentRefunded) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionPaymentRefunded#41b3e202 as nil")
	}
	m.SetFlags()
	if err := m.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionPaymentRefunded#41b3e202: field flags: %w", err)
	}
	if m.Peer == nil {
		return fmt.Errorf("unable to encode messageActionPaymentRefunded#41b3e202: field peer is nil")
	}
	if err := m.Peer.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionPaymentRefunded#41b3e202: field peer: %w", err)
	}
	b.PutString(m.Currency)
	b.PutLong(m.TotalAmount)
	if m.Flags.Has(0) {
		b.PutBytes(m.Payload)
	}
	if err := m.Charge.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionPaymentRefunded#41b3e202: field charge: %w", err)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionPaymentRefunded) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionPaymentRefunded#41b3e202 to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionPaymentRefunded#41b3e202: field flags: %w", err)
		}
	}
	{
		value, err := DecodePeer(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPaymentRefunded#41b3e202: field peer: %w", err)
		}
		m.Peer = value
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPaymentRefunded#41b3e202: field currency: %w", err)
		}
		m.Currency = value
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPaymentRefunded#41b3e202: field total_amount: %w", err)
		}
		m.TotalAmount = value
	}
	if m.Flags.Has(0) {
		value, err := b.Bytes()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPaymentRefunded#41b3e202: field payload: %w", err)
		}
		m.Payload = value
	}
	{
		if err := m.Charge.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionPaymentRefunded#41b3e202: field charge: %w", err)
		}
	}
	return nil
}

// GetPeer returns value of Peer field.
func (m *MessageActionPaymentRefunded) GetPeer() (value PeerClass) {
	if m == nil {
		return
	}
	return m.Peer
}

// GetCurrency returns value of Currency field.
func (m *MessageActionPaymentRefunded) GetCurrency() (value string) {
	if m == nil {
		return
	}
	return m.Currency
}

// GetTotalAmount returns value of TotalAmount field.
func (m *MessageActionPaymentRefunded) GetTotalAmount() (value int64) {
	if m == nil {
		return
	}
	return m.TotalAmount
}

// SetPayload sets value of Payload conditional field.
func (m *MessageActionPaymentRefunded) SetPayload(value []byte) {
	m.Flags.Set(0)
	m.Payload = value
}

// GetPayload returns value of Payload conditional field and
// boolean which is true if field was set.
func (m *MessageActionPaymentRefunded) GetPayload() (value []byte, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(0) {
		return value, false
	}
	return m.Payload, true
}

// GetCharge returns value of Charge field.
func (m *MessageActionPaymentRefunded) GetCharge() (value PaymentCharge) {
	if m == nil {
		return
	}
	return m.Charge
}

// MessageActionGiftStars represents TL type `messageActionGiftStars#45d5b021`.
// You gifted or were gifted some Telegram Stars¹.
// This service message should be displayed below the appropriate sticker from the
// inputStickerSetPremiumGifts »¹ stickerset »²:
//
// Links:
//  1. https://core.telegram.org/api/stars
//  2. https://core.telegram.org/constructor/inputStickerSetPremiumGifts
//  3. https://core.telegram.org/api/stickers#stickersets
//
// See https://core.telegram.org/constructor/messageActionGiftStars for reference.
type MessageActionGiftStars struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Three-letter ISO 4217 currency¹ code
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments#supported-currencies
	Currency string
	// Price of the gift in the smallest units of the currency (integer, not float/double).
	// For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in
	// currencies.json¹, it shows the number of digits past the decimal point for each
	// currency (2 for the majority of currencies).
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments/currencies.json
	Amount int64
	// Amount of gifted stars
	Stars int64
	// If the gift was bought using a cryptocurrency, the cryptocurrency name.
	//
	// Use SetCryptoCurrency and GetCryptoCurrency helpers.
	CryptoCurrency string
	// If the gift was bought using a cryptocurrency, price of the gift in the smallest units
	// of a cryptocurrency.
	//
	// Use SetCryptoAmount and GetCryptoAmount helpers.
	CryptoAmount int64
	// Identifier of the transaction, only visible to the receiver of the gift.
	//
	// Use SetTransactionID and GetTransactionID helpers.
	TransactionID string
}

// MessageActionGiftStarsTypeID is TL type id of MessageActionGiftStars.
const MessageActionGiftStarsTypeID = 0x45d5b021

// construct implements constructor of MessageActionClass.
func (m MessageActionGiftStars) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionGiftStars{}
)

func (m *MessageActionGiftStars) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.Currency == "") {
		return false
	}
	if !(m.Amount == 0) {
		return false
	}
	if !(m.Stars == 0) {
		return false
	}
	if !(m.CryptoCurrency == "") {
		return false
	}
	if !(m.CryptoAmount == 0) {
		return false
	}
	if !(m.TransactionID == "") {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionGiftStars from given interface.
func (m *MessageActionGiftStars) FillFrom(from interface {
	GetCurrency() (value string)
	GetAmount() (value int64)
	GetStars() (value int64)
	GetCryptoCurrency() (value string, ok bool)
	GetCryptoAmount() (value int64, ok bool)
	GetTransactionID() (value string, ok bool)
}) {
	m.Currency = from.GetCurrency()
	m.Amount = from.GetAmount()
	m.Stars = from.GetStars()
	if val, ok := from.GetCryptoCurrency(); ok {
		m.CryptoCurrency = val
	}

	if val, ok := from.GetCryptoAmount(); ok {
		m.CryptoAmount = val
	}

	if val, ok := from.GetTransactionID(); ok {
		m.TransactionID = val
	}

}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionGiftStars) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionGiftStars",
		ID:   MessageActionGiftStarsTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Currency",
			SchemaName: "currency",
		},
		{
			Name:       "Amount",
			SchemaName: "amount",
		},
		{
			Name:       "Stars",
			SchemaName: "stars",
		},
		{
			Name:       "CryptoCurrency",
			SchemaName: "crypto_currency",
			Null:       !m.Flags.Has(0),
		},
		{
			Name:       "CryptoAmount",
			SchemaName: "crypto_amount",
			Null:       !m.Flags.Has(0),
		},
		{
			Name:       "TransactionID",
			SchemaName: "transaction_id",
			Null:       !m.Flags.Has(1),
		},
	}
	return typ
}

// SetFlags sets flags for non-zero fields.
func (m *MessageActionGiftStars) SetFlags() {
	if !(m.CryptoCurrency == "") {
		m.Flags.Set(0)
	}
	if !(m.CryptoAmount == 0) {
		m.Flags.Set(0)
	}
	if !(m.TransactionID == "") {
		m.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func (m *MessageActionGiftStars) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionGiftStars#45d5b021 as nil")
	}
	b.PutID(MessageActionGiftStarsTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionGiftStars) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionGiftStars#45d5b021 as nil")
	}
	m.SetFlags()
	if err := m.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionGiftStars#45d5b021: field flags: %w", err)
	}
	b.PutString(m.Currency)
	b.PutLong(m.Amount)
	b.PutLong(m.Stars)
	if m.Flags.Has(0) {
		b.PutString(m.CryptoCurrency)
	}
	if m.Flags.Has(0) {
		b.PutLong(m.CryptoAmount)
	}
	if m.Flags.Has(1) {
		b.PutString(m.TransactionID)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionGiftStars) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionGiftStars#45d5b021 to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionGiftStars#45d5b021: field flags: %w", err)
		}
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftStars#45d5b021: field currency: %w", err)
		}
		m.Currency = value
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftStars#45d5b021: field amount: %w", err)
		}
		m.Amount = value
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftStars#45d5b021: field stars: %w", err)
		}
		m.Stars = value
	}
	if m.Flags.Has(0) {
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftStars#45d5b021: field crypto_currency: %w", err)
		}
		m.CryptoCurrency = value
	}
	if m.Flags.Has(0) {
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftStars#45d5b021: field crypto_amount: %w", err)
		}
		m.CryptoAmount = value
	}
	if m.Flags.Has(1) {
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftStars#45d5b021: field transaction_id: %w", err)
		}
		m.TransactionID = value
	}
	return nil
}

// GetCurrency returns value of Currency field.
func (m *MessageActionGiftStars) GetCurrency() (value string) {
	if m == nil {
		return
	}
	return m.Currency
}

// GetAmount returns value of Amount field.
func (m *MessageActionGiftStars) GetAmount() (value int64) {
	if m == nil {
		return
	}
	return m.Amount
}

// GetStars returns value of Stars field.
func (m *MessageActionGiftStars) GetStars() (value int64) {
	if m == nil {
		return
	}
	return m.Stars
}

// SetCryptoCurrency sets value of CryptoCurrency conditional field.
func (m *MessageActionGiftStars) SetCryptoCurrency(value string) {
	m.Flags.Set(0)
	m.CryptoCurrency = value
}

// GetCryptoCurrency returns value of CryptoCurrency conditional field and
// boolean which is true if field was set.
func (m *MessageActionGiftStars) GetCryptoCurrency() (value string, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(0) {
		return value, false
	}
	return m.CryptoCurrency, true
}

// SetCryptoAmount sets value of CryptoAmount conditional field.
func (m *MessageActionGiftStars) SetCryptoAmount(value int64) {
	m.Flags.Set(0)
	m.CryptoAmount = value
}

// GetCryptoAmount returns value of CryptoAmount conditional field and
// boolean which is true if field was set.
func (m *MessageActionGiftStars) GetCryptoAmount() (value int64, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(0) {
		return value, false
	}
	return m.CryptoAmount, true
}

// SetTransactionID sets value of TransactionID conditional field.
func (m *MessageActionGiftStars) SetTransactionID(value string) {
	m.Flags.Set(1)
	m.TransactionID = value
}

// GetTransactionID returns value of TransactionID conditional field and
// boolean which is true if field was set.
func (m *MessageActionGiftStars) GetTransactionID() (value string, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(1) {
		return value, false
	}
	return m.TransactionID, true
}

// MessageActionPrizeStars represents TL type `messageActionPrizeStars#b00c47a2`.
// You won some Telegram Stars¹ in a Telegram Star giveaway »².
// This service message should be displayed below the appropriate sticker from the
// inputStickerSetPremiumGifts »¹ stickerset »²:
//
// Links:
//  1. https://core.telegram.org/api/stars
//  2. https://core.telegram.org/api/giveaways#star-giveaways
//  3. https://core.telegram.org/constructor/inputStickerSetPremiumGifts
//  4. https://core.telegram.org/api/stickers#stickersets
//
// See https://core.telegram.org/constructor/messageActionPrizeStars for reference.
type MessageActionPrizeStars struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, this indicates the reverse transaction that refunds the remaining stars to the
	// creator of a giveaway if, when the giveaway ends, the number of members in the channel
	// is smaller than the number of winners in the giveaway.
	Unclaimed bool
	// The number of Telegram Stars you won
	Stars int64
	// ID of the telegram star transaction.
	TransactionID string
	// Identifier of the peer that was automatically boosted by the winners of the giveaway.
	BoostPeer PeerClass
	// ID of the message containing the messageMediaGiveaway¹
	//
	// Links:
	//  1) https://core.telegram.org/constructor/messageMediaGiveaway
	GiveawayMsgID int
}

// MessageActionPrizeStarsTypeID is TL type id of MessageActionPrizeStars.
const MessageActionPrizeStarsTypeID = 0xb00c47a2

// construct implements constructor of MessageActionClass.
func (m MessageActionPrizeStars) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionPrizeStars{}
)

func (m *MessageActionPrizeStars) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.Unclaimed == false) {
		return false
	}
	if !(m.Stars == 0) {
		return false
	}
	if !(m.TransactionID == "") {
		return false
	}
	if !(m.BoostPeer == nil) {
		return false
	}
	if !(m.GiveawayMsgID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionPrizeStars from given interface.
func (m *MessageActionPrizeStars) FillFrom(from interface {
	GetUnclaimed() (value bool)
	GetStars() (value int64)
	GetTransactionID() (value string)
	GetBoostPeer() (value PeerClass)
	GetGiveawayMsgID() (value int)
}) {
	m.Unclaimed = from.GetUnclaimed()
	m.Stars = from.GetStars()
	m.TransactionID = from.GetTransactionID()
	m.BoostPeer = from.GetBoostPeer()
	m.GiveawayMsgID = from.GetGiveawayMsgID()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionPrizeStars) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionPrizeStars",
		ID:   MessageActionPrizeStarsTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Unclaimed",
			SchemaName: "unclaimed",
			Null:       !m.Flags.Has(0),
		},
		{
			Name:       "Stars",
			SchemaName: "stars",
		},
		{
			Name:       "TransactionID",
			SchemaName: "transaction_id",
		},
		{
			Name:       "BoostPeer",
			SchemaName: "boost_peer",
		},
		{
			Name:       "GiveawayMsgID",
			SchemaName: "giveaway_msg_id",
		},
	}
	return typ
}

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

// Encode implements bin.Encoder.
func (m *MessageActionPrizeStars) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionPrizeStars#b00c47a2 as nil")
	}
	b.PutID(MessageActionPrizeStarsTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionPrizeStars) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionPrizeStars#b00c47a2 as nil")
	}
	m.SetFlags()
	if err := m.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionPrizeStars#b00c47a2: field flags: %w", err)
	}
	b.PutLong(m.Stars)
	b.PutString(m.TransactionID)
	if m.BoostPeer == nil {
		return fmt.Errorf("unable to encode messageActionPrizeStars#b00c47a2: field boost_peer is nil")
	}
	if err := m.BoostPeer.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionPrizeStars#b00c47a2: field boost_peer: %w", err)
	}
	b.PutInt(m.GiveawayMsgID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionPrizeStars) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionPrizeStars#b00c47a2 to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionPrizeStars#b00c47a2: field flags: %w", err)
		}
	}
	m.Unclaimed = m.Flags.Has(0)
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPrizeStars#b00c47a2: field stars: %w", err)
		}
		m.Stars = value
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPrizeStars#b00c47a2: field transaction_id: %w", err)
		}
		m.TransactionID = value
	}
	{
		value, err := DecodePeer(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPrizeStars#b00c47a2: field boost_peer: %w", err)
		}
		m.BoostPeer = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPrizeStars#b00c47a2: field giveaway_msg_id: %w", err)
		}
		m.GiveawayMsgID = value
	}
	return nil
}

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

// GetUnclaimed returns value of Unclaimed conditional field.
func (m *MessageActionPrizeStars) GetUnclaimed() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(0)
}

// GetStars returns value of Stars field.
func (m *MessageActionPrizeStars) GetStars() (value int64) {
	if m == nil {
		return
	}
	return m.Stars
}

// GetTransactionID returns value of TransactionID field.
func (m *MessageActionPrizeStars) GetTransactionID() (value string) {
	if m == nil {
		return
	}
	return m.TransactionID
}

// GetBoostPeer returns value of BoostPeer field.
func (m *MessageActionPrizeStars) GetBoostPeer() (value PeerClass) {
	if m == nil {
		return
	}
	return m.BoostPeer
}

// GetGiveawayMsgID returns value of GiveawayMsgID field.
func (m *MessageActionPrizeStars) GetGiveawayMsgID() (value int) {
	if m == nil {
		return
	}
	return m.GiveawayMsgID
}

// MessageActionStarGift represents TL type `messageActionStarGift#db596550`.
// You received a gift, see here »¹ for more info.
//
// Links:
//  1. https://core.telegram.org/api/gifts
//
// See https://core.telegram.org/constructor/messageActionStarGift for reference.
type MessageActionStarGift struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, the name of the sender of the gift will be hidden if the destination user
	// decides to display the gift on their profile
	NameHidden bool
	// Whether this gift was added to the destination user's profile (may be toggled using
	// payments.saveStarGift¹ and fetched using payments.getSavedStarGifts²)
	//
	// Links:
	//  1) https://core.telegram.org/method/payments.saveStarGift
	//  2) https://core.telegram.org/method/payments.getSavedStarGifts
	Saved bool
	// Whether this gift was converted to Telegram Stars¹ and cannot be displayed on the
	// profile anymore.
	//
	// Links:
	//  1) https://core.telegram.org/api/stars
	Converted bool
	// This gift was upgraded to a collectible gift »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#collectible-gifts
	Upgraded bool
	// This gift is not available anymore because a request to refund the payment related to
	// this gift was made, and the money was returned.
	Refunded bool
	// If set, this gift can be upgraded to a collectible gift¹; can only be set for the
	// receiver of a gift.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#upgrade-a-gift-to-a-collectible-gift
	CanUpgrade bool
	// The sender has already pre-paid for the upgrade of this gift to a collectible gift.
	PrepaidUpgrade bool
	// This service message is the notification of a separate pre-payment for the upgrade of
	// a gift we own¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#prepaying-for-someone-elses-upgrade
	UpgradeSeparate bool
	// AuctionAcquired field of MessageActionStarGift.
	AuctionAcquired bool
	// Info about the gift
	Gift StarGiftClass
	// Additional message from the sender of the gift
	//
	// Use SetMessage and GetMessage helpers.
	Message TextWithEntities
	// The receiver of this gift may convert it to this many Telegram Stars, instead of
	// displaying it on their profile page.convert_stars will be equal to stars only if the
	// gift was bought using recently bought Telegram Stars, otherwise it will be less than
	// stars.
	//
	// Use SetConvertStars and GetConvertStars helpers.
	ConvertStars int64
	// If set, this gift was upgraded to a collectible gift¹, and the corresponding
	// messageActionStarGiftUnique² is available at the specified message ID.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#upgrade-a-gift-to-a-collectible-gift
	//  2) https://core.telegram.org/constructor/messageActionStarGiftUnique
	//
	// Use SetUpgradeMsgID and GetUpgradeMsgID helpers.
	UpgradeMsgID int
	// The number of Telegram Stars the user can pay to convert the gift into a collectible
	// gift »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#collectible-gifts
	//
	// Use SetUpgradeStars and GetUpgradeStars helpers.
	UpgradeStars int64
	// Sender of the gift (unset for anonymous gifts).
	//
	// Use SetFromID and GetFromID helpers.
	FromID PeerClass
	// Receiver of the gift.
	//
	// Use SetPeer and GetPeer helpers.
	Peer PeerClass
	// For channel gifts, ID to use in inputSavedStarGiftChat¹ constructors.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/inputSavedStarGiftChat
	//
	// Use SetSavedID and GetSavedID helpers.
	SavedID int64
	// Hash to prepay for a gift upgrade separately »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#prepaying-for-someone-elses-upgrade
	//
	// Use SetPrepaidUpgradeHash and GetPrepaidUpgradeHash helpers.
	PrepaidUpgradeHash string
	// For separate upgrades¹, the identifier of the message with the gift whose upgrade was
	// prepaid (only valid for the receiver of the service message).
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#prepaying-for-someone-elses-upgrade
	//
	// Use SetGiftMsgID and GetGiftMsgID helpers.
	GiftMsgID int
	// ToID field of MessageActionStarGift.
	//
	// Use SetToID and GetToID helpers.
	ToID PeerClass
}

// MessageActionStarGiftTypeID is TL type id of MessageActionStarGift.
const MessageActionStarGiftTypeID = 0xdb596550

// construct implements constructor of MessageActionClass.
func (m MessageActionStarGift) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionStarGift{}
)

func (m *MessageActionStarGift) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.NameHidden == false) {
		return false
	}
	if !(m.Saved == false) {
		return false
	}
	if !(m.Converted == false) {
		return false
	}
	if !(m.Upgraded == false) {
		return false
	}
	if !(m.Refunded == false) {
		return false
	}
	if !(m.CanUpgrade == false) {
		return false
	}
	if !(m.PrepaidUpgrade == false) {
		return false
	}
	if !(m.UpgradeSeparate == false) {
		return false
	}
	if !(m.AuctionAcquired == false) {
		return false
	}
	if !(m.Gift == nil) {
		return false
	}
	if !(m.Message.Zero()) {
		return false
	}
	if !(m.ConvertStars == 0) {
		return false
	}
	if !(m.UpgradeMsgID == 0) {
		return false
	}
	if !(m.UpgradeStars == 0) {
		return false
	}
	if !(m.FromID == nil) {
		return false
	}
	if !(m.Peer == nil) {
		return false
	}
	if !(m.SavedID == 0) {
		return false
	}
	if !(m.PrepaidUpgradeHash == "") {
		return false
	}
	if !(m.GiftMsgID == 0) {
		return false
	}
	if !(m.ToID == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionStarGift from given interface.
func (m *MessageActionStarGift) FillFrom(from interface {
	GetNameHidden() (value bool)
	GetSaved() (value bool)
	GetConverted() (value bool)
	GetUpgraded() (value bool)
	GetRefunded() (value bool)
	GetCanUpgrade() (value bool)
	GetPrepaidUpgrade() (value bool)
	GetUpgradeSeparate() (value bool)
	GetAuctionAcquired() (value bool)
	GetGift() (value StarGiftClass)
	GetMessage() (value TextWithEntities, ok bool)
	GetConvertStars() (value int64, ok bool)
	GetUpgradeMsgID() (value int, ok bool)
	GetUpgradeStars() (value int64, ok bool)
	GetFromID() (value PeerClass, ok bool)
	GetPeer() (value PeerClass, ok bool)
	GetSavedID() (value int64, ok bool)
	GetPrepaidUpgradeHash() (value string, ok bool)
	GetGiftMsgID() (value int, ok bool)
	GetToID() (value PeerClass, ok bool)
}) {
	m.NameHidden = from.GetNameHidden()
	m.Saved = from.GetSaved()
	m.Converted = from.GetConverted()
	m.Upgraded = from.GetUpgraded()
	m.Refunded = from.GetRefunded()
	m.CanUpgrade = from.GetCanUpgrade()
	m.PrepaidUpgrade = from.GetPrepaidUpgrade()
	m.UpgradeSeparate = from.GetUpgradeSeparate()
	m.AuctionAcquired = from.GetAuctionAcquired()
	m.Gift = from.GetGift()
	if val, ok := from.GetMessage(); ok {
		m.Message = val
	}

	if val, ok := from.GetConvertStars(); ok {
		m.ConvertStars = val
	}

	if val, ok := from.GetUpgradeMsgID(); ok {
		m.UpgradeMsgID = val
	}

	if val, ok := from.GetUpgradeStars(); ok {
		m.UpgradeStars = val
	}

	if val, ok := from.GetFromID(); ok {
		m.FromID = val
	}

	if val, ok := from.GetPeer(); ok {
		m.Peer = val
	}

	if val, ok := from.GetSavedID(); ok {
		m.SavedID = val
	}

	if val, ok := from.GetPrepaidUpgradeHash(); ok {
		m.PrepaidUpgradeHash = val
	}

	if val, ok := from.GetGiftMsgID(); ok {
		m.GiftMsgID = val
	}

	if val, ok := from.GetToID(); ok {
		m.ToID = val
	}

}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionStarGift) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionStarGift",
		ID:   MessageActionStarGiftTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "NameHidden",
			SchemaName: "name_hidden",
			Null:       !m.Flags.Has(0),
		},
		{
			Name:       "Saved",
			SchemaName: "saved",
			Null:       !m.Flags.Has(2),
		},
		{
			Name:       "Converted",
			SchemaName: "converted",
			Null:       !m.Flags.Has(3),
		},
		{
			Name:       "Upgraded",
			SchemaName: "upgraded",
			Null:       !m.Flags.Has(5),
		},
		{
			Name:       "Refunded",
			SchemaName: "refunded",
			Null:       !m.Flags.Has(9),
		},
		{
			Name:       "CanUpgrade",
			SchemaName: "can_upgrade",
			Null:       !m.Flags.Has(10),
		},
		{
			Name:       "PrepaidUpgrade",
			SchemaName: "prepaid_upgrade",
			Null:       !m.Flags.Has(13),
		},
		{
			Name:       "UpgradeSeparate",
			SchemaName: "upgrade_separate",
			Null:       !m.Flags.Has(16),
		},
		{
			Name:       "AuctionAcquired",
			SchemaName: "auction_acquired",
			Null:       !m.Flags.Has(17),
		},
		{
			Name:       "Gift",
			SchemaName: "gift",
		},
		{
			Name:       "Message",
			SchemaName: "message",
			Null:       !m.Flags.Has(1),
		},
		{
			Name:       "ConvertStars",
			SchemaName: "convert_stars",
			Null:       !m.Flags.Has(4),
		},
		{
			Name:       "UpgradeMsgID",
			SchemaName: "upgrade_msg_id",
			Null:       !m.Flags.Has(5),
		},
		{
			Name:       "UpgradeStars",
			SchemaName: "upgrade_stars",
			Null:       !m.Flags.Has(8),
		},
		{
			Name:       "FromID",
			SchemaName: "from_id",
			Null:       !m.Flags.Has(11),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
			Null:       !m.Flags.Has(12),
		},
		{
			Name:       "SavedID",
			SchemaName: "saved_id",
			Null:       !m.Flags.Has(12),
		},
		{
			Name:       "PrepaidUpgradeHash",
			SchemaName: "prepaid_upgrade_hash",
			Null:       !m.Flags.Has(14),
		},
		{
			Name:       "GiftMsgID",
			SchemaName: "gift_msg_id",
			Null:       !m.Flags.Has(15),
		},
		{
			Name:       "ToID",
			SchemaName: "to_id",
			Null:       !m.Flags.Has(18),
		},
	}
	return typ
}

// SetFlags sets flags for non-zero fields.
func (m *MessageActionStarGift) SetFlags() {
	if !(m.NameHidden == false) {
		m.Flags.Set(0)
	}
	if !(m.Saved == false) {
		m.Flags.Set(2)
	}
	if !(m.Converted == false) {
		m.Flags.Set(3)
	}
	if !(m.Upgraded == false) {
		m.Flags.Set(5)
	}
	if !(m.Refunded == false) {
		m.Flags.Set(9)
	}
	if !(m.CanUpgrade == false) {
		m.Flags.Set(10)
	}
	if !(m.PrepaidUpgrade == false) {
		m.Flags.Set(13)
	}
	if !(m.UpgradeSeparate == false) {
		m.Flags.Set(16)
	}
	if !(m.AuctionAcquired == false) {
		m.Flags.Set(17)
	}
	if !(m.Message.Zero()) {
		m.Flags.Set(1)
	}
	if !(m.ConvertStars == 0) {
		m.Flags.Set(4)
	}
	if !(m.UpgradeMsgID == 0) {
		m.Flags.Set(5)
	}
	if !(m.UpgradeStars == 0) {
		m.Flags.Set(8)
	}
	if !(m.FromID == nil) {
		m.Flags.Set(11)
	}
	if !(m.Peer == nil) {
		m.Flags.Set(12)
	}
	if !(m.SavedID == 0) {
		m.Flags.Set(12)
	}
	if !(m.PrepaidUpgradeHash == "") {
		m.Flags.Set(14)
	}
	if !(m.GiftMsgID == 0) {
		m.Flags.Set(15)
	}
	if !(m.ToID == nil) {
		m.Flags.Set(18)
	}
}

// Encode implements bin.Encoder.
func (m *MessageActionStarGift) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionStarGift#db596550 as nil")
	}
	b.PutID(MessageActionStarGiftTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionStarGift) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionStarGift#db596550 as nil")
	}
	m.SetFlags()
	if err := m.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionStarGift#db596550: field flags: %w", err)
	}
	if m.Gift == nil {
		return fmt.Errorf("unable to encode messageActionStarGift#db596550: field gift is nil")
	}
	if err := m.Gift.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionStarGift#db596550: field gift: %w", err)
	}
	if m.Flags.Has(1) {
		if err := m.Message.Encode(b); err != nil {
			return fmt.Errorf("unable to encode messageActionStarGift#db596550: field message: %w", err)
		}
	}
	if m.Flags.Has(4) {
		b.PutLong(m.ConvertStars)
	}
	if m.Flags.Has(5) {
		b.PutInt(m.UpgradeMsgID)
	}
	if m.Flags.Has(8) {
		b.PutLong(m.UpgradeStars)
	}
	if m.Flags.Has(11) {
		if m.FromID == nil {
			return fmt.Errorf("unable to encode messageActionStarGift#db596550: field from_id is nil")
		}
		if err := m.FromID.Encode(b); err != nil {
			return fmt.Errorf("unable to encode messageActionStarGift#db596550: field from_id: %w", err)
		}
	}
	if m.Flags.Has(12) {
		if m.Peer == nil {
			return fmt.Errorf("unable to encode messageActionStarGift#db596550: field peer is nil")
		}
		if err := m.Peer.Encode(b); err != nil {
			return fmt.Errorf("unable to encode messageActionStarGift#db596550: field peer: %w", err)
		}
	}
	if m.Flags.Has(12) {
		b.PutLong(m.SavedID)
	}
	if m.Flags.Has(14) {
		b.PutString(m.PrepaidUpgradeHash)
	}
	if m.Flags.Has(15) {
		b.PutInt(m.GiftMsgID)
	}
	if m.Flags.Has(18) {
		if m.ToID == nil {
			return fmt.Errorf("unable to encode messageActionStarGift#db596550: field to_id is nil")
		}
		if err := m.ToID.Encode(b); err != nil {
			return fmt.Errorf("unable to encode messageActionStarGift#db596550: field to_id: %w", err)
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionStarGift) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionStarGift#db596550 to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionStarGift#db596550: field flags: %w", err)
		}
	}
	m.NameHidden = m.Flags.Has(0)
	m.Saved = m.Flags.Has(2)
	m.Converted = m.Flags.Has(3)
	m.Upgraded = m.Flags.Has(5)
	m.Refunded = m.Flags.Has(9)
	m.CanUpgrade = m.Flags.Has(10)
	m.PrepaidUpgrade = m.Flags.Has(13)
	m.UpgradeSeparate = m.Flags.Has(16)
	m.AuctionAcquired = m.Flags.Has(17)
	{
		value, err := DecodeStarGift(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionStarGift#db596550: field gift: %w", err)
		}
		m.Gift = value
	}
	if m.Flags.Has(1) {
		if err := m.Message.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionStarGift#db596550: field message: %w", err)
		}
	}
	if m.Flags.Has(4) {
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionStarGift#db596550: field convert_stars: %w", err)
		}
		m.ConvertStars = value
	}
	if m.Flags.Has(5) {
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionStarGift#db596550: field upgrade_msg_id: %w", err)
		}
		m.UpgradeMsgID = value
	}
	if m.Flags.Has(8) {
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionStarGift#db596550: field upgrade_stars: %w", err)
		}
		m.UpgradeStars = value
	}
	if m.Flags.Has(11) {
		value, err := DecodePeer(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionStarGift#db596550: field from_id: %w", err)
		}
		m.FromID = value
	}
	if m.Flags.Has(12) {
		value, err := DecodePeer(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionStarGift#db596550: field peer: %w", err)
		}
		m.Peer = value
	}
	if m.Flags.Has(12) {
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionStarGift#db596550: field saved_id: %w", err)
		}
		m.SavedID = value
	}
	if m.Flags.Has(14) {
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionStarGift#db596550: field prepaid_upgrade_hash: %w", err)
		}
		m.PrepaidUpgradeHash = value
	}
	if m.Flags.Has(15) {
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionStarGift#db596550: field gift_msg_id: %w", err)
		}
		m.GiftMsgID = value
	}
	if m.Flags.Has(18) {
		value, err := DecodePeer(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionStarGift#db596550: field to_id: %w", err)
		}
		m.ToID = value
	}
	return nil
}

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

// GetNameHidden returns value of NameHidden conditional field.
func (m *MessageActionStarGift) GetNameHidden() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(0)
}

// SetSaved sets value of Saved conditional field.
func (m *MessageActionStarGift) SetSaved(value bool) {
	if value {
		m.Flags.Set(2)
		m.Saved = true
	} else {
		m.Flags.Unset(2)
		m.Saved = false
	}
}

// GetSaved returns value of Saved conditional field.
func (m *MessageActionStarGift) GetSaved() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(2)
}

// SetConverted sets value of Converted conditional field.
func (m *MessageActionStarGift) SetConverted(value bool) {
	if value {
		m.Flags.Set(3)
		m.Converted = true
	} else {
		m.Flags.Unset(3)
		m.Converted = false
	}
}

// GetConverted returns value of Converted conditional field.
func (m *MessageActionStarGift) GetConverted() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(3)
}

// SetUpgraded sets value of Upgraded conditional field.
func (m *MessageActionStarGift) SetUpgraded(value bool) {
	if value {
		m.Flags.Set(5)
		m.Upgraded = true
	} else {
		m.Flags.Unset(5)
		m.Upgraded = false
	}
}

// GetUpgraded returns value of Upgraded conditional field.
func (m *MessageActionStarGift) GetUpgraded() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(5)
}

// SetRefunded sets value of Refunded conditional field.
func (m *MessageActionStarGift) SetRefunded(value bool) {
	if value {
		m.Flags.Set(9)
		m.Refunded = true
	} else {
		m.Flags.Unset(9)
		m.Refunded = false
	}
}

// GetRefunded returns value of Refunded conditional field.
func (m *MessageActionStarGift) GetRefunded() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(9)
}

// SetCanUpgrade sets value of CanUpgrade conditional field.
func (m *MessageActionStarGift) SetCanUpgrade(value bool) {
	if value {
		m.Flags.Set(10)
		m.CanUpgrade = true
	} else {
		m.Flags.Unset(10)
		m.CanUpgrade = false
	}
}

// GetCanUpgrade returns value of CanUpgrade conditional field.
func (m *MessageActionStarGift) GetCanUpgrade() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(10)
}

// SetPrepaidUpgrade sets value of PrepaidUpgrade conditional field.
func (m *MessageActionStarGift) SetPrepaidUpgrade(value bool) {
	if value {
		m.Flags.Set(13)
		m.PrepaidUpgrade = true
	} else {
		m.Flags.Unset(13)
		m.PrepaidUpgrade = false
	}
}

// GetPrepaidUpgrade returns value of PrepaidUpgrade conditional field.
func (m *MessageActionStarGift) GetPrepaidUpgrade() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(13)
}

// SetUpgradeSeparate sets value of UpgradeSeparate conditional field.
func (m *MessageActionStarGift) SetUpgradeSeparate(value bool) {
	if value {
		m.Flags.Set(16)
		m.UpgradeSeparate = true
	} else {
		m.Flags.Unset(16)
		m.UpgradeSeparate = false
	}
}

// GetUpgradeSeparate returns value of UpgradeSeparate conditional field.
func (m *MessageActionStarGift) GetUpgradeSeparate() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(16)
}

// SetAuctionAcquired sets value of AuctionAcquired conditional field.
func (m *MessageActionStarGift) SetAuctionAcquired(value bool) {
	if value {
		m.Flags.Set(17)
		m.AuctionAcquired = true
	} else {
		m.Flags.Unset(17)
		m.AuctionAcquired = false
	}
}

// GetAuctionAcquired returns value of AuctionAcquired conditional field.
func (m *MessageActionStarGift) GetAuctionAcquired() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(17)
}

// GetGift returns value of Gift field.
func (m *MessageActionStarGift) GetGift() (value StarGiftClass) {
	if m == nil {
		return
	}
	return m.Gift
}

// SetMessage sets value of Message conditional field.
func (m *MessageActionStarGift) SetMessage(value TextWithEntities) {
	m.Flags.Set(1)
	m.Message = value
}

// GetMessage returns value of Message conditional field and
// boolean which is true if field was set.
func (m *MessageActionStarGift) GetMessage() (value TextWithEntities, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(1) {
		return value, false
	}
	return m.Message, true
}

// SetConvertStars sets value of ConvertStars conditional field.
func (m *MessageActionStarGift) SetConvertStars(value int64) {
	m.Flags.Set(4)
	m.ConvertStars = value
}

// GetConvertStars returns value of ConvertStars conditional field and
// boolean which is true if field was set.
func (m *MessageActionStarGift) GetConvertStars() (value int64, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(4) {
		return value, false
	}
	return m.ConvertStars, true
}

// SetUpgradeMsgID sets value of UpgradeMsgID conditional field.
func (m *MessageActionStarGift) SetUpgradeMsgID(value int) {
	m.Flags.Set(5)
	m.UpgradeMsgID = value
}

// GetUpgradeMsgID returns value of UpgradeMsgID conditional field and
// boolean which is true if field was set.
func (m *MessageActionStarGift) GetUpgradeMsgID() (value int, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(5) {
		return value, false
	}
	return m.UpgradeMsgID, true
}

// SetUpgradeStars sets value of UpgradeStars conditional field.
func (m *MessageActionStarGift) SetUpgradeStars(value int64) {
	m.Flags.Set(8)
	m.UpgradeStars = value
}

// GetUpgradeStars returns value of UpgradeStars conditional field and
// boolean which is true if field was set.
func (m *MessageActionStarGift) GetUpgradeStars() (value int64, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(8) {
		return value, false
	}
	return m.UpgradeStars, true
}

// SetFromID sets value of FromID conditional field.
func (m *MessageActionStarGift) SetFromID(value PeerClass) {
	m.Flags.Set(11)
	m.FromID = value
}

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

// SetPeer sets value of Peer conditional field.
func (m *MessageActionStarGift) SetPeer(value PeerClass) {
	m.Flags.Set(12)
	m.Peer = value
}

// GetPeer returns value of Peer conditional field and
// boolean which is true if field was set.
func (m *MessageActionStarGift) GetPeer() (value PeerClass, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(12) {
		return value, false
	}
	return m.Peer, true
}

// SetSavedID sets value of SavedID conditional field.
func (m *MessageActionStarGift) SetSavedID(value int64) {
	m.Flags.Set(12)
	m.SavedID = value
}

// GetSavedID returns value of SavedID conditional field and
// boolean which is true if field was set.
func (m *MessageActionStarGift) GetSavedID() (value int64, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(12) {
		return value, false
	}
	return m.SavedID, true
}

// SetPrepaidUpgradeHash sets value of PrepaidUpgradeHash conditional field.
func (m *MessageActionStarGift) SetPrepaidUpgradeHash(value string) {
	m.Flags.Set(14)
	m.PrepaidUpgradeHash = value
}

// GetPrepaidUpgradeHash returns value of PrepaidUpgradeHash conditional field and
// boolean which is true if field was set.
func (m *MessageActionStarGift) GetPrepaidUpgradeHash() (value string, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(14) {
		return value, false
	}
	return m.PrepaidUpgradeHash, true
}

// SetGiftMsgID sets value of GiftMsgID conditional field.
func (m *MessageActionStarGift) SetGiftMsgID(value int) {
	m.Flags.Set(15)
	m.GiftMsgID = value
}

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

// SetToID sets value of ToID conditional field.
func (m *MessageActionStarGift) SetToID(value PeerClass) {
	m.Flags.Set(18)
	m.ToID = value
}

// GetToID returns value of ToID conditional field and
// boolean which is true if field was set.
func (m *MessageActionStarGift) GetToID() (value PeerClass, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(18) {
		return value, false
	}
	return m.ToID, true
}

// MessageActionStarGiftUnique represents TL type `messageActionStarGiftUnique#95728543`.
// A gift »¹ was upgraded to a collectible gift »².
//
// Links:
//  1. https://core.telegram.org/api/gifts
//  2. https://core.telegram.org/api/gifts#collectible-gifts
//
// See https://core.telegram.org/constructor/messageActionStarGiftUnique for reference.
type MessageActionStarGiftUnique struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, this collectible was upgraded »¹ to a collectible gift from a previously
	// received or sent (depending on the out flag of the containing messageService²)
	// non-collectible gift.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#collectible-gifts
	//  2) https://core.telegram.org/constructor/messageService
	Upgrade bool
	// If set, this collectible was transferred (either to the current user or by the current
	// user to the other user in the private chat, depending on the out flag of the
	// containing messageService¹).
	//
	// Links:
	//  1) https://core.telegram.org/constructor/messageService
	Transferred bool
	// If set, this gift is visible on the user or channel's profile page; can only be set
	// for the receiver of a gift.
	Saved bool
	// This gift was upgraded to a collectible gift »¹ and then re-downgraded to a regular
	// gift because a request to refund the payment related to the upgrade was made, and the
	// money was returned.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#collectible-gifts
	Refunded bool
	// The sender has pre-paid for the upgrade of this gift to a collectible gift.
	PrepaidUpgrade bool
	// Assigned field of MessageActionStarGiftUnique.
	Assigned bool
	// The collectible gift.
	Gift StarGiftClass
	// If set, indicates that the current gift can't be exported to the TON blockchain »¹
	// yet: the owner will be able to export it at the specified unixtime.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#withdraw-a-collectible-gift-to-the-ton-blockchain
	//
	// Use SetCanExportAt and GetCanExportAt helpers.
	CanExportAt int
	// If set, indicates that the gift can be transferred »¹ to another user by paying the
	// specified amount of stars.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#transferring-collectible-gifts
	//
	// Use SetTransferStars and GetTransferStars helpers.
	TransferStars int64
	// Sender of the gift (unset for anonymous gifts).
	//
	// Use SetFromID and GetFromID helpers.
	FromID PeerClass
	// Receiver of the gift.
	//
	// Use SetPeer and GetPeer helpers.
	Peer PeerClass
	// For channel gifts, ID to use in inputSavedStarGiftChat¹ constructors.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/inputSavedStarGiftChat
	//
	// Use SetSavedID and GetSavedID helpers.
	SavedID int64
	// Resale price of the gift.
	//
	// Use SetResaleAmount and GetResaleAmount helpers.
	ResaleAmount StarsAmountClass
	// If set, indicates that the current gift can't be transferred »¹ yet: the owner will
	// be able to transfer it at the specified unixtime.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#transferring-collectible-gifts
	//
	// Use SetCanTransferAt and GetCanTransferAt helpers.
	CanTransferAt int
	// If set, indicates that the current gift can't be resold »¹ yet: the owner will be
	// able to put it up for sale at the specified unixtime.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#reselling-collectible-gifts
	//
	// Use SetCanResellAt and GetCanResellAt helpers.
	CanResellAt int
	// DropOriginalDetailsStars field of MessageActionStarGiftUnique.
	//
	// Use SetDropOriginalDetailsStars and GetDropOriginalDetailsStars helpers.
	DropOriginalDetailsStars int64
}

// MessageActionStarGiftUniqueTypeID is TL type id of MessageActionStarGiftUnique.
const MessageActionStarGiftUniqueTypeID = 0x95728543

// construct implements constructor of MessageActionClass.
func (m MessageActionStarGiftUnique) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionStarGiftUnique{}
)

func (m *MessageActionStarGiftUnique) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.Upgrade == false) {
		return false
	}
	if !(m.Transferred == false) {
		return false
	}
	if !(m.Saved == false) {
		return false
	}
	if !(m.Refunded == false) {
		return false
	}
	if !(m.PrepaidUpgrade == false) {
		return false
	}
	if !(m.Assigned == false) {
		return false
	}
	if !(m.Gift == nil) {
		return false
	}
	if !(m.CanExportAt == 0) {
		return false
	}
	if !(m.TransferStars == 0) {
		return false
	}
	if !(m.FromID == nil) {
		return false
	}
	if !(m.Peer == nil) {
		return false
	}
	if !(m.SavedID == 0) {
		return false
	}
	if !(m.ResaleAmount == nil) {
		return false
	}
	if !(m.CanTransferAt == 0) {
		return false
	}
	if !(m.CanResellAt == 0) {
		return false
	}
	if !(m.DropOriginalDetailsStars == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionStarGiftUnique from given interface.
func (m *MessageActionStarGiftUnique) FillFrom(from interface {
	GetUpgrade() (value bool)
	GetTransferred() (value bool)
	GetSaved() (value bool)
	GetRefunded() (value bool)
	GetPrepaidUpgrade() (value bool)
	GetAssigned() (value bool)
	GetGift() (value StarGiftClass)
	GetCanExportAt() (value int, ok bool)
	GetTransferStars() (value int64, ok bool)
	GetFromID() (value PeerClass, ok bool)
	GetPeer() (value PeerClass, ok bool)
	GetSavedID() (value int64, ok bool)
	GetResaleAmount() (value StarsAmountClass, ok bool)
	GetCanTransferAt() (value int, ok bool)
	GetCanResellAt() (value int, ok bool)
	GetDropOriginalDetailsStars() (value int64, ok bool)
}) {
	m.Upgrade = from.GetUpgrade()
	m.Transferred = from.GetTransferred()
	m.Saved = from.GetSaved()
	m.Refunded = from.GetRefunded()
	m.PrepaidUpgrade = from.GetPrepaidUpgrade()
	m.Assigned = from.GetAssigned()
	m.Gift = from.GetGift()
	if val, ok := from.GetCanExportAt(); ok {
		m.CanExportAt = val
	}

	if val, ok := from.GetTransferStars(); ok {
		m.TransferStars = val
	}

	if val, ok := from.GetFromID(); ok {
		m.FromID = val
	}

	if val, ok := from.GetPeer(); ok {
		m.Peer = val
	}

	if val, ok := from.GetSavedID(); ok {
		m.SavedID = val
	}

	if val, ok := from.GetResaleAmount(); ok {
		m.ResaleAmount = val
	}

	if val, ok := from.GetCanTransferAt(); ok {
		m.CanTransferAt = val
	}

	if val, ok := from.GetCanResellAt(); ok {
		m.CanResellAt = val
	}

	if val, ok := from.GetDropOriginalDetailsStars(); ok {
		m.DropOriginalDetailsStars = val
	}

}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionStarGiftUnique) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionStarGiftUnique",
		ID:   MessageActionStarGiftUniqueTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Upgrade",
			SchemaName: "upgrade",
			Null:       !m.Flags.Has(0),
		},
		{
			Name:       "Transferred",
			SchemaName: "transferred",
			Null:       !m.Flags.Has(1),
		},
		{
			Name:       "Saved",
			SchemaName: "saved",
			Null:       !m.Flags.Has(2),
		},
		{
			Name:       "Refunded",
			SchemaName: "refunded",
			Null:       !m.Flags.Has(5),
		},
		{
			Name:       "PrepaidUpgrade",
			SchemaName: "prepaid_upgrade",
			Null:       !m.Flags.Has(11),
		},
		{
			Name:       "Assigned",
			SchemaName: "assigned",
			Null:       !m.Flags.Has(13),
		},
		{
			Name:       "Gift",
			SchemaName: "gift",
		},
		{
			Name:       "CanExportAt",
			SchemaName: "can_export_at",
			Null:       !m.Flags.Has(3),
		},
		{
			Name:       "TransferStars",
			SchemaName: "transfer_stars",
			Null:       !m.Flags.Has(4),
		},
		{
			Name:       "FromID",
			SchemaName: "from_id",
			Null:       !m.Flags.Has(6),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
			Null:       !m.Flags.Has(7),
		},
		{
			Name:       "SavedID",
			SchemaName: "saved_id",
			Null:       !m.Flags.Has(7),
		},
		{
			Name:       "ResaleAmount",
			SchemaName: "resale_amount",
			Null:       !m.Flags.Has(8),
		},
		{
			Name:       "CanTransferAt",
			SchemaName: "can_transfer_at",
			Null:       !m.Flags.Has(9),
		},
		{
			Name:       "CanResellAt",
			SchemaName: "can_resell_at",
			Null:       !m.Flags.Has(10),
		},
		{
			Name:       "DropOriginalDetailsStars",
			SchemaName: "drop_original_details_stars",
			Null:       !m.Flags.Has(12),
		},
	}
	return typ
}

// SetFlags sets flags for non-zero fields.
func (m *MessageActionStarGiftUnique) SetFlags() {
	if !(m.Upgrade == false) {
		m.Flags.Set(0)
	}
	if !(m.Transferred == false) {
		m.Flags.Set(1)
	}
	if !(m.Saved == false) {
		m.Flags.Set(2)
	}
	if !(m.Refunded == false) {
		m.Flags.Set(5)
	}
	if !(m.PrepaidUpgrade == false) {
		m.Flags.Set(11)
	}
	if !(m.Assigned == false) {
		m.Flags.Set(13)
	}
	if !(m.CanExportAt == 0) {
		m.Flags.Set(3)
	}
	if !(m.TransferStars == 0) {
		m.Flags.Set(4)
	}
	if !(m.FromID == nil) {
		m.Flags.Set(6)
	}
	if !(m.Peer == nil) {
		m.Flags.Set(7)
	}
	if !(m.SavedID == 0) {
		m.Flags.Set(7)
	}
	if !(m.ResaleAmount == nil) {
		m.Flags.Set(8)
	}
	if !(m.CanTransferAt == 0) {
		m.Flags.Set(9)
	}
	if !(m.CanResellAt == 0) {
		m.Flags.Set(10)
	}
	if !(m.DropOriginalDetailsStars == 0) {
		m.Flags.Set(12)
	}
}

// Encode implements bin.Encoder.
func (m *MessageActionStarGiftUnique) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionStarGiftUnique#95728543 as nil")
	}
	b.PutID(MessageActionStarGiftUniqueTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionStarGiftUnique) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionStarGiftUnique#95728543 as nil")
	}
	m.SetFlags()
	if err := m.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionStarGiftUnique#95728543: field flags: %w", err)
	}
	if m.Gift == nil {
		return fmt.Errorf("unable to encode messageActionStarGiftUnique#95728543: field gift is nil")
	}
	if err := m.Gift.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionStarGiftUnique#95728543: field gift: %w", err)
	}
	if m.Flags.Has(3) {
		b.PutInt(m.CanExportAt)
	}
	if m.Flags.Has(4) {
		b.PutLong(m.TransferStars)
	}
	if m.Flags.Has(6) {
		if m.FromID == nil {
			return fmt.Errorf("unable to encode messageActionStarGiftUnique#95728543: field from_id is nil")
		}
		if err := m.FromID.Encode(b); err != nil {
			return fmt.Errorf("unable to encode messageActionStarGiftUnique#95728543: field from_id: %w", err)
		}
	}
	if m.Flags.Has(7) {
		if m.Peer == nil {
			return fmt.Errorf("unable to encode messageActionStarGiftUnique#95728543: field peer is nil")
		}
		if err := m.Peer.Encode(b); err != nil {
			return fmt.Errorf("unable to encode messageActionStarGiftUnique#95728543: field peer: %w", err)
		}
	}
	if m.Flags.Has(7) {
		b.PutLong(m.SavedID)
	}
	if m.Flags.Has(8) {
		if m.ResaleAmount == nil {
			return fmt.Errorf("unable to encode messageActionStarGiftUnique#95728543: field resale_amount is nil")
		}
		if err := m.ResaleAmount.Encode(b); err != nil {
			return fmt.Errorf("unable to encode messageActionStarGiftUnique#95728543: field resale_amount: %w", err)
		}
	}
	if m.Flags.Has(9) {
		b.PutInt(m.CanTransferAt)
	}
	if m.Flags.Has(10) {
		b.PutInt(m.CanResellAt)
	}
	if m.Flags.Has(12) {
		b.PutLong(m.DropOriginalDetailsStars)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionStarGiftUnique) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionStarGiftUnique#95728543 to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionStarGiftUnique#95728543: field flags: %w", err)
		}
	}
	m.Upgrade = m.Flags.Has(0)
	m.Transferred = m.Flags.Has(1)
	m.Saved = m.Flags.Has(2)
	m.Refunded = m.Flags.Has(5)
	m.PrepaidUpgrade = m.Flags.Has(11)
	m.Assigned = m.Flags.Has(13)
	{
		value, err := DecodeStarGift(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionStarGiftUnique#95728543: field gift: %w", err)
		}
		m.Gift = value
	}
	if m.Flags.Has(3) {
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionStarGiftUnique#95728543: field can_export_at: %w", err)
		}
		m.CanExportAt = value
	}
	if m.Flags.Has(4) {
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionStarGiftUnique#95728543: field transfer_stars: %w", err)
		}
		m.TransferStars = value
	}
	if m.Flags.Has(6) {
		value, err := DecodePeer(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionStarGiftUnique#95728543: field from_id: %w", err)
		}
		m.FromID = value
	}
	if m.Flags.Has(7) {
		value, err := DecodePeer(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionStarGiftUnique#95728543: field peer: %w", err)
		}
		m.Peer = value
	}
	if m.Flags.Has(7) {
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionStarGiftUnique#95728543: field saved_id: %w", err)
		}
		m.SavedID = value
	}
	if m.Flags.Has(8) {
		value, err := DecodeStarsAmount(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionStarGiftUnique#95728543: field resale_amount: %w", err)
		}
		m.ResaleAmount = value
	}
	if m.Flags.Has(9) {
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionStarGiftUnique#95728543: field can_transfer_at: %w", err)
		}
		m.CanTransferAt = value
	}
	if m.Flags.Has(10) {
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionStarGiftUnique#95728543: field can_resell_at: %w", err)
		}
		m.CanResellAt = value
	}
	if m.Flags.Has(12) {
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionStarGiftUnique#95728543: field drop_original_details_stars: %w", err)
		}
		m.DropOriginalDetailsStars = value
	}
	return nil
}

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

// GetUpgrade returns value of Upgrade conditional field.
func (m *MessageActionStarGiftUnique) GetUpgrade() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(0)
}

// SetTransferred sets value of Transferred conditional field.
func (m *MessageActionStarGiftUnique) SetTransferred(value bool) {
	if value {
		m.Flags.Set(1)
		m.Transferred = true
	} else {
		m.Flags.Unset(1)
		m.Transferred = false
	}
}

// GetTransferred returns value of Transferred conditional field.
func (m *MessageActionStarGiftUnique) GetTransferred() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(1)
}

// SetSaved sets value of Saved conditional field.
func (m *MessageActionStarGiftUnique) SetSaved(value bool) {
	if value {
		m.Flags.Set(2)
		m.Saved = true
	} else {
		m.Flags.Unset(2)
		m.Saved = false
	}
}

// GetSaved returns value of Saved conditional field.
func (m *MessageActionStarGiftUnique) GetSaved() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(2)
}

// SetRefunded sets value of Refunded conditional field.
func (m *MessageActionStarGiftUnique) SetRefunded(value bool) {
	if value {
		m.Flags.Set(5)
		m.Refunded = true
	} else {
		m.Flags.Unset(5)
		m.Refunded = false
	}
}

// GetRefunded returns value of Refunded conditional field.
func (m *MessageActionStarGiftUnique) GetRefunded() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(5)
}

// SetPrepaidUpgrade sets value of PrepaidUpgrade conditional field.
func (m *MessageActionStarGiftUnique) SetPrepaidUpgrade(value bool) {
	if value {
		m.Flags.Set(11)
		m.PrepaidUpgrade = true
	} else {
		m.Flags.Unset(11)
		m.PrepaidUpgrade = false
	}
}

// GetPrepaidUpgrade returns value of PrepaidUpgrade conditional field.
func (m *MessageActionStarGiftUnique) GetPrepaidUpgrade() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(11)
}

// SetAssigned sets value of Assigned conditional field.
func (m *MessageActionStarGiftUnique) SetAssigned(value bool) {
	if value {
		m.Flags.Set(13)
		m.Assigned = true
	} else {
		m.Flags.Unset(13)
		m.Assigned = false
	}
}

// GetAssigned returns value of Assigned conditional field.
func (m *MessageActionStarGiftUnique) GetAssigned() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(13)
}

// GetGift returns value of Gift field.
func (m *MessageActionStarGiftUnique) GetGift() (value StarGiftClass) {
	if m == nil {
		return
	}
	return m.Gift
}

// SetCanExportAt sets value of CanExportAt conditional field.
func (m *MessageActionStarGiftUnique) SetCanExportAt(value int) {
	m.Flags.Set(3)
	m.CanExportAt = value
}

// GetCanExportAt returns value of CanExportAt conditional field and
// boolean which is true if field was set.
func (m *MessageActionStarGiftUnique) GetCanExportAt() (value int, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(3) {
		return value, false
	}
	return m.CanExportAt, true
}

// SetTransferStars sets value of TransferStars conditional field.
func (m *MessageActionStarGiftUnique) SetTransferStars(value int64) {
	m.Flags.Set(4)
	m.TransferStars = value
}

// GetTransferStars returns value of TransferStars conditional field and
// boolean which is true if field was set.
func (m *MessageActionStarGiftUnique) GetTransferStars() (value int64, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(4) {
		return value, false
	}
	return m.TransferStars, true
}

// SetFromID sets value of FromID conditional field.
func (m *MessageActionStarGiftUnique) SetFromID(value PeerClass) {
	m.Flags.Set(6)
	m.FromID = value
}

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

// SetPeer sets value of Peer conditional field.
func (m *MessageActionStarGiftUnique) SetPeer(value PeerClass) {
	m.Flags.Set(7)
	m.Peer = value
}

// GetPeer returns value of Peer conditional field and
// boolean which is true if field was set.
func (m *MessageActionStarGiftUnique) GetPeer() (value PeerClass, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(7) {
		return value, false
	}
	return m.Peer, true
}

// SetSavedID sets value of SavedID conditional field.
func (m *MessageActionStarGiftUnique) SetSavedID(value int64) {
	m.Flags.Set(7)
	m.SavedID = value
}

// GetSavedID returns value of SavedID conditional field and
// boolean which is true if field was set.
func (m *MessageActionStarGiftUnique) GetSavedID() (value int64, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(7) {
		return value, false
	}
	return m.SavedID, true
}

// SetResaleAmount sets value of ResaleAmount conditional field.
func (m *MessageActionStarGiftUnique) SetResaleAmount(value StarsAmountClass) {
	m.Flags.Set(8)
	m.ResaleAmount = value
}

// GetResaleAmount returns value of ResaleAmount conditional field and
// boolean which is true if field was set.
func (m *MessageActionStarGiftUnique) GetResaleAmount() (value StarsAmountClass, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(8) {
		return value, false
	}
	return m.ResaleAmount, true
}

// SetCanTransferAt sets value of CanTransferAt conditional field.
func (m *MessageActionStarGiftUnique) SetCanTransferAt(value int) {
	m.Flags.Set(9)
	m.CanTransferAt = value
}

// GetCanTransferAt returns value of CanTransferAt conditional field and
// boolean which is true if field was set.
func (m *MessageActionStarGiftUnique) GetCanTransferAt() (value int, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(9) {
		return value, false
	}
	return m.CanTransferAt, true
}

// SetCanResellAt sets value of CanResellAt conditional field.
func (m *MessageActionStarGiftUnique) SetCanResellAt(value int) {
	m.Flags.Set(10)
	m.CanResellAt = value
}

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

// SetDropOriginalDetailsStars sets value of DropOriginalDetailsStars conditional field.
func (m *MessageActionStarGiftUnique) SetDropOriginalDetailsStars(value int64) {
	m.Flags.Set(12)
	m.DropOriginalDetailsStars = value
}

// GetDropOriginalDetailsStars returns value of DropOriginalDetailsStars conditional field and
// boolean which is true if field was set.
func (m *MessageActionStarGiftUnique) GetDropOriginalDetailsStars() (value int64, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(12) {
		return value, false
	}
	return m.DropOriginalDetailsStars, true
}

// MessageActionPaidMessagesRefunded represents TL type `messageActionPaidMessagesRefunded#ac1f1fcd`.
// Sent from peer A to B, indicates that A refunded all stars¹ B previously paid to send
// messages to A, see here »² for more info on paid messages.
//
// Links:
//  1. https://core.telegram.org/api/stars
//  2. https://core.telegram.org/api/paid-messages
//
// See https://core.telegram.org/constructor/messageActionPaidMessagesRefunded for reference.
type MessageActionPaidMessagesRefunded struct {
	// Number of paid messages affected by the refund.
	Count int
	// Number of refunded stars.
	Stars int64
}

// MessageActionPaidMessagesRefundedTypeID is TL type id of MessageActionPaidMessagesRefunded.
const MessageActionPaidMessagesRefundedTypeID = 0xac1f1fcd

// construct implements constructor of MessageActionClass.
func (m MessageActionPaidMessagesRefunded) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionPaidMessagesRefunded{}
)

func (m *MessageActionPaidMessagesRefunded) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Count == 0) {
		return false
	}
	if !(m.Stars == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionPaidMessagesRefunded from given interface.
func (m *MessageActionPaidMessagesRefunded) FillFrom(from interface {
	GetCount() (value int)
	GetStars() (value int64)
}) {
	m.Count = from.GetCount()
	m.Stars = from.GetStars()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionPaidMessagesRefunded) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionPaidMessagesRefunded",
		ID:   MessageActionPaidMessagesRefundedTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Count",
			SchemaName: "count",
		},
		{
			Name:       "Stars",
			SchemaName: "stars",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionPaidMessagesRefunded) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionPaidMessagesRefunded#ac1f1fcd as nil")
	}
	b.PutID(MessageActionPaidMessagesRefundedTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionPaidMessagesRefunded) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionPaidMessagesRefunded#ac1f1fcd as nil")
	}
	b.PutInt(m.Count)
	b.PutLong(m.Stars)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionPaidMessagesRefunded) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionPaidMessagesRefunded#ac1f1fcd to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPaidMessagesRefunded#ac1f1fcd: field count: %w", err)
		}
		m.Count = value
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPaidMessagesRefunded#ac1f1fcd: field stars: %w", err)
		}
		m.Stars = value
	}
	return nil
}

// GetCount returns value of Count field.
func (m *MessageActionPaidMessagesRefunded) GetCount() (value int) {
	if m == nil {
		return
	}
	return m.Count
}

// GetStars returns value of Stars field.
func (m *MessageActionPaidMessagesRefunded) GetStars() (value int64) {
	if m == nil {
		return
	}
	return m.Stars
}

// MessageActionPaidMessagesPrice represents TL type `messageActionPaidMessagesPrice#84b88578`.
// The price of paid messages »¹ in this chat was changed.
//
// Links:
//  1. https://core.telegram.org/api/paid-messages
//
// See https://core.telegram.org/constructor/messageActionPaidMessagesPrice for reference.
type MessageActionPaidMessagesPrice struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Can only be set for channels, if set indicates that direct messages were enabled »¹,
	// otherwise indicates that direct messages were disabled; the price of paid messages is
	// related to the price of direct messages (aka those sent to the associated monoforum²).
	//
	// Links:
	//  1) https://core.telegram.org/api/monoforum
	//  2) https://core.telegram.org/api/monoforum
	BroadcastMessagesAllowed bool
	// The new price in Telegram Stars¹, can be 0 if messages are now free.
	//
	// Links:
	//  1) https://core.telegram.org/api/stars
	Stars int64
}

// MessageActionPaidMessagesPriceTypeID is TL type id of MessageActionPaidMessagesPrice.
const MessageActionPaidMessagesPriceTypeID = 0x84b88578

// construct implements constructor of MessageActionClass.
func (m MessageActionPaidMessagesPrice) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionPaidMessagesPrice{}
)

func (m *MessageActionPaidMessagesPrice) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.BroadcastMessagesAllowed == false) {
		return false
	}
	if !(m.Stars == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionPaidMessagesPrice from given interface.
func (m *MessageActionPaidMessagesPrice) FillFrom(from interface {
	GetBroadcastMessagesAllowed() (value bool)
	GetStars() (value int64)
}) {
	m.BroadcastMessagesAllowed = from.GetBroadcastMessagesAllowed()
	m.Stars = from.GetStars()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionPaidMessagesPrice) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionPaidMessagesPrice",
		ID:   MessageActionPaidMessagesPriceTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "BroadcastMessagesAllowed",
			SchemaName: "broadcast_messages_allowed",
			Null:       !m.Flags.Has(0),
		},
		{
			Name:       "Stars",
			SchemaName: "stars",
		},
	}
	return typ
}

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

// Encode implements bin.Encoder.
func (m *MessageActionPaidMessagesPrice) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionPaidMessagesPrice#84b88578 as nil")
	}
	b.PutID(MessageActionPaidMessagesPriceTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionPaidMessagesPrice) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionPaidMessagesPrice#84b88578 as nil")
	}
	m.SetFlags()
	if err := m.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionPaidMessagesPrice#84b88578: field flags: %w", err)
	}
	b.PutLong(m.Stars)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionPaidMessagesPrice) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionPaidMessagesPrice#84b88578 to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionPaidMessagesPrice#84b88578: field flags: %w", err)
		}
	}
	m.BroadcastMessagesAllowed = m.Flags.Has(0)
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionPaidMessagesPrice#84b88578: field stars: %w", err)
		}
		m.Stars = value
	}
	return nil
}

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

// GetBroadcastMessagesAllowed returns value of BroadcastMessagesAllowed conditional field.
func (m *MessageActionPaidMessagesPrice) GetBroadcastMessagesAllowed() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(0)
}

// GetStars returns value of Stars field.
func (m *MessageActionPaidMessagesPrice) GetStars() (value int64) {
	if m == nil {
		return
	}
	return m.Stars
}

// MessageActionConferenceCall represents TL type `messageActionConferenceCall#2ffe2f7a`.
// Represents a conference call¹ (or an invitation to a conference call, if neither the
// missed nor active flags are set).
// If call_requests_disabled¹ is not set or false, an incoming
// messageActionConferenceCall² with the missed and active flags not set should trigger
// ringing and an incoming call screen, just like for one-on-one calls.
//
// Links:
//  1. https://core.telegram.org/api/end-to-end/group-calls
//  2. https://core.telegram.org/api/config#call-requests-disabled
//  3. https://core.telegram.org/constructor/messageActionConferenceCall
//
// See https://core.telegram.org/constructor/messageActionConferenceCall for reference.
type MessageActionConferenceCall struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the conference call has ended and the user hasn't joined.
	Missed bool
	// Whether the user is currently in the conference call.
	Active bool
	// Whether this is a video conference call.
	Video bool
	// Call ID.
	CallID int64
	// Call duration, for left calls only.
	//
	// Use SetDuration and GetDuration helpers.
	Duration int
	// Identifiers of some other call participants.
	//
	// Use SetOtherParticipants and GetOtherParticipants helpers.
	OtherParticipants []PeerClass
}

// MessageActionConferenceCallTypeID is TL type id of MessageActionConferenceCall.
const MessageActionConferenceCallTypeID = 0x2ffe2f7a

// construct implements constructor of MessageActionClass.
func (m MessageActionConferenceCall) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionConferenceCall{}
)

func (m *MessageActionConferenceCall) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.Missed == false) {
		return false
	}
	if !(m.Active == false) {
		return false
	}
	if !(m.Video == false) {
		return false
	}
	if !(m.CallID == 0) {
		return false
	}
	if !(m.Duration == 0) {
		return false
	}
	if !(m.OtherParticipants == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionConferenceCall from given interface.
func (m *MessageActionConferenceCall) FillFrom(from interface {
	GetMissed() (value bool)
	GetActive() (value bool)
	GetVideo() (value bool)
	GetCallID() (value int64)
	GetDuration() (value int, ok bool)
	GetOtherParticipants() (value []PeerClass, ok bool)
}) {
	m.Missed = from.GetMissed()
	m.Active = from.GetActive()
	m.Video = from.GetVideo()
	m.CallID = from.GetCallID()
	if val, ok := from.GetDuration(); ok {
		m.Duration = val
	}

	if val, ok := from.GetOtherParticipants(); ok {
		m.OtherParticipants = val
	}

}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionConferenceCall) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionConferenceCall",
		ID:   MessageActionConferenceCallTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Missed",
			SchemaName: "missed",
			Null:       !m.Flags.Has(0),
		},
		{
			Name:       "Active",
			SchemaName: "active",
			Null:       !m.Flags.Has(1),
		},
		{
			Name:       "Video",
			SchemaName: "video",
			Null:       !m.Flags.Has(4),
		},
		{
			Name:       "CallID",
			SchemaName: "call_id",
		},
		{
			Name:       "Duration",
			SchemaName: "duration",
			Null:       !m.Flags.Has(2),
		},
		{
			Name:       "OtherParticipants",
			SchemaName: "other_participants",
			Null:       !m.Flags.Has(3),
		},
	}
	return typ
}

// SetFlags sets flags for non-zero fields.
func (m *MessageActionConferenceCall) SetFlags() {
	if !(m.Missed == false) {
		m.Flags.Set(0)
	}
	if !(m.Active == false) {
		m.Flags.Set(1)
	}
	if !(m.Video == false) {
		m.Flags.Set(4)
	}
	if !(m.Duration == 0) {
		m.Flags.Set(2)
	}
	if !(m.OtherParticipants == nil) {
		m.Flags.Set(3)
	}
}

// Encode implements bin.Encoder.
func (m *MessageActionConferenceCall) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionConferenceCall#2ffe2f7a as nil")
	}
	b.PutID(MessageActionConferenceCallTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionConferenceCall) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionConferenceCall#2ffe2f7a as nil")
	}
	m.SetFlags()
	if err := m.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionConferenceCall#2ffe2f7a: field flags: %w", err)
	}
	b.PutLong(m.CallID)
	if m.Flags.Has(2) {
		b.PutInt(m.Duration)
	}
	if m.Flags.Has(3) {
		b.PutVectorHeader(len(m.OtherParticipants))
		for idx, v := range m.OtherParticipants {
			if v == nil {
				return fmt.Errorf("unable to encode messageActionConferenceCall#2ffe2f7a: field other_participants element with index %d is nil", idx)
			}
			if err := v.Encode(b); err != nil {
				return fmt.Errorf("unable to encode messageActionConferenceCall#2ffe2f7a: field other_participants element with index %d: %w", idx, err)
			}
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionConferenceCall) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionConferenceCall#2ffe2f7a to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionConferenceCall#2ffe2f7a: field flags: %w", err)
		}
	}
	m.Missed = m.Flags.Has(0)
	m.Active = m.Flags.Has(1)
	m.Video = m.Flags.Has(4)
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionConferenceCall#2ffe2f7a: field call_id: %w", err)
		}
		m.CallID = value
	}
	if m.Flags.Has(2) {
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionConferenceCall#2ffe2f7a: field duration: %w", err)
		}
		m.Duration = value
	}
	if m.Flags.Has(3) {
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionConferenceCall#2ffe2f7a: field other_participants: %w", err)
		}

		if headerLen > 0 {
			m.OtherParticipants = make([]PeerClass, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := DecodePeer(b)
			if err != nil {
				return fmt.Errorf("unable to decode messageActionConferenceCall#2ffe2f7a: field other_participants: %w", err)
			}
			m.OtherParticipants = append(m.OtherParticipants, value)
		}
	}
	return nil
}

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

// GetMissed returns value of Missed conditional field.
func (m *MessageActionConferenceCall) GetMissed() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(0)
}

// SetActive sets value of Active conditional field.
func (m *MessageActionConferenceCall) SetActive(value bool) {
	if value {
		m.Flags.Set(1)
		m.Active = true
	} else {
		m.Flags.Unset(1)
		m.Active = false
	}
}

// GetActive returns value of Active conditional field.
func (m *MessageActionConferenceCall) GetActive() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(1)
}

// SetVideo sets value of Video conditional field.
func (m *MessageActionConferenceCall) SetVideo(value bool) {
	if value {
		m.Flags.Set(4)
		m.Video = true
	} else {
		m.Flags.Unset(4)
		m.Video = false
	}
}

// GetVideo returns value of Video conditional field.
func (m *MessageActionConferenceCall) GetVideo() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(4)
}

// GetCallID returns value of CallID field.
func (m *MessageActionConferenceCall) GetCallID() (value int64) {
	if m == nil {
		return
	}
	return m.CallID
}

// SetDuration sets value of Duration conditional field.
func (m *MessageActionConferenceCall) SetDuration(value int) {
	m.Flags.Set(2)
	m.Duration = value
}

// GetDuration returns value of Duration conditional field and
// boolean which is true if field was set.
func (m *MessageActionConferenceCall) GetDuration() (value int, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(2) {
		return value, false
	}
	return m.Duration, true
}

// SetOtherParticipants sets value of OtherParticipants conditional field.
func (m *MessageActionConferenceCall) SetOtherParticipants(value []PeerClass) {
	m.Flags.Set(3)
	m.OtherParticipants = value
}

// GetOtherParticipants returns value of OtherParticipants conditional field and
// boolean which is true if field was set.
func (m *MessageActionConferenceCall) GetOtherParticipants() (value []PeerClass, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(3) {
		return value, false
	}
	return m.OtherParticipants, true
}

// MapOtherParticipants returns field OtherParticipants wrapped in PeerClassArray helper.
func (m *MessageActionConferenceCall) MapOtherParticipants() (value PeerClassArray, ok bool) {
	if !m.Flags.Has(3) {
		return value, false
	}
	return PeerClassArray(m.OtherParticipants), true
}

// MessageActionTodoCompletions represents TL type `messageActionTodoCompletions#cc7c5c89`.
// Items were marked as completed or not completed in a todo list »¹.
//
// Links:
//  1. https://core.telegram.org/api/todo
//
// See https://core.telegram.org/constructor/messageActionTodoCompletions for reference.
type MessageActionTodoCompletions struct {
	// Items marked as completed.
	Completed []int
	// Items marked as not completed.
	Incompleted []int
}

// MessageActionTodoCompletionsTypeID is TL type id of MessageActionTodoCompletions.
const MessageActionTodoCompletionsTypeID = 0xcc7c5c89

// construct implements constructor of MessageActionClass.
func (m MessageActionTodoCompletions) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionTodoCompletions{}
)

func (m *MessageActionTodoCompletions) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Completed == nil) {
		return false
	}
	if !(m.Incompleted == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionTodoCompletions from given interface.
func (m *MessageActionTodoCompletions) FillFrom(from interface {
	GetCompleted() (value []int)
	GetIncompleted() (value []int)
}) {
	m.Completed = from.GetCompleted()
	m.Incompleted = from.GetIncompleted()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionTodoCompletions) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionTodoCompletions",
		ID:   MessageActionTodoCompletionsTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Completed",
			SchemaName: "completed",
		},
		{
			Name:       "Incompleted",
			SchemaName: "incompleted",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionTodoCompletions) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionTodoCompletions#cc7c5c89 as nil")
	}
	b.PutID(MessageActionTodoCompletionsTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionTodoCompletions) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionTodoCompletions#cc7c5c89 as nil")
	}
	b.PutVectorHeader(len(m.Completed))
	for _, v := range m.Completed {
		b.PutInt(v)
	}
	b.PutVectorHeader(len(m.Incompleted))
	for _, v := range m.Incompleted {
		b.PutInt(v)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionTodoCompletions) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionTodoCompletions#cc7c5c89 to nil")
	}
	{
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionTodoCompletions#cc7c5c89: field completed: %w", err)
		}

		if headerLen > 0 {
			m.Completed = make([]int, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := b.Int()
			if err != nil {
				return fmt.Errorf("unable to decode messageActionTodoCompletions#cc7c5c89: field completed: %w", err)
			}
			m.Completed = append(m.Completed, value)
		}
	}
	{
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionTodoCompletions#cc7c5c89: field incompleted: %w", err)
		}

		if headerLen > 0 {
			m.Incompleted = make([]int, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := b.Int()
			if err != nil {
				return fmt.Errorf("unable to decode messageActionTodoCompletions#cc7c5c89: field incompleted: %w", err)
			}
			m.Incompleted = append(m.Incompleted, value)
		}
	}
	return nil
}

// GetCompleted returns value of Completed field.
func (m *MessageActionTodoCompletions) GetCompleted() (value []int) {
	if m == nil {
		return
	}
	return m.Completed
}

// GetIncompleted returns value of Incompleted field.
func (m *MessageActionTodoCompletions) GetIncompleted() (value []int) {
	if m == nil {
		return
	}
	return m.Incompleted
}

// MessageActionTodoAppendTasks represents TL type `messageActionTodoAppendTasks#c7edbc83`.
// Items were appended to the todo list »¹.
//
// Links:
//  1. https://core.telegram.org/api/todo
//
// See https://core.telegram.org/constructor/messageActionTodoAppendTasks for reference.
type MessageActionTodoAppendTasks struct {
	// Appended items.
	List []TodoItem
}

// MessageActionTodoAppendTasksTypeID is TL type id of MessageActionTodoAppendTasks.
const MessageActionTodoAppendTasksTypeID = 0xc7edbc83

// construct implements constructor of MessageActionClass.
func (m MessageActionTodoAppendTasks) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionTodoAppendTasks{}
)

func (m *MessageActionTodoAppendTasks) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.List == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionTodoAppendTasks from given interface.
func (m *MessageActionTodoAppendTasks) FillFrom(from interface {
	GetList() (value []TodoItem)
}) {
	m.List = from.GetList()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionTodoAppendTasks) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionTodoAppendTasks",
		ID:   MessageActionTodoAppendTasksTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "List",
			SchemaName: "list",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionTodoAppendTasks) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionTodoAppendTasks#c7edbc83 as nil")
	}
	b.PutID(MessageActionTodoAppendTasksTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionTodoAppendTasks) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionTodoAppendTasks#c7edbc83 as nil")
	}
	b.PutVectorHeader(len(m.List))
	for idx, v := range m.List {
		if err := v.Encode(b); err != nil {
			return fmt.Errorf("unable to encode messageActionTodoAppendTasks#c7edbc83: field list element with index %d: %w", idx, err)
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionTodoAppendTasks) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionTodoAppendTasks#c7edbc83 to nil")
	}
	{
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionTodoAppendTasks#c7edbc83: field list: %w", err)
		}

		if headerLen > 0 {
			m.List = make([]TodoItem, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			var value TodoItem
			if err := value.Decode(b); err != nil {
				return fmt.Errorf("unable to decode messageActionTodoAppendTasks#c7edbc83: field list: %w", err)
			}
			m.List = append(m.List, value)
		}
	}
	return nil
}

// GetList returns value of List field.
func (m *MessageActionTodoAppendTasks) GetList() (value []TodoItem) {
	if m == nil {
		return
	}
	return m.List
}

// MessageActionSuggestedPostApproval represents TL type `messageActionSuggestedPostApproval#ee7a1596`.
// A suggested post »¹ was approved or rejected.
//
// Links:
//  1. https://core.telegram.org/api/suggested-posts
//
// See https://core.telegram.org/constructor/messageActionSuggestedPostApproval for reference.
type MessageActionSuggestedPostApproval struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the suggested post was rejected.
	Rejected bool
	// If set, the post was approved but the user's balance is too low to pay for the
	// suggested post.
	BalanceTooLow bool
	// If the suggested post was rejected, can optionally contain a rejection comment.
	//
	// Use SetRejectComment and GetRejectComment helpers.
	RejectComment string
	// Scheduling date.
	//
	// Use SetScheduleDate and GetScheduleDate helpers.
	ScheduleDate int
	// Price for the suggested post.
	//
	// Use SetPrice and GetPrice helpers.
	Price StarsAmountClass
}

// MessageActionSuggestedPostApprovalTypeID is TL type id of MessageActionSuggestedPostApproval.
const MessageActionSuggestedPostApprovalTypeID = 0xee7a1596

// construct implements constructor of MessageActionClass.
func (m MessageActionSuggestedPostApproval) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionSuggestedPostApproval{}
)

func (m *MessageActionSuggestedPostApproval) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.Rejected == false) {
		return false
	}
	if !(m.BalanceTooLow == false) {
		return false
	}
	if !(m.RejectComment == "") {
		return false
	}
	if !(m.ScheduleDate == 0) {
		return false
	}
	if !(m.Price == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionSuggestedPostApproval from given interface.
func (m *MessageActionSuggestedPostApproval) FillFrom(from interface {
	GetRejected() (value bool)
	GetBalanceTooLow() (value bool)
	GetRejectComment() (value string, ok bool)
	GetScheduleDate() (value int, ok bool)
	GetPrice() (value StarsAmountClass, ok bool)
}) {
	m.Rejected = from.GetRejected()
	m.BalanceTooLow = from.GetBalanceTooLow()
	if val, ok := from.GetRejectComment(); ok {
		m.RejectComment = val
	}

	if val, ok := from.GetScheduleDate(); ok {
		m.ScheduleDate = val
	}

	if val, ok := from.GetPrice(); ok {
		m.Price = val
	}

}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionSuggestedPostApproval) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionSuggestedPostApproval",
		ID:   MessageActionSuggestedPostApprovalTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Rejected",
			SchemaName: "rejected",
			Null:       !m.Flags.Has(0),
		},
		{
			Name:       "BalanceTooLow",
			SchemaName: "balance_too_low",
			Null:       !m.Flags.Has(1),
		},
		{
			Name:       "RejectComment",
			SchemaName: "reject_comment",
			Null:       !m.Flags.Has(2),
		},
		{
			Name:       "ScheduleDate",
			SchemaName: "schedule_date",
			Null:       !m.Flags.Has(3),
		},
		{
			Name:       "Price",
			SchemaName: "price",
			Null:       !m.Flags.Has(4),
		},
	}
	return typ
}

// SetFlags sets flags for non-zero fields.
func (m *MessageActionSuggestedPostApproval) SetFlags() {
	if !(m.Rejected == false) {
		m.Flags.Set(0)
	}
	if !(m.BalanceTooLow == false) {
		m.Flags.Set(1)
	}
	if !(m.RejectComment == "") {
		m.Flags.Set(2)
	}
	if !(m.ScheduleDate == 0) {
		m.Flags.Set(3)
	}
	if !(m.Price == nil) {
		m.Flags.Set(4)
	}
}

// Encode implements bin.Encoder.
func (m *MessageActionSuggestedPostApproval) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionSuggestedPostApproval#ee7a1596 as nil")
	}
	b.PutID(MessageActionSuggestedPostApprovalTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionSuggestedPostApproval) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionSuggestedPostApproval#ee7a1596 as nil")
	}
	m.SetFlags()
	if err := m.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionSuggestedPostApproval#ee7a1596: field flags: %w", err)
	}
	if m.Flags.Has(2) {
		b.PutString(m.RejectComment)
	}
	if m.Flags.Has(3) {
		b.PutInt(m.ScheduleDate)
	}
	if m.Flags.Has(4) {
		if m.Price == nil {
			return fmt.Errorf("unable to encode messageActionSuggestedPostApproval#ee7a1596: field price is nil")
		}
		if err := m.Price.Encode(b); err != nil {
			return fmt.Errorf("unable to encode messageActionSuggestedPostApproval#ee7a1596: field price: %w", err)
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionSuggestedPostApproval) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionSuggestedPostApproval#ee7a1596 to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionSuggestedPostApproval#ee7a1596: field flags: %w", err)
		}
	}
	m.Rejected = m.Flags.Has(0)
	m.BalanceTooLow = m.Flags.Has(1)
	if m.Flags.Has(2) {
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionSuggestedPostApproval#ee7a1596: field reject_comment: %w", err)
		}
		m.RejectComment = value
	}
	if m.Flags.Has(3) {
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionSuggestedPostApproval#ee7a1596: field schedule_date: %w", err)
		}
		m.ScheduleDate = value
	}
	if m.Flags.Has(4) {
		value, err := DecodeStarsAmount(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionSuggestedPostApproval#ee7a1596: field price: %w", err)
		}
		m.Price = value
	}
	return nil
}

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

// GetRejected returns value of Rejected conditional field.
func (m *MessageActionSuggestedPostApproval) GetRejected() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(0)
}

// SetBalanceTooLow sets value of BalanceTooLow conditional field.
func (m *MessageActionSuggestedPostApproval) SetBalanceTooLow(value bool) {
	if value {
		m.Flags.Set(1)
		m.BalanceTooLow = true
	} else {
		m.Flags.Unset(1)
		m.BalanceTooLow = false
	}
}

// GetBalanceTooLow returns value of BalanceTooLow conditional field.
func (m *MessageActionSuggestedPostApproval) GetBalanceTooLow() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(1)
}

// SetRejectComment sets value of RejectComment conditional field.
func (m *MessageActionSuggestedPostApproval) SetRejectComment(value string) {
	m.Flags.Set(2)
	m.RejectComment = value
}

// GetRejectComment returns value of RejectComment conditional field and
// boolean which is true if field was set.
func (m *MessageActionSuggestedPostApproval) GetRejectComment() (value string, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(2) {
		return value, false
	}
	return m.RejectComment, true
}

// SetScheduleDate sets value of ScheduleDate conditional field.
func (m *MessageActionSuggestedPostApproval) SetScheduleDate(value int) {
	m.Flags.Set(3)
	m.ScheduleDate = value
}

// GetScheduleDate returns value of ScheduleDate conditional field and
// boolean which is true if field was set.
func (m *MessageActionSuggestedPostApproval) GetScheduleDate() (value int, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(3) {
		return value, false
	}
	return m.ScheduleDate, true
}

// SetPrice sets value of Price conditional field.
func (m *MessageActionSuggestedPostApproval) SetPrice(value StarsAmountClass) {
	m.Flags.Set(4)
	m.Price = value
}

// GetPrice returns value of Price conditional field and
// boolean which is true if field was set.
func (m *MessageActionSuggestedPostApproval) GetPrice() (value StarsAmountClass, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(4) {
		return value, false
	}
	return m.Price, true
}

// MessageActionSuggestedPostSuccess represents TL type `messageActionSuggestedPostSuccess#95ddcf69`.
// A suggested post »¹ was successfully posted, and payment for it was successfully
// received.
//
// Links:
//  1. https://core.telegram.org/api/suggested-posts
//
// See https://core.telegram.org/constructor/messageActionSuggestedPostSuccess for reference.
type MessageActionSuggestedPostSuccess struct {
	// The price.
	Price StarsAmountClass
}

// MessageActionSuggestedPostSuccessTypeID is TL type id of MessageActionSuggestedPostSuccess.
const MessageActionSuggestedPostSuccessTypeID = 0x95ddcf69

// construct implements constructor of MessageActionClass.
func (m MessageActionSuggestedPostSuccess) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionSuggestedPostSuccess{}
)

func (m *MessageActionSuggestedPostSuccess) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Price == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionSuggestedPostSuccess from given interface.
func (m *MessageActionSuggestedPostSuccess) FillFrom(from interface {
	GetPrice() (value StarsAmountClass)
}) {
	m.Price = from.GetPrice()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionSuggestedPostSuccess) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionSuggestedPostSuccess",
		ID:   MessageActionSuggestedPostSuccessTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Price",
			SchemaName: "price",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionSuggestedPostSuccess) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionSuggestedPostSuccess#95ddcf69 as nil")
	}
	b.PutID(MessageActionSuggestedPostSuccessTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionSuggestedPostSuccess) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionSuggestedPostSuccess#95ddcf69 as nil")
	}
	if m.Price == nil {
		return fmt.Errorf("unable to encode messageActionSuggestedPostSuccess#95ddcf69: field price is nil")
	}
	if err := m.Price.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionSuggestedPostSuccess#95ddcf69: field price: %w", err)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionSuggestedPostSuccess) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionSuggestedPostSuccess#95ddcf69 to nil")
	}
	{
		value, err := DecodeStarsAmount(b)
		if err != nil {
			return fmt.Errorf("unable to decode messageActionSuggestedPostSuccess#95ddcf69: field price: %w", err)
		}
		m.Price = value
	}
	return nil
}

// GetPrice returns value of Price field.
func (m *MessageActionSuggestedPostSuccess) GetPrice() (value StarsAmountClass) {
	if m == nil {
		return
	}
	return m.Price
}

// MessageActionSuggestedPostRefund represents TL type `messageActionSuggestedPostRefund#69f916f8`.
// A suggested post »¹ was accepted and posted or scheduled, but either the channel
// deleted the posted/scheduled post before stars_suggested_post_age_min² seconds have
// elapsed, or the user refunded the payment for the stars used to pay for the suggested
// post.
//
// Links:
//  1. https://core.telegram.org/api/suggested-posts
//  2. https://core.telegram.org/api/config#stars-suggested-post-age-min
//
// See https://core.telegram.org/constructor/messageActionSuggestedPostRefund for reference.
type MessageActionSuggestedPostRefund struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, the user refunded the payment for the stars used to pay for the suggested post.
	PayerInitiated bool
}

// MessageActionSuggestedPostRefundTypeID is TL type id of MessageActionSuggestedPostRefund.
const MessageActionSuggestedPostRefundTypeID = 0x69f916f8

// construct implements constructor of MessageActionClass.
func (m MessageActionSuggestedPostRefund) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionSuggestedPostRefund{}
)

func (m *MessageActionSuggestedPostRefund) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.PayerInitiated == false) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionSuggestedPostRefund from given interface.
func (m *MessageActionSuggestedPostRefund) FillFrom(from interface {
	GetPayerInitiated() (value bool)
}) {
	m.PayerInitiated = from.GetPayerInitiated()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionSuggestedPostRefund) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionSuggestedPostRefund",
		ID:   MessageActionSuggestedPostRefundTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "PayerInitiated",
			SchemaName: "payer_initiated",
			Null:       !m.Flags.Has(0),
		},
	}
	return typ
}

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

// Encode implements bin.Encoder.
func (m *MessageActionSuggestedPostRefund) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionSuggestedPostRefund#69f916f8 as nil")
	}
	b.PutID(MessageActionSuggestedPostRefundTypeID)
	return m.EncodeBare(b)
}

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

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionSuggestedPostRefund) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionSuggestedPostRefund#69f916f8 to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionSuggestedPostRefund#69f916f8: field flags: %w", err)
		}
	}
	m.PayerInitiated = m.Flags.Has(0)
	return nil
}

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

// GetPayerInitiated returns value of PayerInitiated conditional field.
func (m *MessageActionSuggestedPostRefund) GetPayerInitiated() (value bool) {
	if m == nil {
		return
	}
	return m.Flags.Has(0)
}

// MessageActionGiftTon represents TL type `messageActionGiftTon#a8a3c699`.
// You were gifted some toncoins.
// This service message should be displayed below the appropriate sticker from the
// inputStickerSetTonGifts »¹ stickerset »²:
//
// Links:
//  1. https://core.telegram.org/constructor/inputStickerSetTonGifts
//  2. https://core.telegram.org/api/stickers#stickersets
//
// See https://core.telegram.org/constructor/messageActionGiftTon for reference.
type MessageActionGiftTon struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Name of a localized FIAT currency.
	Currency string
	// FIAT currency equivalent (in the currency specified in currency) of the amount
	// specified in crypto_amount.
	Amount int64
	// Name of the cryptocurrency.
	CryptoCurrency string
	// Amount in the smallest unit of the cryptocurrency (for TONs, one billionth of a ton,
	// AKA a nanoton).
	CryptoAmount int64
	// Transaction ID.
	//
	// Use SetTransactionID and GetTransactionID helpers.
	TransactionID string
}

// MessageActionGiftTonTypeID is TL type id of MessageActionGiftTon.
const MessageActionGiftTonTypeID = 0xa8a3c699

// construct implements constructor of MessageActionClass.
func (m MessageActionGiftTon) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionGiftTon{}
)

func (m *MessageActionGiftTon) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Flags.Zero()) {
		return false
	}
	if !(m.Currency == "") {
		return false
	}
	if !(m.Amount == 0) {
		return false
	}
	if !(m.CryptoCurrency == "") {
		return false
	}
	if !(m.CryptoAmount == 0) {
		return false
	}
	if !(m.TransactionID == "") {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionGiftTon from given interface.
func (m *MessageActionGiftTon) FillFrom(from interface {
	GetCurrency() (value string)
	GetAmount() (value int64)
	GetCryptoCurrency() (value string)
	GetCryptoAmount() (value int64)
	GetTransactionID() (value string, ok bool)
}) {
	m.Currency = from.GetCurrency()
	m.Amount = from.GetAmount()
	m.CryptoCurrency = from.GetCryptoCurrency()
	m.CryptoAmount = from.GetCryptoAmount()
	if val, ok := from.GetTransactionID(); ok {
		m.TransactionID = val
	}

}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionGiftTon) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionGiftTon",
		ID:   MessageActionGiftTonTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Currency",
			SchemaName: "currency",
		},
		{
			Name:       "Amount",
			SchemaName: "amount",
		},
		{
			Name:       "CryptoCurrency",
			SchemaName: "crypto_currency",
		},
		{
			Name:       "CryptoAmount",
			SchemaName: "crypto_amount",
		},
		{
			Name:       "TransactionID",
			SchemaName: "transaction_id",
			Null:       !m.Flags.Has(0),
		},
	}
	return typ
}

// SetFlags sets flags for non-zero fields.
func (m *MessageActionGiftTon) SetFlags() {
	if !(m.TransactionID == "") {
		m.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func (m *MessageActionGiftTon) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionGiftTon#a8a3c699 as nil")
	}
	b.PutID(MessageActionGiftTonTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionGiftTon) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionGiftTon#a8a3c699 as nil")
	}
	m.SetFlags()
	if err := m.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionGiftTon#a8a3c699: field flags: %w", err)
	}
	b.PutString(m.Currency)
	b.PutLong(m.Amount)
	b.PutString(m.CryptoCurrency)
	b.PutLong(m.CryptoAmount)
	if m.Flags.Has(0) {
		b.PutString(m.TransactionID)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionGiftTon) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionGiftTon#a8a3c699 to nil")
	}
	{
		if err := m.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionGiftTon#a8a3c699: field flags: %w", err)
		}
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftTon#a8a3c699: field currency: %w", err)
		}
		m.Currency = value
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftTon#a8a3c699: field amount: %w", err)
		}
		m.Amount = value
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftTon#a8a3c699: field crypto_currency: %w", err)
		}
		m.CryptoCurrency = value
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftTon#a8a3c699: field crypto_amount: %w", err)
		}
		m.CryptoAmount = value
	}
	if m.Flags.Has(0) {
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode messageActionGiftTon#a8a3c699: field transaction_id: %w", err)
		}
		m.TransactionID = value
	}
	return nil
}

// GetCurrency returns value of Currency field.
func (m *MessageActionGiftTon) GetCurrency() (value string) {
	if m == nil {
		return
	}
	return m.Currency
}

// GetAmount returns value of Amount field.
func (m *MessageActionGiftTon) GetAmount() (value int64) {
	if m == nil {
		return
	}
	return m.Amount
}

// GetCryptoCurrency returns value of CryptoCurrency field.
func (m *MessageActionGiftTon) GetCryptoCurrency() (value string) {
	if m == nil {
		return
	}
	return m.CryptoCurrency
}

// GetCryptoAmount returns value of CryptoAmount field.
func (m *MessageActionGiftTon) GetCryptoAmount() (value int64) {
	if m == nil {
		return
	}
	return m.CryptoAmount
}

// SetTransactionID sets value of TransactionID conditional field.
func (m *MessageActionGiftTon) SetTransactionID(value string) {
	m.Flags.Set(0)
	m.TransactionID = value
}

// GetTransactionID returns value of TransactionID conditional field and
// boolean which is true if field was set.
func (m *MessageActionGiftTon) GetTransactionID() (value string, ok bool) {
	if m == nil {
		return
	}
	if !m.Flags.Has(0) {
		return value, false
	}
	return m.TransactionID, true
}

// MessageActionSuggestBirthday represents TL type `messageActionSuggestBirthday#2c8f2a25`.
//
// See https://core.telegram.org/constructor/messageActionSuggestBirthday for reference.
type MessageActionSuggestBirthday struct {
	// Birthday field of MessageActionSuggestBirthday.
	Birthday Birthday
}

// MessageActionSuggestBirthdayTypeID is TL type id of MessageActionSuggestBirthday.
const MessageActionSuggestBirthdayTypeID = 0x2c8f2a25

// construct implements constructor of MessageActionClass.
func (m MessageActionSuggestBirthday) construct() MessageActionClass { return &m }

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

	_ MessageActionClass = &MessageActionSuggestBirthday{}
)

func (m *MessageActionSuggestBirthday) Zero() bool {
	if m == nil {
		return true
	}
	if !(m.Birthday.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills MessageActionSuggestBirthday from given interface.
func (m *MessageActionSuggestBirthday) FillFrom(from interface {
	GetBirthday() (value Birthday)
}) {
	m.Birthday = from.GetBirthday()
}

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

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

// TypeInfo returns info about TL type.
func (m *MessageActionSuggestBirthday) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "messageActionSuggestBirthday",
		ID:   MessageActionSuggestBirthdayTypeID,
	}
	if m == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Birthday",
			SchemaName: "birthday",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (m *MessageActionSuggestBirthday) Encode(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionSuggestBirthday#2c8f2a25 as nil")
	}
	b.PutID(MessageActionSuggestBirthdayTypeID)
	return m.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (m *MessageActionSuggestBirthday) EncodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't encode messageActionSuggestBirthday#2c8f2a25 as nil")
	}
	if err := m.Birthday.Encode(b); err != nil {
		return fmt.Errorf("unable to encode messageActionSuggestBirthday#2c8f2a25: field birthday: %w", err)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (m *MessageActionSuggestBirthday) DecodeBare(b *bin.Buffer) error {
	if m == nil {
		return fmt.Errorf("can't decode messageActionSuggestBirthday#2c8f2a25 to nil")
	}
	{
		if err := m.Birthday.Decode(b); err != nil {
			return fmt.Errorf("unable to decode messageActionSuggestBirthday#2c8f2a25: field birthday: %w", err)
		}
	}
	return nil
}

// GetBirthday returns value of Birthday field.
func (m *MessageActionSuggestBirthday) GetBirthday() (value Birthday) {
	if m == nil {
		return
	}
	return m.Birthday
}

// MessageActionClassName is schema name of MessageActionClass.
const MessageActionClassName = "MessageAction"

// MessageActionClass represents MessageAction generic type.
//
// See https://core.telegram.org/type/MessageAction for reference.
//
// Example:
//
//	g, err := tg.DecodeMessageAction(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.MessageActionEmpty: // messageActionEmpty#b6aef7b0
//	case *tg.MessageActionChatCreate: // messageActionChatCreate#bd47cbad
//	case *tg.MessageActionChatEditTitle: // messageActionChatEditTitle#b5a1ce5a
//	case *tg.MessageActionChatEditPhoto: // messageActionChatEditPhoto#7fcb13a8
//	case *tg.MessageActionChatDeletePhoto: // messageActionChatDeletePhoto#95e3fbef
//	case *tg.MessageActionChatAddUser: // messageActionChatAddUser#15cefd00
//	case *tg.MessageActionChatDeleteUser: // messageActionChatDeleteUser#a43f30cc
//	case *tg.MessageActionChatJoinedByLink: // messageActionChatJoinedByLink#31224c3
//	case *tg.MessageActionChannelCreate: // messageActionChannelCreate#95d2ac92
//	case *tg.MessageActionChatMigrateTo: // messageActionChatMigrateTo#e1037f92
//	case *tg.MessageActionChannelMigrateFrom: // messageActionChannelMigrateFrom#ea3948e9
//	case *tg.MessageActionPinMessage: // messageActionPinMessage#94bd38ed
//	case *tg.MessageActionHistoryClear: // messageActionHistoryClear#9fbab604
//	case *tg.MessageActionGameScore: // messageActionGameScore#92a72876
//	case *tg.MessageActionPaymentSentMe: // messageActionPaymentSentMe#ffa00ccc
//	case *tg.MessageActionPaymentSent: // messageActionPaymentSent#c624b16e
//	case *tg.MessageActionPhoneCall: // messageActionPhoneCall#80e11a7f
//	case *tg.MessageActionScreenshotTaken: // messageActionScreenshotTaken#4792929b
//	case *tg.MessageActionCustomAction: // messageActionCustomAction#fae69f56
//	case *tg.MessageActionBotAllowed: // messageActionBotAllowed#c516d679
//	case *tg.MessageActionSecureValuesSentMe: // messageActionSecureValuesSentMe#1b287353
//	case *tg.MessageActionSecureValuesSent: // messageActionSecureValuesSent#d95c6154
//	case *tg.MessageActionContactSignUp: // messageActionContactSignUp#f3f25f76
//	case *tg.MessageActionGeoProximityReached: // messageActionGeoProximityReached#98e0d697
//	case *tg.MessageActionGroupCall: // messageActionGroupCall#7a0d7f42
//	case *tg.MessageActionInviteToGroupCall: // messageActionInviteToGroupCall#502f92f7
//	case *tg.MessageActionSetMessagesTTL: // messageActionSetMessagesTTL#3c134d7b
//	case *tg.MessageActionGroupCallScheduled: // messageActionGroupCallScheduled#b3a07661
//	case *tg.MessageActionSetChatTheme: // messageActionSetChatTheme#b91bbd3a
//	case *tg.MessageActionChatJoinedByRequest: // messageActionChatJoinedByRequest#ebbca3cb
//	case *tg.MessageActionWebViewDataSentMe: // messageActionWebViewDataSentMe#47dd8079
//	case *tg.MessageActionWebViewDataSent: // messageActionWebViewDataSent#b4c38cb5
//	case *tg.MessageActionGiftPremium: // messageActionGiftPremium#48e91302
//	case *tg.MessageActionTopicCreate: // messageActionTopicCreate#d999256
//	case *tg.MessageActionTopicEdit: // messageActionTopicEdit#c0944820
//	case *tg.MessageActionSuggestProfilePhoto: // messageActionSuggestProfilePhoto#57de635e
//	case *tg.MessageActionRequestedPeer: // messageActionRequestedPeer#31518e9b
//	case *tg.MessageActionSetChatWallPaper: // messageActionSetChatWallPaper#5060a3f4
//	case *tg.MessageActionGiftCode: // messageActionGiftCode#31c48347
//	case *tg.MessageActionGiveawayLaunch: // messageActionGiveawayLaunch#a80f51e4
//	case *tg.MessageActionGiveawayResults: // messageActionGiveawayResults#87e2f155
//	case *tg.MessageActionBoostApply: // messageActionBoostApply#cc02aa6d
//	case *tg.MessageActionRequestedPeerSentMe: // messageActionRequestedPeerSentMe#93b31848
//	case *tg.MessageActionPaymentRefunded: // messageActionPaymentRefunded#41b3e202
//	case *tg.MessageActionGiftStars: // messageActionGiftStars#45d5b021
//	case *tg.MessageActionPrizeStars: // messageActionPrizeStars#b00c47a2
//	case *tg.MessageActionStarGift: // messageActionStarGift#db596550
//	case *tg.MessageActionStarGiftUnique: // messageActionStarGiftUnique#95728543
//	case *tg.MessageActionPaidMessagesRefunded: // messageActionPaidMessagesRefunded#ac1f1fcd
//	case *tg.MessageActionPaidMessagesPrice: // messageActionPaidMessagesPrice#84b88578
//	case *tg.MessageActionConferenceCall: // messageActionConferenceCall#2ffe2f7a
//	case *tg.MessageActionTodoCompletions: // messageActionTodoCompletions#cc7c5c89
//	case *tg.MessageActionTodoAppendTasks: // messageActionTodoAppendTasks#c7edbc83
//	case *tg.MessageActionSuggestedPostApproval: // messageActionSuggestedPostApproval#ee7a1596
//	case *tg.MessageActionSuggestedPostSuccess: // messageActionSuggestedPostSuccess#95ddcf69
//	case *tg.MessageActionSuggestedPostRefund: // messageActionSuggestedPostRefund#69f916f8
//	case *tg.MessageActionGiftTon: // messageActionGiftTon#a8a3c699
//	case *tg.MessageActionSuggestBirthday: // messageActionSuggestBirthday#2c8f2a25
//	default: panic(v)
//	}
type MessageActionClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() MessageActionClass

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

// DecodeMessageAction implements binary de-serialization for MessageActionClass.
func DecodeMessageAction(buf *bin.Buffer) (MessageActionClass, error) {
	id, err := buf.PeekID()
	if err != nil {
		return nil, err
	}
	switch id {
	case MessageActionEmptyTypeID:
		// Decoding messageActionEmpty#b6aef7b0.
		v := MessageActionEmpty{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionChatCreateTypeID:
		// Decoding messageActionChatCreate#bd47cbad.
		v := MessageActionChatCreate{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionChatEditTitleTypeID:
		// Decoding messageActionChatEditTitle#b5a1ce5a.
		v := MessageActionChatEditTitle{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionChatEditPhotoTypeID:
		// Decoding messageActionChatEditPhoto#7fcb13a8.
		v := MessageActionChatEditPhoto{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionChatDeletePhotoTypeID:
		// Decoding messageActionChatDeletePhoto#95e3fbef.
		v := MessageActionChatDeletePhoto{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionChatAddUserTypeID:
		// Decoding messageActionChatAddUser#15cefd00.
		v := MessageActionChatAddUser{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionChatDeleteUserTypeID:
		// Decoding messageActionChatDeleteUser#a43f30cc.
		v := MessageActionChatDeleteUser{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionChatJoinedByLinkTypeID:
		// Decoding messageActionChatJoinedByLink#31224c3.
		v := MessageActionChatJoinedByLink{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionChannelCreateTypeID:
		// Decoding messageActionChannelCreate#95d2ac92.
		v := MessageActionChannelCreate{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionChatMigrateToTypeID:
		// Decoding messageActionChatMigrateTo#e1037f92.
		v := MessageActionChatMigrateTo{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionChannelMigrateFromTypeID:
		// Decoding messageActionChannelMigrateFrom#ea3948e9.
		v := MessageActionChannelMigrateFrom{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionPinMessageTypeID:
		// Decoding messageActionPinMessage#94bd38ed.
		v := MessageActionPinMessage{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionHistoryClearTypeID:
		// Decoding messageActionHistoryClear#9fbab604.
		v := MessageActionHistoryClear{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionGameScoreTypeID:
		// Decoding messageActionGameScore#92a72876.
		v := MessageActionGameScore{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionPaymentSentMeTypeID:
		// Decoding messageActionPaymentSentMe#ffa00ccc.
		v := MessageActionPaymentSentMe{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionPaymentSentTypeID:
		// Decoding messageActionPaymentSent#c624b16e.
		v := MessageActionPaymentSent{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionPhoneCallTypeID:
		// Decoding messageActionPhoneCall#80e11a7f.
		v := MessageActionPhoneCall{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionScreenshotTakenTypeID:
		// Decoding messageActionScreenshotTaken#4792929b.
		v := MessageActionScreenshotTaken{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionCustomActionTypeID:
		// Decoding messageActionCustomAction#fae69f56.
		v := MessageActionCustomAction{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionBotAllowedTypeID:
		// Decoding messageActionBotAllowed#c516d679.
		v := MessageActionBotAllowed{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionSecureValuesSentMeTypeID:
		// Decoding messageActionSecureValuesSentMe#1b287353.
		v := MessageActionSecureValuesSentMe{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionSecureValuesSentTypeID:
		// Decoding messageActionSecureValuesSent#d95c6154.
		v := MessageActionSecureValuesSent{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionContactSignUpTypeID:
		// Decoding messageActionContactSignUp#f3f25f76.
		v := MessageActionContactSignUp{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionGeoProximityReachedTypeID:
		// Decoding messageActionGeoProximityReached#98e0d697.
		v := MessageActionGeoProximityReached{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionGroupCallTypeID:
		// Decoding messageActionGroupCall#7a0d7f42.
		v := MessageActionGroupCall{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionInviteToGroupCallTypeID:
		// Decoding messageActionInviteToGroupCall#502f92f7.
		v := MessageActionInviteToGroupCall{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionSetMessagesTTLTypeID:
		// Decoding messageActionSetMessagesTTL#3c134d7b.
		v := MessageActionSetMessagesTTL{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionGroupCallScheduledTypeID:
		// Decoding messageActionGroupCallScheduled#b3a07661.
		v := MessageActionGroupCallScheduled{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionSetChatThemeTypeID:
		// Decoding messageActionSetChatTheme#b91bbd3a.
		v := MessageActionSetChatTheme{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionChatJoinedByRequestTypeID:
		// Decoding messageActionChatJoinedByRequest#ebbca3cb.
		v := MessageActionChatJoinedByRequest{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionWebViewDataSentMeTypeID:
		// Decoding messageActionWebViewDataSentMe#47dd8079.
		v := MessageActionWebViewDataSentMe{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionWebViewDataSentTypeID:
		// Decoding messageActionWebViewDataSent#b4c38cb5.
		v := MessageActionWebViewDataSent{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionGiftPremiumTypeID:
		// Decoding messageActionGiftPremium#48e91302.
		v := MessageActionGiftPremium{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionTopicCreateTypeID:
		// Decoding messageActionTopicCreate#d999256.
		v := MessageActionTopicCreate{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionTopicEditTypeID:
		// Decoding messageActionTopicEdit#c0944820.
		v := MessageActionTopicEdit{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionSuggestProfilePhotoTypeID:
		// Decoding messageActionSuggestProfilePhoto#57de635e.
		v := MessageActionSuggestProfilePhoto{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionRequestedPeerTypeID:
		// Decoding messageActionRequestedPeer#31518e9b.
		v := MessageActionRequestedPeer{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionSetChatWallPaperTypeID:
		// Decoding messageActionSetChatWallPaper#5060a3f4.
		v := MessageActionSetChatWallPaper{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionGiftCodeTypeID:
		// Decoding messageActionGiftCode#31c48347.
		v := MessageActionGiftCode{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionGiveawayLaunchTypeID:
		// Decoding messageActionGiveawayLaunch#a80f51e4.
		v := MessageActionGiveawayLaunch{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionGiveawayResultsTypeID:
		// Decoding messageActionGiveawayResults#87e2f155.
		v := MessageActionGiveawayResults{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionBoostApplyTypeID:
		// Decoding messageActionBoostApply#cc02aa6d.
		v := MessageActionBoostApply{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionRequestedPeerSentMeTypeID:
		// Decoding messageActionRequestedPeerSentMe#93b31848.
		v := MessageActionRequestedPeerSentMe{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionPaymentRefundedTypeID:
		// Decoding messageActionPaymentRefunded#41b3e202.
		v := MessageActionPaymentRefunded{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionGiftStarsTypeID:
		// Decoding messageActionGiftStars#45d5b021.
		v := MessageActionGiftStars{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionPrizeStarsTypeID:
		// Decoding messageActionPrizeStars#b00c47a2.
		v := MessageActionPrizeStars{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionStarGiftTypeID:
		// Decoding messageActionStarGift#db596550.
		v := MessageActionStarGift{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionStarGiftUniqueTypeID:
		// Decoding messageActionStarGiftUnique#95728543.
		v := MessageActionStarGiftUnique{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionPaidMessagesRefundedTypeID:
		// Decoding messageActionPaidMessagesRefunded#ac1f1fcd.
		v := MessageActionPaidMessagesRefunded{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionPaidMessagesPriceTypeID:
		// Decoding messageActionPaidMessagesPrice#84b88578.
		v := MessageActionPaidMessagesPrice{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionConferenceCallTypeID:
		// Decoding messageActionConferenceCall#2ffe2f7a.
		v := MessageActionConferenceCall{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionTodoCompletionsTypeID:
		// Decoding messageActionTodoCompletions#cc7c5c89.
		v := MessageActionTodoCompletions{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionTodoAppendTasksTypeID:
		// Decoding messageActionTodoAppendTasks#c7edbc83.
		v := MessageActionTodoAppendTasks{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionSuggestedPostApprovalTypeID:
		// Decoding messageActionSuggestedPostApproval#ee7a1596.
		v := MessageActionSuggestedPostApproval{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionSuggestedPostSuccessTypeID:
		// Decoding messageActionSuggestedPostSuccess#95ddcf69.
		v := MessageActionSuggestedPostSuccess{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionSuggestedPostRefundTypeID:
		// Decoding messageActionSuggestedPostRefund#69f916f8.
		v := MessageActionSuggestedPostRefund{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionGiftTonTypeID:
		// Decoding messageActionGiftTon#a8a3c699.
		v := MessageActionGiftTon{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	case MessageActionSuggestBirthdayTypeID:
		// Decoding messageActionSuggestBirthday#2c8f2a25.
		v := MessageActionSuggestBirthday{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode MessageActionClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode MessageActionClass: %w", bin.NewUnexpectedID(id))
	}
}

// MessageAction boxes the MessageActionClass providing a helper.
type MessageActionBox struct {
	MessageAction MessageActionClass
}

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

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