// Code generated by gotdgen, DO NOT EDIT.

package tdapi

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

// ChatActionTyping represents TL type `chatActionTyping#16a83437`.
type ChatActionTyping struct {
}

// ChatActionTypingTypeID is TL type id of ChatActionTyping.
const ChatActionTypingTypeID = 0x16a83437

// construct implements constructor of ChatActionClass.
func (c ChatActionTyping) construct() ChatActionClass { return &c }

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

	_ ChatActionClass = &ChatActionTyping{}
)

func (c *ChatActionTyping) Zero() bool {
	if c == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (c *ChatActionTyping) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionTyping#16a83437 as nil")
	}
	b.PutID(ChatActionTypingTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *ChatActionTyping) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionTyping#16a83437 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (c *ChatActionTyping) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionTyping#16a83437 to nil")
	}
	if err := b.ConsumeID(ChatActionTypingTypeID); err != nil {
		return fmt.Errorf("unable to decode chatActionTyping#16a83437: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *ChatActionTyping) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionTyping#16a83437 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *ChatActionTyping) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionTyping#16a83437 as nil")
	}
	b.ObjStart()
	b.PutID("chatActionTyping")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *ChatActionTyping) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionTyping#16a83437 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("chatActionTyping"); err != nil {
				return fmt.Errorf("unable to decode chatActionTyping#16a83437: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// ChatActionRecordingVideo represents TL type `chatActionRecordingVideo#ce85792`.
type ChatActionRecordingVideo struct {
}

// ChatActionRecordingVideoTypeID is TL type id of ChatActionRecordingVideo.
const ChatActionRecordingVideoTypeID = 0xce85792

// construct implements constructor of ChatActionClass.
func (c ChatActionRecordingVideo) construct() ChatActionClass { return &c }

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

	_ ChatActionClass = &ChatActionRecordingVideo{}
)

func (c *ChatActionRecordingVideo) Zero() bool {
	if c == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (c *ChatActionRecordingVideo) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionRecordingVideo#ce85792 as nil")
	}
	b.PutID(ChatActionRecordingVideoTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *ChatActionRecordingVideo) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionRecordingVideo#ce85792 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (c *ChatActionRecordingVideo) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionRecordingVideo#ce85792 to nil")
	}
	if err := b.ConsumeID(ChatActionRecordingVideoTypeID); err != nil {
		return fmt.Errorf("unable to decode chatActionRecordingVideo#ce85792: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *ChatActionRecordingVideo) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionRecordingVideo#ce85792 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *ChatActionRecordingVideo) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionRecordingVideo#ce85792 as nil")
	}
	b.ObjStart()
	b.PutID("chatActionRecordingVideo")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *ChatActionRecordingVideo) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionRecordingVideo#ce85792 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("chatActionRecordingVideo"); err != nil {
				return fmt.Errorf("unable to decode chatActionRecordingVideo#ce85792: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// ChatActionUploadingVideo represents TL type `chatActionUploadingVideo#49902c36`.
type ChatActionUploadingVideo struct {
	// Upload progress, as a percentage
	Progress int32
}

// ChatActionUploadingVideoTypeID is TL type id of ChatActionUploadingVideo.
const ChatActionUploadingVideoTypeID = 0x49902c36

// construct implements constructor of ChatActionClass.
func (c ChatActionUploadingVideo) construct() ChatActionClass { return &c }

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

	_ ChatActionClass = &ChatActionUploadingVideo{}
)

func (c *ChatActionUploadingVideo) Zero() bool {
	if c == nil {
		return true
	}
	if !(c.Progress == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (c *ChatActionUploadingVideo) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "chatActionUploadingVideo",
		ID:   ChatActionUploadingVideoTypeID,
	}
	if c == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Progress",
			SchemaName: "progress",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (c *ChatActionUploadingVideo) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionUploadingVideo#49902c36 as nil")
	}
	b.PutID(ChatActionUploadingVideoTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *ChatActionUploadingVideo) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionUploadingVideo#49902c36 as nil")
	}
	b.PutInt32(c.Progress)
	return nil
}

// Decode implements bin.Decoder.
func (c *ChatActionUploadingVideo) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionUploadingVideo#49902c36 to nil")
	}
	if err := b.ConsumeID(ChatActionUploadingVideoTypeID); err != nil {
		return fmt.Errorf("unable to decode chatActionUploadingVideo#49902c36: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *ChatActionUploadingVideo) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionUploadingVideo#49902c36 to nil")
	}
	{
		value, err := b.Int32()
		if err != nil {
			return fmt.Errorf("unable to decode chatActionUploadingVideo#49902c36: field progress: %w", err)
		}
		c.Progress = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *ChatActionUploadingVideo) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionUploadingVideo#49902c36 as nil")
	}
	b.ObjStart()
	b.PutID("chatActionUploadingVideo")
	b.Comma()
	b.FieldStart("progress")
	b.PutInt32(c.Progress)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *ChatActionUploadingVideo) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionUploadingVideo#49902c36 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("chatActionUploadingVideo"); err != nil {
				return fmt.Errorf("unable to decode chatActionUploadingVideo#49902c36: %w", err)
			}
		case "progress":
			value, err := b.Int32()
			if err != nil {
				return fmt.Errorf("unable to decode chatActionUploadingVideo#49902c36: field progress: %w", err)
			}
			c.Progress = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetProgress returns value of Progress field.
func (c *ChatActionUploadingVideo) GetProgress() (value int32) {
	if c == nil {
		return
	}
	return c.Progress
}

// ChatActionRecordingVoiceNote represents TL type `chatActionRecordingVoiceNote#cfc9ed76`.
type ChatActionRecordingVoiceNote struct {
}

// ChatActionRecordingVoiceNoteTypeID is TL type id of ChatActionRecordingVoiceNote.
const ChatActionRecordingVoiceNoteTypeID = 0xcfc9ed76

// construct implements constructor of ChatActionClass.
func (c ChatActionRecordingVoiceNote) construct() ChatActionClass { return &c }

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

	_ ChatActionClass = &ChatActionRecordingVoiceNote{}
)

func (c *ChatActionRecordingVoiceNote) Zero() bool {
	if c == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (c *ChatActionRecordingVoiceNote) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionRecordingVoiceNote#cfc9ed76 as nil")
	}
	b.PutID(ChatActionRecordingVoiceNoteTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *ChatActionRecordingVoiceNote) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionRecordingVoiceNote#cfc9ed76 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (c *ChatActionRecordingVoiceNote) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionRecordingVoiceNote#cfc9ed76 to nil")
	}
	if err := b.ConsumeID(ChatActionRecordingVoiceNoteTypeID); err != nil {
		return fmt.Errorf("unable to decode chatActionRecordingVoiceNote#cfc9ed76: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *ChatActionRecordingVoiceNote) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionRecordingVoiceNote#cfc9ed76 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *ChatActionRecordingVoiceNote) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionRecordingVoiceNote#cfc9ed76 as nil")
	}
	b.ObjStart()
	b.PutID("chatActionRecordingVoiceNote")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *ChatActionRecordingVoiceNote) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionRecordingVoiceNote#cfc9ed76 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("chatActionRecordingVoiceNote"); err != nil {
				return fmt.Errorf("unable to decode chatActionRecordingVoiceNote#cfc9ed76: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// ChatActionUploadingVoiceNote represents TL type `chatActionUploadingVoiceNote#db6c8a6e`.
type ChatActionUploadingVoiceNote struct {
	// Upload progress, as a percentage
	Progress int32
}

// ChatActionUploadingVoiceNoteTypeID is TL type id of ChatActionUploadingVoiceNote.
const ChatActionUploadingVoiceNoteTypeID = 0xdb6c8a6e

// construct implements constructor of ChatActionClass.
func (c ChatActionUploadingVoiceNote) construct() ChatActionClass { return &c }

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

	_ ChatActionClass = &ChatActionUploadingVoiceNote{}
)

func (c *ChatActionUploadingVoiceNote) Zero() bool {
	if c == nil {
		return true
	}
	if !(c.Progress == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (c *ChatActionUploadingVoiceNote) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "chatActionUploadingVoiceNote",
		ID:   ChatActionUploadingVoiceNoteTypeID,
	}
	if c == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Progress",
			SchemaName: "progress",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (c *ChatActionUploadingVoiceNote) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionUploadingVoiceNote#db6c8a6e as nil")
	}
	b.PutID(ChatActionUploadingVoiceNoteTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *ChatActionUploadingVoiceNote) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionUploadingVoiceNote#db6c8a6e as nil")
	}
	b.PutInt32(c.Progress)
	return nil
}

// Decode implements bin.Decoder.
func (c *ChatActionUploadingVoiceNote) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionUploadingVoiceNote#db6c8a6e to nil")
	}
	if err := b.ConsumeID(ChatActionUploadingVoiceNoteTypeID); err != nil {
		return fmt.Errorf("unable to decode chatActionUploadingVoiceNote#db6c8a6e: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *ChatActionUploadingVoiceNote) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionUploadingVoiceNote#db6c8a6e to nil")
	}
	{
		value, err := b.Int32()
		if err != nil {
			return fmt.Errorf("unable to decode chatActionUploadingVoiceNote#db6c8a6e: field progress: %w", err)
		}
		c.Progress = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *ChatActionUploadingVoiceNote) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionUploadingVoiceNote#db6c8a6e as nil")
	}
	b.ObjStart()
	b.PutID("chatActionUploadingVoiceNote")
	b.Comma()
	b.FieldStart("progress")
	b.PutInt32(c.Progress)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *ChatActionUploadingVoiceNote) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionUploadingVoiceNote#db6c8a6e to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("chatActionUploadingVoiceNote"); err != nil {
				return fmt.Errorf("unable to decode chatActionUploadingVoiceNote#db6c8a6e: %w", err)
			}
		case "progress":
			value, err := b.Int32()
			if err != nil {
				return fmt.Errorf("unable to decode chatActionUploadingVoiceNote#db6c8a6e: field progress: %w", err)
			}
			c.Progress = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetProgress returns value of Progress field.
func (c *ChatActionUploadingVoiceNote) GetProgress() (value int32) {
	if c == nil {
		return
	}
	return c.Progress
}

// ChatActionUploadingPhoto represents TL type `chatActionUploadingPhoto#26feeb47`.
type ChatActionUploadingPhoto struct {
	// Upload progress, as a percentage
	Progress int32
}

// ChatActionUploadingPhotoTypeID is TL type id of ChatActionUploadingPhoto.
const ChatActionUploadingPhotoTypeID = 0x26feeb47

// construct implements constructor of ChatActionClass.
func (c ChatActionUploadingPhoto) construct() ChatActionClass { return &c }

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

	_ ChatActionClass = &ChatActionUploadingPhoto{}
)

func (c *ChatActionUploadingPhoto) Zero() bool {
	if c == nil {
		return true
	}
	if !(c.Progress == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (c *ChatActionUploadingPhoto) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "chatActionUploadingPhoto",
		ID:   ChatActionUploadingPhotoTypeID,
	}
	if c == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Progress",
			SchemaName: "progress",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (c *ChatActionUploadingPhoto) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionUploadingPhoto#26feeb47 as nil")
	}
	b.PutID(ChatActionUploadingPhotoTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *ChatActionUploadingPhoto) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionUploadingPhoto#26feeb47 as nil")
	}
	b.PutInt32(c.Progress)
	return nil
}

// Decode implements bin.Decoder.
func (c *ChatActionUploadingPhoto) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionUploadingPhoto#26feeb47 to nil")
	}
	if err := b.ConsumeID(ChatActionUploadingPhotoTypeID); err != nil {
		return fmt.Errorf("unable to decode chatActionUploadingPhoto#26feeb47: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *ChatActionUploadingPhoto) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionUploadingPhoto#26feeb47 to nil")
	}
	{
		value, err := b.Int32()
		if err != nil {
			return fmt.Errorf("unable to decode chatActionUploadingPhoto#26feeb47: field progress: %w", err)
		}
		c.Progress = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *ChatActionUploadingPhoto) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionUploadingPhoto#26feeb47 as nil")
	}
	b.ObjStart()
	b.PutID("chatActionUploadingPhoto")
	b.Comma()
	b.FieldStart("progress")
	b.PutInt32(c.Progress)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *ChatActionUploadingPhoto) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionUploadingPhoto#26feeb47 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("chatActionUploadingPhoto"); err != nil {
				return fmt.Errorf("unable to decode chatActionUploadingPhoto#26feeb47: %w", err)
			}
		case "progress":
			value, err := b.Int32()
			if err != nil {
				return fmt.Errorf("unable to decode chatActionUploadingPhoto#26feeb47: field progress: %w", err)
			}
			c.Progress = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetProgress returns value of Progress field.
func (c *ChatActionUploadingPhoto) GetProgress() (value int32) {
	if c == nil {
		return
	}
	return c.Progress
}

// ChatActionUploadingDocument represents TL type `chatActionUploadingDocument#a01b64a`.
type ChatActionUploadingDocument struct {
	// Upload progress, as a percentage
	Progress int32
}

// ChatActionUploadingDocumentTypeID is TL type id of ChatActionUploadingDocument.
const ChatActionUploadingDocumentTypeID = 0xa01b64a

// construct implements constructor of ChatActionClass.
func (c ChatActionUploadingDocument) construct() ChatActionClass { return &c }

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

	_ ChatActionClass = &ChatActionUploadingDocument{}
)

func (c *ChatActionUploadingDocument) Zero() bool {
	if c == nil {
		return true
	}
	if !(c.Progress == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (c *ChatActionUploadingDocument) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "chatActionUploadingDocument",
		ID:   ChatActionUploadingDocumentTypeID,
	}
	if c == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Progress",
			SchemaName: "progress",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (c *ChatActionUploadingDocument) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionUploadingDocument#a01b64a as nil")
	}
	b.PutID(ChatActionUploadingDocumentTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *ChatActionUploadingDocument) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionUploadingDocument#a01b64a as nil")
	}
	b.PutInt32(c.Progress)
	return nil
}

// Decode implements bin.Decoder.
func (c *ChatActionUploadingDocument) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionUploadingDocument#a01b64a to nil")
	}
	if err := b.ConsumeID(ChatActionUploadingDocumentTypeID); err != nil {
		return fmt.Errorf("unable to decode chatActionUploadingDocument#a01b64a: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *ChatActionUploadingDocument) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionUploadingDocument#a01b64a to nil")
	}
	{
		value, err := b.Int32()
		if err != nil {
			return fmt.Errorf("unable to decode chatActionUploadingDocument#a01b64a: field progress: %w", err)
		}
		c.Progress = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *ChatActionUploadingDocument) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionUploadingDocument#a01b64a as nil")
	}
	b.ObjStart()
	b.PutID("chatActionUploadingDocument")
	b.Comma()
	b.FieldStart("progress")
	b.PutInt32(c.Progress)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *ChatActionUploadingDocument) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionUploadingDocument#a01b64a to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("chatActionUploadingDocument"); err != nil {
				return fmt.Errorf("unable to decode chatActionUploadingDocument#a01b64a: %w", err)
			}
		case "progress":
			value, err := b.Int32()
			if err != nil {
				return fmt.Errorf("unable to decode chatActionUploadingDocument#a01b64a: field progress: %w", err)
			}
			c.Progress = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetProgress returns value of Progress field.
func (c *ChatActionUploadingDocument) GetProgress() (value int32) {
	if c == nil {
		return
	}
	return c.Progress
}

// ChatActionChoosingSticker represents TL type `chatActionChoosingSticker#1637c521`.
type ChatActionChoosingSticker struct {
}

// ChatActionChoosingStickerTypeID is TL type id of ChatActionChoosingSticker.
const ChatActionChoosingStickerTypeID = 0x1637c521

// construct implements constructor of ChatActionClass.
func (c ChatActionChoosingSticker) construct() ChatActionClass { return &c }

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

	_ ChatActionClass = &ChatActionChoosingSticker{}
)

func (c *ChatActionChoosingSticker) Zero() bool {
	if c == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (c *ChatActionChoosingSticker) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionChoosingSticker#1637c521 as nil")
	}
	b.PutID(ChatActionChoosingStickerTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *ChatActionChoosingSticker) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionChoosingSticker#1637c521 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (c *ChatActionChoosingSticker) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionChoosingSticker#1637c521 to nil")
	}
	if err := b.ConsumeID(ChatActionChoosingStickerTypeID); err != nil {
		return fmt.Errorf("unable to decode chatActionChoosingSticker#1637c521: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *ChatActionChoosingSticker) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionChoosingSticker#1637c521 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *ChatActionChoosingSticker) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionChoosingSticker#1637c521 as nil")
	}
	b.ObjStart()
	b.PutID("chatActionChoosingSticker")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *ChatActionChoosingSticker) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionChoosingSticker#1637c521 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("chatActionChoosingSticker"); err != nil {
				return fmt.Errorf("unable to decode chatActionChoosingSticker#1637c521: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// ChatActionChoosingLocation represents TL type `chatActionChoosingLocation#87b96324`.
type ChatActionChoosingLocation struct {
}

// ChatActionChoosingLocationTypeID is TL type id of ChatActionChoosingLocation.
const ChatActionChoosingLocationTypeID = 0x87b96324

// construct implements constructor of ChatActionClass.
func (c ChatActionChoosingLocation) construct() ChatActionClass { return &c }

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

	_ ChatActionClass = &ChatActionChoosingLocation{}
)

func (c *ChatActionChoosingLocation) Zero() bool {
	if c == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (c *ChatActionChoosingLocation) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionChoosingLocation#87b96324 as nil")
	}
	b.PutID(ChatActionChoosingLocationTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *ChatActionChoosingLocation) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionChoosingLocation#87b96324 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (c *ChatActionChoosingLocation) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionChoosingLocation#87b96324 to nil")
	}
	if err := b.ConsumeID(ChatActionChoosingLocationTypeID); err != nil {
		return fmt.Errorf("unable to decode chatActionChoosingLocation#87b96324: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *ChatActionChoosingLocation) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionChoosingLocation#87b96324 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *ChatActionChoosingLocation) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionChoosingLocation#87b96324 as nil")
	}
	b.ObjStart()
	b.PutID("chatActionChoosingLocation")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *ChatActionChoosingLocation) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionChoosingLocation#87b96324 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("chatActionChoosingLocation"); err != nil {
				return fmt.Errorf("unable to decode chatActionChoosingLocation#87b96324: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// ChatActionChoosingContact represents TL type `chatActionChoosingContact#b7220418`.
type ChatActionChoosingContact struct {
}

// ChatActionChoosingContactTypeID is TL type id of ChatActionChoosingContact.
const ChatActionChoosingContactTypeID = 0xb7220418

// construct implements constructor of ChatActionClass.
func (c ChatActionChoosingContact) construct() ChatActionClass { return &c }

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

	_ ChatActionClass = &ChatActionChoosingContact{}
)

func (c *ChatActionChoosingContact) Zero() bool {
	if c == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (c *ChatActionChoosingContact) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionChoosingContact#b7220418 as nil")
	}
	b.PutID(ChatActionChoosingContactTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *ChatActionChoosingContact) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionChoosingContact#b7220418 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (c *ChatActionChoosingContact) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionChoosingContact#b7220418 to nil")
	}
	if err := b.ConsumeID(ChatActionChoosingContactTypeID); err != nil {
		return fmt.Errorf("unable to decode chatActionChoosingContact#b7220418: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *ChatActionChoosingContact) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionChoosingContact#b7220418 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *ChatActionChoosingContact) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionChoosingContact#b7220418 as nil")
	}
	b.ObjStart()
	b.PutID("chatActionChoosingContact")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *ChatActionChoosingContact) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionChoosingContact#b7220418 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("chatActionChoosingContact"); err != nil {
				return fmt.Errorf("unable to decode chatActionChoosingContact#b7220418: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// ChatActionStartPlayingGame represents TL type `chatActionStartPlayingGame#cc63a7fc`.
type ChatActionStartPlayingGame struct {
}

// ChatActionStartPlayingGameTypeID is TL type id of ChatActionStartPlayingGame.
const ChatActionStartPlayingGameTypeID = 0xcc63a7fc

// construct implements constructor of ChatActionClass.
func (c ChatActionStartPlayingGame) construct() ChatActionClass { return &c }

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

	_ ChatActionClass = &ChatActionStartPlayingGame{}
)

func (c *ChatActionStartPlayingGame) Zero() bool {
	if c == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (c *ChatActionStartPlayingGame) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionStartPlayingGame#cc63a7fc as nil")
	}
	b.PutID(ChatActionStartPlayingGameTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *ChatActionStartPlayingGame) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionStartPlayingGame#cc63a7fc as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (c *ChatActionStartPlayingGame) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionStartPlayingGame#cc63a7fc to nil")
	}
	if err := b.ConsumeID(ChatActionStartPlayingGameTypeID); err != nil {
		return fmt.Errorf("unable to decode chatActionStartPlayingGame#cc63a7fc: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *ChatActionStartPlayingGame) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionStartPlayingGame#cc63a7fc to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *ChatActionStartPlayingGame) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionStartPlayingGame#cc63a7fc as nil")
	}
	b.ObjStart()
	b.PutID("chatActionStartPlayingGame")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *ChatActionStartPlayingGame) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionStartPlayingGame#cc63a7fc to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("chatActionStartPlayingGame"); err != nil {
				return fmt.Errorf("unable to decode chatActionStartPlayingGame#cc63a7fc: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// ChatActionRecordingVideoNote represents TL type `chatActionRecordingVideoNote#fc2081`.
type ChatActionRecordingVideoNote struct {
}

// ChatActionRecordingVideoNoteTypeID is TL type id of ChatActionRecordingVideoNote.
const ChatActionRecordingVideoNoteTypeID = 0xfc2081

// construct implements constructor of ChatActionClass.
func (c ChatActionRecordingVideoNote) construct() ChatActionClass { return &c }

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

	_ ChatActionClass = &ChatActionRecordingVideoNote{}
)

func (c *ChatActionRecordingVideoNote) Zero() bool {
	if c == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (c *ChatActionRecordingVideoNote) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionRecordingVideoNote#fc2081 as nil")
	}
	b.PutID(ChatActionRecordingVideoNoteTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *ChatActionRecordingVideoNote) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionRecordingVideoNote#fc2081 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (c *ChatActionRecordingVideoNote) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionRecordingVideoNote#fc2081 to nil")
	}
	if err := b.ConsumeID(ChatActionRecordingVideoNoteTypeID); err != nil {
		return fmt.Errorf("unable to decode chatActionRecordingVideoNote#fc2081: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *ChatActionRecordingVideoNote) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionRecordingVideoNote#fc2081 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *ChatActionRecordingVideoNote) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionRecordingVideoNote#fc2081 as nil")
	}
	b.ObjStart()
	b.PutID("chatActionRecordingVideoNote")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *ChatActionRecordingVideoNote) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionRecordingVideoNote#fc2081 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("chatActionRecordingVideoNote"); err != nil {
				return fmt.Errorf("unable to decode chatActionRecordingVideoNote#fc2081: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// ChatActionUploadingVideoNote represents TL type `chatActionUploadingVideoNote#45e0de76`.
type ChatActionUploadingVideoNote struct {
	// Upload progress, as a percentage
	Progress int32
}

// ChatActionUploadingVideoNoteTypeID is TL type id of ChatActionUploadingVideoNote.
const ChatActionUploadingVideoNoteTypeID = 0x45e0de76

// construct implements constructor of ChatActionClass.
func (c ChatActionUploadingVideoNote) construct() ChatActionClass { return &c }

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

	_ ChatActionClass = &ChatActionUploadingVideoNote{}
)

func (c *ChatActionUploadingVideoNote) Zero() bool {
	if c == nil {
		return true
	}
	if !(c.Progress == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (c *ChatActionUploadingVideoNote) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "chatActionUploadingVideoNote",
		ID:   ChatActionUploadingVideoNoteTypeID,
	}
	if c == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Progress",
			SchemaName: "progress",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (c *ChatActionUploadingVideoNote) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionUploadingVideoNote#45e0de76 as nil")
	}
	b.PutID(ChatActionUploadingVideoNoteTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *ChatActionUploadingVideoNote) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionUploadingVideoNote#45e0de76 as nil")
	}
	b.PutInt32(c.Progress)
	return nil
}

// Decode implements bin.Decoder.
func (c *ChatActionUploadingVideoNote) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionUploadingVideoNote#45e0de76 to nil")
	}
	if err := b.ConsumeID(ChatActionUploadingVideoNoteTypeID); err != nil {
		return fmt.Errorf("unable to decode chatActionUploadingVideoNote#45e0de76: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *ChatActionUploadingVideoNote) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionUploadingVideoNote#45e0de76 to nil")
	}
	{
		value, err := b.Int32()
		if err != nil {
			return fmt.Errorf("unable to decode chatActionUploadingVideoNote#45e0de76: field progress: %w", err)
		}
		c.Progress = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *ChatActionUploadingVideoNote) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionUploadingVideoNote#45e0de76 as nil")
	}
	b.ObjStart()
	b.PutID("chatActionUploadingVideoNote")
	b.Comma()
	b.FieldStart("progress")
	b.PutInt32(c.Progress)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *ChatActionUploadingVideoNote) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionUploadingVideoNote#45e0de76 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("chatActionUploadingVideoNote"); err != nil {
				return fmt.Errorf("unable to decode chatActionUploadingVideoNote#45e0de76: %w", err)
			}
		case "progress":
			value, err := b.Int32()
			if err != nil {
				return fmt.Errorf("unable to decode chatActionUploadingVideoNote#45e0de76: field progress: %w", err)
			}
			c.Progress = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetProgress returns value of Progress field.
func (c *ChatActionUploadingVideoNote) GetProgress() (value int32) {
	if c == nil {
		return
	}
	return c.Progress
}

// ChatActionWatchingAnimations represents TL type `chatActionWatchingAnimations#7a5e26b1`.
type ChatActionWatchingAnimations struct {
	// The animated emoji
	Emoji string
}

// ChatActionWatchingAnimationsTypeID is TL type id of ChatActionWatchingAnimations.
const ChatActionWatchingAnimationsTypeID = 0x7a5e26b1

// construct implements constructor of ChatActionClass.
func (c ChatActionWatchingAnimations) construct() ChatActionClass { return &c }

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

	_ ChatActionClass = &ChatActionWatchingAnimations{}
)

func (c *ChatActionWatchingAnimations) Zero() bool {
	if c == nil {
		return true
	}
	if !(c.Emoji == "") {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (c *ChatActionWatchingAnimations) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "chatActionWatchingAnimations",
		ID:   ChatActionWatchingAnimationsTypeID,
	}
	if c == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Emoji",
			SchemaName: "emoji",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (c *ChatActionWatchingAnimations) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionWatchingAnimations#7a5e26b1 as nil")
	}
	b.PutID(ChatActionWatchingAnimationsTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *ChatActionWatchingAnimations) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionWatchingAnimations#7a5e26b1 as nil")
	}
	b.PutString(c.Emoji)
	return nil
}

// Decode implements bin.Decoder.
func (c *ChatActionWatchingAnimations) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionWatchingAnimations#7a5e26b1 to nil")
	}
	if err := b.ConsumeID(ChatActionWatchingAnimationsTypeID); err != nil {
		return fmt.Errorf("unable to decode chatActionWatchingAnimations#7a5e26b1: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *ChatActionWatchingAnimations) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionWatchingAnimations#7a5e26b1 to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode chatActionWatchingAnimations#7a5e26b1: field emoji: %w", err)
		}
		c.Emoji = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *ChatActionWatchingAnimations) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionWatchingAnimations#7a5e26b1 as nil")
	}
	b.ObjStart()
	b.PutID("chatActionWatchingAnimations")
	b.Comma()
	b.FieldStart("emoji")
	b.PutString(c.Emoji)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *ChatActionWatchingAnimations) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionWatchingAnimations#7a5e26b1 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("chatActionWatchingAnimations"); err != nil {
				return fmt.Errorf("unable to decode chatActionWatchingAnimations#7a5e26b1: %w", err)
			}
		case "emoji":
			value, err := b.String()
			if err != nil {
				return fmt.Errorf("unable to decode chatActionWatchingAnimations#7a5e26b1: field emoji: %w", err)
			}
			c.Emoji = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetEmoji returns value of Emoji field.
func (c *ChatActionWatchingAnimations) GetEmoji() (value string) {
	if c == nil {
		return
	}
	return c.Emoji
}

// ChatActionCancel represents TL type `chatActionCancel#452c30b6`.
type ChatActionCancel struct {
}

// ChatActionCancelTypeID is TL type id of ChatActionCancel.
const ChatActionCancelTypeID = 0x452c30b6

// construct implements constructor of ChatActionClass.
func (c ChatActionCancel) construct() ChatActionClass { return &c }

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

	_ ChatActionClass = &ChatActionCancel{}
)

func (c *ChatActionCancel) Zero() bool {
	if c == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (c *ChatActionCancel) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionCancel#452c30b6 as nil")
	}
	b.PutID(ChatActionCancelTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *ChatActionCancel) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionCancel#452c30b6 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (c *ChatActionCancel) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionCancel#452c30b6 to nil")
	}
	if err := b.ConsumeID(ChatActionCancelTypeID); err != nil {
		return fmt.Errorf("unable to decode chatActionCancel#452c30b6: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *ChatActionCancel) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionCancel#452c30b6 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *ChatActionCancel) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode chatActionCancel#452c30b6 as nil")
	}
	b.ObjStart()
	b.PutID("chatActionCancel")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *ChatActionCancel) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode chatActionCancel#452c30b6 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("chatActionCancel"); err != nil {
				return fmt.Errorf("unable to decode chatActionCancel#452c30b6: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// ChatActionClassName is schema name of ChatActionClass.
const ChatActionClassName = "ChatAction"

// ChatActionClass represents ChatAction generic type.
//
// Example:
//
//	g, err := tdapi.DecodeChatAction(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tdapi.ChatActionTyping: // chatActionTyping#16a83437
//	case *tdapi.ChatActionRecordingVideo: // chatActionRecordingVideo#ce85792
//	case *tdapi.ChatActionUploadingVideo: // chatActionUploadingVideo#49902c36
//	case *tdapi.ChatActionRecordingVoiceNote: // chatActionRecordingVoiceNote#cfc9ed76
//	case *tdapi.ChatActionUploadingVoiceNote: // chatActionUploadingVoiceNote#db6c8a6e
//	case *tdapi.ChatActionUploadingPhoto: // chatActionUploadingPhoto#26feeb47
//	case *tdapi.ChatActionUploadingDocument: // chatActionUploadingDocument#a01b64a
//	case *tdapi.ChatActionChoosingSticker: // chatActionChoosingSticker#1637c521
//	case *tdapi.ChatActionChoosingLocation: // chatActionChoosingLocation#87b96324
//	case *tdapi.ChatActionChoosingContact: // chatActionChoosingContact#b7220418
//	case *tdapi.ChatActionStartPlayingGame: // chatActionStartPlayingGame#cc63a7fc
//	case *tdapi.ChatActionRecordingVideoNote: // chatActionRecordingVideoNote#fc2081
//	case *tdapi.ChatActionUploadingVideoNote: // chatActionUploadingVideoNote#45e0de76
//	case *tdapi.ChatActionWatchingAnimations: // chatActionWatchingAnimations#7a5e26b1
//	case *tdapi.ChatActionCancel: // chatActionCancel#452c30b6
//	default: panic(v)
//	}
type ChatActionClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() ChatActionClass

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

	EncodeTDLibJSON(b tdjson.Encoder) error
	DecodeTDLibJSON(b tdjson.Decoder) error
}

// DecodeChatAction implements binary de-serialization for ChatActionClass.
func DecodeChatAction(buf *bin.Buffer) (ChatActionClass, error) {
	id, err := buf.PeekID()
	if err != nil {
		return nil, err
	}
	switch id {
	case ChatActionTypingTypeID:
		// Decoding chatActionTyping#16a83437.
		v := ChatActionTyping{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case ChatActionRecordingVideoTypeID:
		// Decoding chatActionRecordingVideo#ce85792.
		v := ChatActionRecordingVideo{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case ChatActionUploadingVideoTypeID:
		// Decoding chatActionUploadingVideo#49902c36.
		v := ChatActionUploadingVideo{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case ChatActionRecordingVoiceNoteTypeID:
		// Decoding chatActionRecordingVoiceNote#cfc9ed76.
		v := ChatActionRecordingVoiceNote{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case ChatActionUploadingVoiceNoteTypeID:
		// Decoding chatActionUploadingVoiceNote#db6c8a6e.
		v := ChatActionUploadingVoiceNote{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case ChatActionUploadingPhotoTypeID:
		// Decoding chatActionUploadingPhoto#26feeb47.
		v := ChatActionUploadingPhoto{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case ChatActionUploadingDocumentTypeID:
		// Decoding chatActionUploadingDocument#a01b64a.
		v := ChatActionUploadingDocument{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case ChatActionChoosingStickerTypeID:
		// Decoding chatActionChoosingSticker#1637c521.
		v := ChatActionChoosingSticker{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case ChatActionChoosingLocationTypeID:
		// Decoding chatActionChoosingLocation#87b96324.
		v := ChatActionChoosingLocation{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case ChatActionChoosingContactTypeID:
		// Decoding chatActionChoosingContact#b7220418.
		v := ChatActionChoosingContact{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case ChatActionStartPlayingGameTypeID:
		// Decoding chatActionStartPlayingGame#cc63a7fc.
		v := ChatActionStartPlayingGame{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case ChatActionRecordingVideoNoteTypeID:
		// Decoding chatActionRecordingVideoNote#fc2081.
		v := ChatActionRecordingVideoNote{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case ChatActionUploadingVideoNoteTypeID:
		// Decoding chatActionUploadingVideoNote#45e0de76.
		v := ChatActionUploadingVideoNote{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case ChatActionWatchingAnimationsTypeID:
		// Decoding chatActionWatchingAnimations#7a5e26b1.
		v := ChatActionWatchingAnimations{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case ChatActionCancelTypeID:
		// Decoding chatActionCancel#452c30b6.
		v := ChatActionCancel{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode ChatActionClass: %w", bin.NewUnexpectedID(id))
	}
}

// DecodeTDLibJSONChatAction implements binary de-serialization for ChatActionClass.
func DecodeTDLibJSONChatAction(buf tdjson.Decoder) (ChatActionClass, error) {
	id, err := buf.FindTypeID()
	if err != nil {
		return nil, err
	}
	switch id {
	case "chatActionTyping":
		// Decoding chatActionTyping#16a83437.
		v := ChatActionTyping{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case "chatActionRecordingVideo":
		// Decoding chatActionRecordingVideo#ce85792.
		v := ChatActionRecordingVideo{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case "chatActionUploadingVideo":
		// Decoding chatActionUploadingVideo#49902c36.
		v := ChatActionUploadingVideo{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case "chatActionRecordingVoiceNote":
		// Decoding chatActionRecordingVoiceNote#cfc9ed76.
		v := ChatActionRecordingVoiceNote{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case "chatActionUploadingVoiceNote":
		// Decoding chatActionUploadingVoiceNote#db6c8a6e.
		v := ChatActionUploadingVoiceNote{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case "chatActionUploadingPhoto":
		// Decoding chatActionUploadingPhoto#26feeb47.
		v := ChatActionUploadingPhoto{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case "chatActionUploadingDocument":
		// Decoding chatActionUploadingDocument#a01b64a.
		v := ChatActionUploadingDocument{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case "chatActionChoosingSticker":
		// Decoding chatActionChoosingSticker#1637c521.
		v := ChatActionChoosingSticker{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case "chatActionChoosingLocation":
		// Decoding chatActionChoosingLocation#87b96324.
		v := ChatActionChoosingLocation{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case "chatActionChoosingContact":
		// Decoding chatActionChoosingContact#b7220418.
		v := ChatActionChoosingContact{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case "chatActionStartPlayingGame":
		// Decoding chatActionStartPlayingGame#cc63a7fc.
		v := ChatActionStartPlayingGame{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case "chatActionRecordingVideoNote":
		// Decoding chatActionRecordingVideoNote#fc2081.
		v := ChatActionRecordingVideoNote{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case "chatActionUploadingVideoNote":
		// Decoding chatActionUploadingVideoNote#45e0de76.
		v := ChatActionUploadingVideoNote{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case "chatActionWatchingAnimations":
		// Decoding chatActionWatchingAnimations#7a5e26b1.
		v := ChatActionWatchingAnimations{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	case "chatActionCancel":
		// Decoding chatActionCancel#452c30b6.
		v := ChatActionCancel{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode ChatActionClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode ChatActionClass: %w", tdjson.NewUnexpectedID(id))
	}
}

// ChatAction boxes the ChatActionClass providing a helper.
type ChatActionBox struct {
	ChatAction ChatActionClass
}

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

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

// DecodeTDLibJSON implements bin.Decoder for ChatActionBox.
func (b *ChatActionBox) DecodeTDLibJSON(buf tdjson.Decoder) error {
	if b == nil {
		return fmt.Errorf("unable to decode ChatActionBox to nil")
	}
	v, err := DecodeTDLibJSONChatAction(buf)
	if err != nil {
		return fmt.Errorf("unable to decode boxed value: %w", err)
	}
	b.ChatAction = v
	return nil
}

// EncodeTDLibJSON implements bin.Encode for ChatActionBox.
func (b *ChatActionBox) EncodeTDLibJSON(buf tdjson.Encoder) error {
	if b == nil || b.ChatAction == nil {
		return fmt.Errorf("unable to encode ChatActionClass as nil")
	}
	return b.ChatAction.EncodeTDLibJSON(buf)
}
