// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// ChatEmpty represents TL type `chatEmpty#29562865`.
// Empty constructor, group doesn't exist
//
// See https://core.telegram.org/constructor/chatEmpty for reference.
type ChatEmpty struct {
	// Group identifier
	ID int64
}

// ChatEmptyTypeID is TL type id of ChatEmpty.
const ChatEmptyTypeID = 0x29562865

// construct implements constructor of ChatClass.
func ( ChatEmpty) () ChatClass { return & }

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

	_ ChatClass = &ChatEmpty{}
)

func ( *ChatEmpty) () bool {
	if  == nil {
		return true
	}
	if !(.ID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills ChatEmpty from given interface.
func ( *ChatEmpty) ( interface {
	() ( int64)
}) {
	.ID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChatEmpty) () tdp.Type {
	 := tdp.Type{
		Name: "chatEmpty",
		ID:   ChatEmptyTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChatEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatEmpty#29562865 as nil")
	}
	.PutID(ChatEmptyTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChatEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatEmpty#29562865 as nil")
	}
	.PutLong(.ID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChatEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chatEmpty#29562865 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode chatEmpty#29562865: field id: %w", )
		}
		.ID = 
	}
	return nil
}

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

// Chat represents TL type `chat#41cbf256`.
// Info about a group
//
// See https://core.telegram.org/constructor/chat for reference.
type Chat struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the current user is the creator of the group
	Creator bool
	// Whether the current user has left the group
	Left bool
	// Whether the group was migrated¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	Deactivated bool
	// Whether a group call is currently active
	CallActive bool
	// Whether there's anyone in the group call
	CallNotEmpty bool
	// Whether this group is protected¹, thus does not allow forwarding messages from it
	//
	// Links:
	//  1) https://telegram.org/blog/protected-content-delete-by-date-and-more
	Noforwards bool
	// ID of the group
	ID int64
	// Title
	Title string
	// Chat photo
	Photo ChatPhotoClass
	// Participant count
	ParticipantsCount int
	// Date of creation of the group
	Date int
	// Used in basic groups to reorder updates and make sure that all of them were received.
	Version int
	// Means this chat was upgraded¹ to a supergroup
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	//
	// Use SetMigratedTo and GetMigratedTo helpers.
	MigratedTo InputChannelClass
	// Admin rights¹ of the user in the group
	//
	// Links:
	//  1) https://core.telegram.org/api/rights
	//
	// Use SetAdminRights and GetAdminRights helpers.
	AdminRights ChatAdminRights
	// Default banned rights¹ of all users in the group
	//
	// Links:
	//  1) https://core.telegram.org/api/rights
	//
	// Use SetDefaultBannedRights and GetDefaultBannedRights helpers.
	DefaultBannedRights ChatBannedRights
}

// ChatTypeID is TL type id of Chat.
const ChatTypeID = 0x41cbf256

// construct implements constructor of ChatClass.
func ( Chat) () ChatClass { return & }

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

	_ ChatClass = &Chat{}
)

func ( *Chat) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Creator == false) {
		return false
	}
	if !(.Left == false) {
		return false
	}
	if !(.Deactivated == false) {
		return false
	}
	if !(.CallActive == false) {
		return false
	}
	if !(.CallNotEmpty == false) {
		return false
	}
	if !(.Noforwards == false) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.Photo == nil) {
		return false
	}
	if !(.ParticipantsCount == 0) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.Version == 0) {
		return false
	}
	if !(.MigratedTo == nil) {
		return false
	}
	if !(.AdminRights.Zero()) {
		return false
	}
	if !(.DefaultBannedRights.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills Chat from given interface.
func ( *Chat) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( int64)
	() ( string)
	() ( ChatPhotoClass)
	() ( int)
	() ( int)
	() ( int)
	() ( InputChannelClass,  bool)
	() ( ChatAdminRights,  bool)
	() ( ChatBannedRights,  bool)
}) {
	.Creator = .()
	.Left = .()
	.Deactivated = .()
	.CallActive = .()
	.CallNotEmpty = .()
	.Noforwards = .()
	.ID = .()
	.Title = .()
	.Photo = .()
	.ParticipantsCount = .()
	.Date = .()
	.Version = .()
	if ,  := .();  {
		.MigratedTo = 
	}

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

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

}

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

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

// TypeInfo returns info about TL type.
func ( *Chat) () tdp.Type {
	 := tdp.Type{
		Name: "chat",
		ID:   ChatTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Creator",
			SchemaName: "creator",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Left",
			SchemaName: "left",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Deactivated",
			SchemaName: "deactivated",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "CallActive",
			SchemaName: "call_active",
			Null:       !.Flags.Has(23),
		},
		{
			Name:       "CallNotEmpty",
			SchemaName: "call_not_empty",
			Null:       !.Flags.Has(24),
		},
		{
			Name:       "Noforwards",
			SchemaName: "noforwards",
			Null:       !.Flags.Has(25),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "Photo",
			SchemaName: "photo",
		},
		{
			Name:       "ParticipantsCount",
			SchemaName: "participants_count",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "Version",
			SchemaName: "version",
		},
		{
			Name:       "MigratedTo",
			SchemaName: "migrated_to",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "AdminRights",
			SchemaName: "admin_rights",
			Null:       !.Flags.Has(14),
		},
		{
			Name:       "DefaultBannedRights",
			SchemaName: "default_banned_rights",
			Null:       !.Flags.Has(18),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *Chat) () {
	if !(.Creator == false) {
		.Flags.Set(0)
	}
	if !(.Left == false) {
		.Flags.Set(2)
	}
	if !(.Deactivated == false) {
		.Flags.Set(5)
	}
	if !(.CallActive == false) {
		.Flags.Set(23)
	}
	if !(.CallNotEmpty == false) {
		.Flags.Set(24)
	}
	if !(.Noforwards == false) {
		.Flags.Set(25)
	}
	if !(.MigratedTo == nil) {
		.Flags.Set(6)
	}
	if !(.AdminRights.Zero()) {
		.Flags.Set(14)
	}
	if !(.DefaultBannedRights.Zero()) {
		.Flags.Set(18)
	}
}

// Encode implements bin.Encoder.
func ( *Chat) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chat#41cbf256 as nil")
	}
	.PutID(ChatTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *Chat) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chat#41cbf256 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode chat#41cbf256: field flags: %w", )
	}
	.PutLong(.ID)
	.PutString(.Title)
	if .Photo == nil {
		return fmt.Errorf("unable to encode chat#41cbf256: field photo is nil")
	}
	if  := .Photo.Encode();  != nil {
		return fmt.Errorf("unable to encode chat#41cbf256: field photo: %w", )
	}
	.PutInt(.ParticipantsCount)
	.PutInt(.Date)
	.PutInt(.Version)
	if .Flags.Has(6) {
		if .MigratedTo == nil {
			return fmt.Errorf("unable to encode chat#41cbf256: field migrated_to is nil")
		}
		if  := .MigratedTo.Encode();  != nil {
			return fmt.Errorf("unable to encode chat#41cbf256: field migrated_to: %w", )
		}
	}
	if .Flags.Has(14) {
		if  := .AdminRights.Encode();  != nil {
			return fmt.Errorf("unable to encode chat#41cbf256: field admin_rights: %w", )
		}
	}
	if .Flags.Has(18) {
		if  := .DefaultBannedRights.Encode();  != nil {
			return fmt.Errorf("unable to encode chat#41cbf256: field default_banned_rights: %w", )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *Chat) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chat#41cbf256 to nil")
	}
	if  := .ConsumeID(ChatTypeID);  != nil {
		return fmt.Errorf("unable to decode chat#41cbf256: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *Chat) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chat#41cbf256 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode chat#41cbf256: field flags: %w", )
		}
	}
	.Creator = .Flags.Has(0)
	.Left = .Flags.Has(2)
	.Deactivated = .Flags.Has(5)
	.CallActive = .Flags.Has(23)
	.CallNotEmpty = .Flags.Has(24)
	.Noforwards = .Flags.Has(25)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode chat#41cbf256: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode chat#41cbf256: field title: %w", )
		}
		.Title = 
	}
	{
		,  := DecodeChatPhoto()
		if  != nil {
			return fmt.Errorf("unable to decode chat#41cbf256: field photo: %w", )
		}
		.Photo = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode chat#41cbf256: field participants_count: %w", )
		}
		.ParticipantsCount = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode chat#41cbf256: field date: %w", )
		}
		.Date = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode chat#41cbf256: field version: %w", )
		}
		.Version = 
	}
	if .Flags.Has(6) {
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode chat#41cbf256: field migrated_to: %w", )
		}
		.MigratedTo = 
	}
	if .Flags.Has(14) {
		if  := .AdminRights.Decode();  != nil {
			return fmt.Errorf("unable to decode chat#41cbf256: field admin_rights: %w", )
		}
	}
	if .Flags.Has(18) {
		if  := .DefaultBannedRights.Decode();  != nil {
			return fmt.Errorf("unable to decode chat#41cbf256: field default_banned_rights: %w", )
		}
	}
	return nil
}

// SetCreator sets value of Creator conditional field.
func ( *Chat) ( bool) {
	if  {
		.Flags.Set(0)
		.Creator = true
	} else {
		.Flags.Unset(0)
		.Creator = false
	}
}

// GetCreator returns value of Creator conditional field.
func ( *Chat) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetLeft sets value of Left conditional field.
func ( *Chat) ( bool) {
	if  {
		.Flags.Set(2)
		.Left = true
	} else {
		.Flags.Unset(2)
		.Left = false
	}
}

// GetLeft returns value of Left conditional field.
func ( *Chat) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// SetDeactivated sets value of Deactivated conditional field.
func ( *Chat) ( bool) {
	if  {
		.Flags.Set(5)
		.Deactivated = true
	} else {
		.Flags.Unset(5)
		.Deactivated = false
	}
}

// GetDeactivated returns value of Deactivated conditional field.
func ( *Chat) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(5)
}

// SetCallActive sets value of CallActive conditional field.
func ( *Chat) ( bool) {
	if  {
		.Flags.Set(23)
		.CallActive = true
	} else {
		.Flags.Unset(23)
		.CallActive = false
	}
}

// GetCallActive returns value of CallActive conditional field.
func ( *Chat) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(23)
}

// SetCallNotEmpty sets value of CallNotEmpty conditional field.
func ( *Chat) ( bool) {
	if  {
		.Flags.Set(24)
		.CallNotEmpty = true
	} else {
		.Flags.Unset(24)
		.CallNotEmpty = false
	}
}

// GetCallNotEmpty returns value of CallNotEmpty conditional field.
func ( *Chat) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(24)
}

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

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

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

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

// GetPhoto returns value of Photo field.
func ( *Chat) () ( ChatPhotoClass) {
	if  == nil {
		return
	}
	return .Photo
}

// GetParticipantsCount returns value of ParticipantsCount field.
func ( *Chat) () ( int) {
	if  == nil {
		return
	}
	return .ParticipantsCount
}

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

// GetVersion returns value of Version field.
func ( *Chat) () ( int) {
	if  == nil {
		return
	}
	return .Version
}

// SetMigratedTo sets value of MigratedTo conditional field.
func ( *Chat) ( InputChannelClass) {
	.Flags.Set(6)
	.MigratedTo = 
}

// GetMigratedTo returns value of MigratedTo conditional field and
// boolean which is true if field was set.
func ( *Chat) () ( InputChannelClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(6) {
		return , false
	}
	return .MigratedTo, true
}

// SetAdminRights sets value of AdminRights conditional field.
func ( *Chat) ( ChatAdminRights) {
	.Flags.Set(14)
	.AdminRights = 
}

// GetAdminRights returns value of AdminRights conditional field and
// boolean which is true if field was set.
func ( *Chat) () ( ChatAdminRights,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(14) {
		return , false
	}
	return .AdminRights, true
}

// SetDefaultBannedRights sets value of DefaultBannedRights conditional field.
func ( *Chat) ( ChatBannedRights) {
	.Flags.Set(18)
	.DefaultBannedRights = 
}

// GetDefaultBannedRights returns value of DefaultBannedRights conditional field and
// boolean which is true if field was set.
func ( *Chat) () ( ChatBannedRights,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(18) {
		return , false
	}
	return .DefaultBannedRights, true
}

// ChatForbidden represents TL type `chatForbidden#6592a1a7`.
// A group to which the user has no access. E.g., because the user was kicked from the
// group.
//
// See https://core.telegram.org/constructor/chatForbidden for reference.
type ChatForbidden struct {
	// User identifier
	ID int64
	// Group name
	Title string
}

// ChatForbiddenTypeID is TL type id of ChatForbidden.
const ChatForbiddenTypeID = 0x6592a1a7

// construct implements constructor of ChatClass.
func ( ChatForbidden) () ChatClass { return & }

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

	_ ChatClass = &ChatForbidden{}
)

func ( *ChatForbidden) () bool {
	if  == nil {
		return true
	}
	if !(.ID == 0) {
		return false
	}
	if !(.Title == "") {
		return false
	}

	return true
}

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

// FillFrom fills ChatForbidden from given interface.
func ( *ChatForbidden) ( interface {
	() ( int64)
	() ( string)
}) {
	.ID = .()
	.Title = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChatForbidden) () tdp.Type {
	 := tdp.Type{
		Name: "chatForbidden",
		ID:   ChatForbiddenTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Title",
			SchemaName: "title",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChatForbidden) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatForbidden#6592a1a7 as nil")
	}
	.PutID(ChatForbiddenTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChatForbidden) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatForbidden#6592a1a7 as nil")
	}
	.PutLong(.ID)
	.PutString(.Title)
	return nil
}

// Decode implements bin.Decoder.
func ( *ChatForbidden) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chatForbidden#6592a1a7 to nil")
	}
	if  := .ConsumeID(ChatForbiddenTypeID);  != nil {
		return fmt.Errorf("unable to decode chatForbidden#6592a1a7: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ChatForbidden) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chatForbidden#6592a1a7 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode chatForbidden#6592a1a7: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode chatForbidden#6592a1a7: field title: %w", )
		}
		.Title = 
	}
	return nil
}

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

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

// Channel represents TL type `channel#aadfc8f`.
// Channel/supergroup info
//
// See https://core.telegram.org/constructor/channel for reference.
type Channel struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the current user is the creator of this channel
	Creator bool
	// Whether the current user has left or is not a member of this channel
	Left bool
	// Is this a channel?
	Broadcast bool
	// Is this channel verified by telegram?
	Verified bool
	// Is this a supergroup?
	Megagroup bool
	// Whether viewing/writing in this channel for a reason (see restriction_reason
	Restricted bool
	// Whether signatures are enabled (channels)
	Signatures bool
	// See min¹
	//
	// Links:
	//  1) https://core.telegram.org/api/min
	Min bool
	// This channel/supergroup is probably a scam
	Scam bool
	// Whether this channel has a private join link
	HasLink bool
	// Whether this chanel has a geoposition
	HasGeo bool
	// Whether slow mode is enabled for groups to prevent flood in chat
	SlowmodeEnabled bool
	// Whether a group call or livestream is currently active
	CallActive bool
	// Whether there's anyone in the group call or livestream
	CallNotEmpty bool
	// If set, this supergroup/channel¹ was reported by many users as a fake or scam: be
	// careful when interacting with it.
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	Fake bool
	// Whether this supergroup¹ is a gigagroup
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	Gigagroup bool
	// Whether this channel or group is protected¹, thus does not allow forwarding messages
	// from it
	//
	// Links:
	//  1) https://telegram.org/blog/protected-content-delete-by-date-and-more
	Noforwards bool
	// Whether a user needs to join the supergroup before they can send messages: can be
	// false only for discussion groups »¹, toggle using channels.toggleJoinToSend²
	//
	// Links:
	//  1) https://core.telegram.org/api/discussion
	//  2) https://core.telegram.org/method/channels.toggleJoinToSend
	JoinToSend bool
	// Whether a user's join request will have to be approved by administrators¹, toggle
	// using channels.toggleJoinToSend²
	//
	// Links:
	//  1) https://core.telegram.org/api/invites#join-requests
	//  2) https://core.telegram.org/method/channels.toggleJoinRequest
	JoinRequest bool
	// Whether this supergroup is a forum¹
	//
	// Links:
	//  1) https://core.telegram.org/api/forum
	Forum bool
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags2 bin.Fields
	// Whether we have hidden all stories posted by this channel »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/stories#hiding-stories-of-other-users
	StoriesHidden bool
	// If set, indicates that the stories_hidden flag was not populated, and its value must
	// cannot be relied on; use the previously cached value, or re-fetch the constructor
	// using channels.getChannels¹ to obtain the latest value of the stories_hidden flag.
	//
	// Links:
	//  1) https://core.telegram.org/method/channels.getChannels
	StoriesHiddenMin bool
	// No stories from the channel are visible.
	StoriesUnavailable bool
	// ID of the channel
	ID int64
	// Access hash
	//
	// Use SetAccessHash and GetAccessHash helpers.
	AccessHash int64
	// Title
	Title string
	// Username
	//
	// Use SetUsername and GetUsername helpers.
	Username string
	// Profile photo
	Photo ChatPhotoClass
	// Date when the user joined the supergroup/channel, or if the user isn't a member, its
	// creation date
	Date int
	// Contains the reason why access to this channel must be restricted.
	//
	// Use SetRestrictionReason and GetRestrictionReason helpers.
	RestrictionReason []RestrictionReason
	// Admin rights of the user in this channel (see rights¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/rights
	//
	// Use SetAdminRights and GetAdminRights helpers.
	AdminRights ChatAdminRights
	// Banned rights of the user in this channel (see rights¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/rights
	//
	// Use SetBannedRights and GetBannedRights helpers.
	BannedRights ChatBannedRights
	// Default chat rights (see rights¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/rights
	//
	// Use SetDefaultBannedRights and GetDefaultBannedRights helpers.
	DefaultBannedRights ChatBannedRights
	// Participant count
	//
	// Use SetParticipantsCount and GetParticipantsCount helpers.
	ParticipantsCount int
	// Additional usernames
	//
	// Use SetUsernames and GetUsernames helpers.
	Usernames []Username
	// ID of the maximum read story¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/stories
	//
	// Use SetStoriesMaxID and GetStoriesMaxID helpers.
	StoriesMaxID int
	// The channel's accent color¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/colors
	//
	// Use SetColor and GetColor helpers.
	Color PeerColor
	// ProfileColor field of Channel.
	//
	// Use SetProfileColor and GetProfileColor helpers.
	ProfileColor PeerColor
	// EmojiStatus field of Channel.
	//
	// Use SetEmojiStatus and GetEmojiStatus helpers.
	EmojiStatus EmojiStatusClass
	// Level field of Channel.
	//
	// Use SetLevel and GetLevel helpers.
	Level int
}

// ChannelTypeID is TL type id of Channel.
const ChannelTypeID = 0xaadfc8f

// construct implements constructor of ChatClass.
func ( Channel) () ChatClass { return & }

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

	_ ChatClass = &Channel{}
)

func ( *Channel) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Creator == false) {
		return false
	}
	if !(.Left == false) {
		return false
	}
	if !(.Broadcast == false) {
		return false
	}
	if !(.Verified == false) {
		return false
	}
	if !(.Megagroup == false) {
		return false
	}
	if !(.Restricted == false) {
		return false
	}
	if !(.Signatures == false) {
		return false
	}
	if !(.Min == false) {
		return false
	}
	if !(.Scam == false) {
		return false
	}
	if !(.HasLink == false) {
		return false
	}
	if !(.HasGeo == false) {
		return false
	}
	if !(.SlowmodeEnabled == false) {
		return false
	}
	if !(.CallActive == false) {
		return false
	}
	if !(.CallNotEmpty == false) {
		return false
	}
	if !(.Fake == false) {
		return false
	}
	if !(.Gigagroup == false) {
		return false
	}
	if !(.Noforwards == false) {
		return false
	}
	if !(.JoinToSend == false) {
		return false
	}
	if !(.JoinRequest == false) {
		return false
	}
	if !(.Forum == false) {
		return false
	}
	if !(.Flags2.Zero()) {
		return false
	}
	if !(.StoriesHidden == false) {
		return false
	}
	if !(.StoriesHiddenMin == false) {
		return false
	}
	if !(.StoriesUnavailable == false) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.AccessHash == 0) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.Username == "") {
		return false
	}
	if !(.Photo == nil) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.RestrictionReason == nil) {
		return false
	}
	if !(.AdminRights.Zero()) {
		return false
	}
	if !(.BannedRights.Zero()) {
		return false
	}
	if !(.DefaultBannedRights.Zero()) {
		return false
	}
	if !(.ParticipantsCount == 0) {
		return false
	}
	if !(.Usernames == nil) {
		return false
	}
	if !(.StoriesMaxID == 0) {
		return false
	}
	if !(.Color.Zero()) {
		return false
	}
	if !(.ProfileColor.Zero()) {
		return false
	}
	if !(.EmojiStatus == nil) {
		return false
	}
	if !(.Level == 0) {
		return false
	}

	return true
}

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

// FillFrom fills Channel from given interface.
func ( *Channel) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( int64)
	() ( int64,  bool)
	() ( string)
	() ( string,  bool)
	() ( ChatPhotoClass)
	() ( int)
	() ( []RestrictionReason,  bool)
	() ( ChatAdminRights,  bool)
	() ( ChatBannedRights,  bool)
	() ( ChatBannedRights,  bool)
	() ( int,  bool)
	() ( []Username,  bool)
	() ( int,  bool)
	() ( PeerColor,  bool)
	() ( PeerColor,  bool)
	() ( EmojiStatusClass,  bool)
	() ( int,  bool)
}) {
	.Creator = .()
	.Left = .()
	.Broadcast = .()
	.Verified = .()
	.Megagroup = .()
	.Restricted = .()
	.Signatures = .()
	.Min = .()
	.Scam = .()
	.HasLink = .()
	.HasGeo = .()
	.SlowmodeEnabled = .()
	.CallActive = .()
	.CallNotEmpty = .()
	.Fake = .()
	.Gigagroup = .()
	.Noforwards = .()
	.JoinToSend = .()
	.JoinRequest = .()
	.Forum = .()
	.StoriesHidden = .()
	.StoriesHiddenMin = .()
	.StoriesUnavailable = .()
	.ID = .()
	if ,  := .();  {
		.AccessHash = 
	}

	.Title = .()
	if ,  := .();  {
		.Username = 
	}

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

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

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

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

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

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

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

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

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

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

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

}

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

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

// TypeInfo returns info about TL type.
func ( *Channel) () tdp.Type {
	 := tdp.Type{
		Name: "channel",
		ID:   ChannelTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Creator",
			SchemaName: "creator",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Left",
			SchemaName: "left",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Broadcast",
			SchemaName: "broadcast",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "Verified",
			SchemaName: "verified",
			Null:       !.Flags.Has(7),
		},
		{
			Name:       "Megagroup",
			SchemaName: "megagroup",
			Null:       !.Flags.Has(8),
		},
		{
			Name:       "Restricted",
			SchemaName: "restricted",
			Null:       !.Flags.Has(9),
		},
		{
			Name:       "Signatures",
			SchemaName: "signatures",
			Null:       !.Flags.Has(11),
		},
		{
			Name:       "Min",
			SchemaName: "min",
			Null:       !.Flags.Has(12),
		},
		{
			Name:       "Scam",
			SchemaName: "scam",
			Null:       !.Flags.Has(19),
		},
		{
			Name:       "HasLink",
			SchemaName: "has_link",
			Null:       !.Flags.Has(20),
		},
		{
			Name:       "HasGeo",
			SchemaName: "has_geo",
			Null:       !.Flags.Has(21),
		},
		{
			Name:       "SlowmodeEnabled",
			SchemaName: "slowmode_enabled",
			Null:       !.Flags.Has(22),
		},
		{
			Name:       "CallActive",
			SchemaName: "call_active",
			Null:       !.Flags.Has(23),
		},
		{
			Name:       "CallNotEmpty",
			SchemaName: "call_not_empty",
			Null:       !.Flags.Has(24),
		},
		{
			Name:       "Fake",
			SchemaName: "fake",
			Null:       !.Flags.Has(25),
		},
		{
			Name:       "Gigagroup",
			SchemaName: "gigagroup",
			Null:       !.Flags.Has(26),
		},
		{
			Name:       "Noforwards",
			SchemaName: "noforwards",
			Null:       !.Flags.Has(27),
		},
		{
			Name:       "JoinToSend",
			SchemaName: "join_to_send",
			Null:       !.Flags.Has(28),
		},
		{
			Name:       "JoinRequest",
			SchemaName: "join_request",
			Null:       !.Flags.Has(29),
		},
		{
			Name:       "Forum",
			SchemaName: "forum",
			Null:       !.Flags.Has(30),
		},
		{
			Name:       "StoriesHidden",
			SchemaName: "stories_hidden",
			Null:       !.Flags2.Has(1),
		},
		{
			Name:       "StoriesHiddenMin",
			SchemaName: "stories_hidden_min",
			Null:       !.Flags2.Has(2),
		},
		{
			Name:       "StoriesUnavailable",
			SchemaName: "stories_unavailable",
			Null:       !.Flags2.Has(3),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "AccessHash",
			SchemaName: "access_hash",
			Null:       !.Flags.Has(13),
		},
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "Username",
			SchemaName: "username",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "Photo",
			SchemaName: "photo",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "RestrictionReason",
			SchemaName: "restriction_reason",
			Null:       !.Flags.Has(9),
		},
		{
			Name:       "AdminRights",
			SchemaName: "admin_rights",
			Null:       !.Flags.Has(14),
		},
		{
			Name:       "BannedRights",
			SchemaName: "banned_rights",
			Null:       !.Flags.Has(15),
		},
		{
			Name:       "DefaultBannedRights",
			SchemaName: "default_banned_rights",
			Null:       !.Flags.Has(18),
		},
		{
			Name:       "ParticipantsCount",
			SchemaName: "participants_count",
			Null:       !.Flags.Has(17),
		},
		{
			Name:       "Usernames",
			SchemaName: "usernames",
			Null:       !.Flags2.Has(0),
		},
		{
			Name:       "StoriesMaxID",
			SchemaName: "stories_max_id",
			Null:       !.Flags2.Has(4),
		},
		{
			Name:       "Color",
			SchemaName: "color",
			Null:       !.Flags2.Has(7),
		},
		{
			Name:       "ProfileColor",
			SchemaName: "profile_color",
			Null:       !.Flags2.Has(8),
		},
		{
			Name:       "EmojiStatus",
			SchemaName: "emoji_status",
			Null:       !.Flags2.Has(9),
		},
		{
			Name:       "Level",
			SchemaName: "level",
			Null:       !.Flags2.Has(10),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *Channel) () {
	if !(.Creator == false) {
		.Flags.Set(0)
	}
	if !(.Left == false) {
		.Flags.Set(2)
	}
	if !(.Broadcast == false) {
		.Flags.Set(5)
	}
	if !(.Verified == false) {
		.Flags.Set(7)
	}
	if !(.Megagroup == false) {
		.Flags.Set(8)
	}
	if !(.Restricted == false) {
		.Flags.Set(9)
	}
	if !(.Signatures == false) {
		.Flags.Set(11)
	}
	if !(.Min == false) {
		.Flags.Set(12)
	}
	if !(.Scam == false) {
		.Flags.Set(19)
	}
	if !(.HasLink == false) {
		.Flags.Set(20)
	}
	if !(.HasGeo == false) {
		.Flags.Set(21)
	}
	if !(.SlowmodeEnabled == false) {
		.Flags.Set(22)
	}
	if !(.CallActive == false) {
		.Flags.Set(23)
	}
	if !(.CallNotEmpty == false) {
		.Flags.Set(24)
	}
	if !(.Fake == false) {
		.Flags.Set(25)
	}
	if !(.Gigagroup == false) {
		.Flags.Set(26)
	}
	if !(.Noforwards == false) {
		.Flags.Set(27)
	}
	if !(.JoinToSend == false) {
		.Flags.Set(28)
	}
	if !(.JoinRequest == false) {
		.Flags.Set(29)
	}
	if !(.Forum == false) {
		.Flags.Set(30)
	}
	if !(.StoriesHidden == false) {
		.Flags2.Set(1)
	}
	if !(.StoriesHiddenMin == false) {
		.Flags2.Set(2)
	}
	if !(.StoriesUnavailable == false) {
		.Flags2.Set(3)
	}
	if !(.AccessHash == 0) {
		.Flags.Set(13)
	}
	if !(.Username == "") {
		.Flags.Set(6)
	}
	if !(.RestrictionReason == nil) {
		.Flags.Set(9)
	}
	if !(.AdminRights.Zero()) {
		.Flags.Set(14)
	}
	if !(.BannedRights.Zero()) {
		.Flags.Set(15)
	}
	if !(.DefaultBannedRights.Zero()) {
		.Flags.Set(18)
	}
	if !(.ParticipantsCount == 0) {
		.Flags.Set(17)
	}
	if !(.Usernames == nil) {
		.Flags2.Set(0)
	}
	if !(.StoriesMaxID == 0) {
		.Flags2.Set(4)
	}
	if !(.Color.Zero()) {
		.Flags2.Set(7)
	}
	if !(.ProfileColor.Zero()) {
		.Flags2.Set(8)
	}
	if !(.EmojiStatus == nil) {
		.Flags2.Set(9)
	}
	if !(.Level == 0) {
		.Flags2.Set(10)
	}
}

// Encode implements bin.Encoder.
func ( *Channel) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channel#aadfc8f as nil")
	}
	.PutID(ChannelTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *Channel) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channel#aadfc8f as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode channel#aadfc8f: field flags: %w", )
	}
	if  := .Flags2.Encode();  != nil {
		return fmt.Errorf("unable to encode channel#aadfc8f: field flags2: %w", )
	}
	.PutLong(.ID)
	if .Flags.Has(13) {
		.PutLong(.AccessHash)
	}
	.PutString(.Title)
	if .Flags.Has(6) {
		.PutString(.Username)
	}
	if .Photo == nil {
		return fmt.Errorf("unable to encode channel#aadfc8f: field photo is nil")
	}
	if  := .Photo.Encode();  != nil {
		return fmt.Errorf("unable to encode channel#aadfc8f: field photo: %w", )
	}
	.PutInt(.Date)
	if .Flags.Has(9) {
		.PutVectorHeader(len(.RestrictionReason))
		for ,  := range .RestrictionReason {
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode channel#aadfc8f: field restriction_reason element with index %d: %w", , )
			}
		}
	}
	if .Flags.Has(14) {
		if  := .AdminRights.Encode();  != nil {
			return fmt.Errorf("unable to encode channel#aadfc8f: field admin_rights: %w", )
		}
	}
	if .Flags.Has(15) {
		if  := .BannedRights.Encode();  != nil {
			return fmt.Errorf("unable to encode channel#aadfc8f: field banned_rights: %w", )
		}
	}
	if .Flags.Has(18) {
		if  := .DefaultBannedRights.Encode();  != nil {
			return fmt.Errorf("unable to encode channel#aadfc8f: field default_banned_rights: %w", )
		}
	}
	if .Flags.Has(17) {
		.PutInt(.ParticipantsCount)
	}
	if .Flags2.Has(0) {
		.PutVectorHeader(len(.Usernames))
		for ,  := range .Usernames {
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode channel#aadfc8f: field usernames element with index %d: %w", , )
			}
		}
	}
	if .Flags2.Has(4) {
		.PutInt(.StoriesMaxID)
	}
	if .Flags2.Has(7) {
		if  := .Color.Encode();  != nil {
			return fmt.Errorf("unable to encode channel#aadfc8f: field color: %w", )
		}
	}
	if .Flags2.Has(8) {
		if  := .ProfileColor.Encode();  != nil {
			return fmt.Errorf("unable to encode channel#aadfc8f: field profile_color: %w", )
		}
	}
	if .Flags2.Has(9) {
		if .EmojiStatus == nil {
			return fmt.Errorf("unable to encode channel#aadfc8f: field emoji_status is nil")
		}
		if  := .EmojiStatus.Encode();  != nil {
			return fmt.Errorf("unable to encode channel#aadfc8f: field emoji_status: %w", )
		}
	}
	if .Flags2.Has(10) {
		.PutInt(.Level)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *Channel) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channel#aadfc8f to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode channel#aadfc8f: field flags: %w", )
		}
	}
	.Creator = .Flags.Has(0)
	.Left = .Flags.Has(2)
	.Broadcast = .Flags.Has(5)
	.Verified = .Flags.Has(7)
	.Megagroup = .Flags.Has(8)
	.Restricted = .Flags.Has(9)
	.Signatures = .Flags.Has(11)
	.Min = .Flags.Has(12)
	.Scam = .Flags.Has(19)
	.HasLink = .Flags.Has(20)
	.HasGeo = .Flags.Has(21)
	.SlowmodeEnabled = .Flags.Has(22)
	.CallActive = .Flags.Has(23)
	.CallNotEmpty = .Flags.Has(24)
	.Fake = .Flags.Has(25)
	.Gigagroup = .Flags.Has(26)
	.Noforwards = .Flags.Has(27)
	.JoinToSend = .Flags.Has(28)
	.JoinRequest = .Flags.Has(29)
	.Forum = .Flags.Has(30)
	{
		if  := .Flags2.Decode();  != nil {
			return fmt.Errorf("unable to decode channel#aadfc8f: field flags2: %w", )
		}
	}
	.StoriesHidden = .Flags2.Has(1)
	.StoriesHiddenMin = .Flags2.Has(2)
	.StoriesUnavailable = .Flags2.Has(3)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode channel#aadfc8f: field id: %w", )
		}
		.ID = 
	}
	if .Flags.Has(13) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode channel#aadfc8f: field access_hash: %w", )
		}
		.AccessHash = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode channel#aadfc8f: field title: %w", )
		}
		.Title = 
	}
	if .Flags.Has(6) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode channel#aadfc8f: field username: %w", )
		}
		.Username = 
	}
	{
		,  := DecodeChatPhoto()
		if  != nil {
			return fmt.Errorf("unable to decode channel#aadfc8f: field photo: %w", )
		}
		.Photo = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channel#aadfc8f: field date: %w", )
		}
		.Date = 
	}
	if .Flags.Has(9) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode channel#aadfc8f: field restriction_reason: %w", )
		}

		if  > 0 {
			.RestrictionReason = make([]RestrictionReason, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  RestrictionReason
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode channel#aadfc8f: field restriction_reason: %w", )
			}
			.RestrictionReason = append(.RestrictionReason, )
		}
	}
	if .Flags.Has(14) {
		if  := .AdminRights.Decode();  != nil {
			return fmt.Errorf("unable to decode channel#aadfc8f: field admin_rights: %w", )
		}
	}
	if .Flags.Has(15) {
		if  := .BannedRights.Decode();  != nil {
			return fmt.Errorf("unable to decode channel#aadfc8f: field banned_rights: %w", )
		}
	}
	if .Flags.Has(18) {
		if  := .DefaultBannedRights.Decode();  != nil {
			return fmt.Errorf("unable to decode channel#aadfc8f: field default_banned_rights: %w", )
		}
	}
	if .Flags.Has(17) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channel#aadfc8f: field participants_count: %w", )
		}
		.ParticipantsCount = 
	}
	if .Flags2.Has(0) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode channel#aadfc8f: field usernames: %w", )
		}

		if  > 0 {
			.Usernames = make([]Username, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  Username
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode channel#aadfc8f: field usernames: %w", )
			}
			.Usernames = append(.Usernames, )
		}
	}
	if .Flags2.Has(4) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channel#aadfc8f: field stories_max_id: %w", )
		}
		.StoriesMaxID = 
	}
	if .Flags2.Has(7) {
		if  := .Color.Decode();  != nil {
			return fmt.Errorf("unable to decode channel#aadfc8f: field color: %w", )
		}
	}
	if .Flags2.Has(8) {
		if  := .ProfileColor.Decode();  != nil {
			return fmt.Errorf("unable to decode channel#aadfc8f: field profile_color: %w", )
		}
	}
	if .Flags2.Has(9) {
		,  := DecodeEmojiStatus()
		if  != nil {
			return fmt.Errorf("unable to decode channel#aadfc8f: field emoji_status: %w", )
		}
		.EmojiStatus = 
	}
	if .Flags2.Has(10) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channel#aadfc8f: field level: %w", )
		}
		.Level = 
	}
	return nil
}

// SetCreator sets value of Creator conditional field.
func ( *Channel) ( bool) {
	if  {
		.Flags.Set(0)
		.Creator = true
	} else {
		.Flags.Unset(0)
		.Creator = false
	}
}

// GetCreator returns value of Creator conditional field.
func ( *Channel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetLeft sets value of Left conditional field.
func ( *Channel) ( bool) {
	if  {
		.Flags.Set(2)
		.Left = true
	} else {
		.Flags.Unset(2)
		.Left = false
	}
}

// GetLeft returns value of Left conditional field.
func ( *Channel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// SetBroadcast sets value of Broadcast conditional field.
func ( *Channel) ( bool) {
	if  {
		.Flags.Set(5)
		.Broadcast = true
	} else {
		.Flags.Unset(5)
		.Broadcast = false
	}
}

// GetBroadcast returns value of Broadcast conditional field.
func ( *Channel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(5)
}

// SetVerified sets value of Verified conditional field.
func ( *Channel) ( bool) {
	if  {
		.Flags.Set(7)
		.Verified = true
	} else {
		.Flags.Unset(7)
		.Verified = false
	}
}

// GetVerified returns value of Verified conditional field.
func ( *Channel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(7)
}

// SetMegagroup sets value of Megagroup conditional field.
func ( *Channel) ( bool) {
	if  {
		.Flags.Set(8)
		.Megagroup = true
	} else {
		.Flags.Unset(8)
		.Megagroup = false
	}
}

// GetMegagroup returns value of Megagroup conditional field.
func ( *Channel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(8)
}

// SetRestricted sets value of Restricted conditional field.
func ( *Channel) ( bool) {
	if  {
		.Flags.Set(9)
		.Restricted = true
	} else {
		.Flags.Unset(9)
		.Restricted = false
	}
}

// GetRestricted returns value of Restricted conditional field.
func ( *Channel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(9)
}

// SetSignatures sets value of Signatures conditional field.
func ( *Channel) ( bool) {
	if  {
		.Flags.Set(11)
		.Signatures = true
	} else {
		.Flags.Unset(11)
		.Signatures = false
	}
}

// GetSignatures returns value of Signatures conditional field.
func ( *Channel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(11)
}

// SetMin sets value of Min conditional field.
func ( *Channel) ( bool) {
	if  {
		.Flags.Set(12)
		.Min = true
	} else {
		.Flags.Unset(12)
		.Min = false
	}
}

// GetMin returns value of Min conditional field.
func ( *Channel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(12)
}

// SetScam sets value of Scam conditional field.
func ( *Channel) ( bool) {
	if  {
		.Flags.Set(19)
		.Scam = true
	} else {
		.Flags.Unset(19)
		.Scam = false
	}
}

// GetScam returns value of Scam conditional field.
func ( *Channel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(19)
}

// SetHasLink sets value of HasLink conditional field.
func ( *Channel) ( bool) {
	if  {
		.Flags.Set(20)
		.HasLink = true
	} else {
		.Flags.Unset(20)
		.HasLink = false
	}
}

// GetHasLink returns value of HasLink conditional field.
func ( *Channel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(20)
}

// SetHasGeo sets value of HasGeo conditional field.
func ( *Channel) ( bool) {
	if  {
		.Flags.Set(21)
		.HasGeo = true
	} else {
		.Flags.Unset(21)
		.HasGeo = false
	}
}

// GetHasGeo returns value of HasGeo conditional field.
func ( *Channel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(21)
}

// SetSlowmodeEnabled sets value of SlowmodeEnabled conditional field.
func ( *Channel) ( bool) {
	if  {
		.Flags.Set(22)
		.SlowmodeEnabled = true
	} else {
		.Flags.Unset(22)
		.SlowmodeEnabled = false
	}
}

// GetSlowmodeEnabled returns value of SlowmodeEnabled conditional field.
func ( *Channel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(22)
}

// SetCallActive sets value of CallActive conditional field.
func ( *Channel) ( bool) {
	if  {
		.Flags.Set(23)
		.CallActive = true
	} else {
		.Flags.Unset(23)
		.CallActive = false
	}
}

// GetCallActive returns value of CallActive conditional field.
func ( *Channel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(23)
}

// SetCallNotEmpty sets value of CallNotEmpty conditional field.
func ( *Channel) ( bool) {
	if  {
		.Flags.Set(24)
		.CallNotEmpty = true
	} else {
		.Flags.Unset(24)
		.CallNotEmpty = false
	}
}

// GetCallNotEmpty returns value of CallNotEmpty conditional field.
func ( *Channel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(24)
}

// SetFake sets value of Fake conditional field.
func ( *Channel) ( bool) {
	if  {
		.Flags.Set(25)
		.Fake = true
	} else {
		.Flags.Unset(25)
		.Fake = false
	}
}

// GetFake returns value of Fake conditional field.
func ( *Channel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(25)
}

// SetGigagroup sets value of Gigagroup conditional field.
func ( *Channel) ( bool) {
	if  {
		.Flags.Set(26)
		.Gigagroup = true
	} else {
		.Flags.Unset(26)
		.Gigagroup = false
	}
}

// GetGigagroup returns value of Gigagroup conditional field.
func ( *Channel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(26)
}

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

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

// SetJoinToSend sets value of JoinToSend conditional field.
func ( *Channel) ( bool) {
	if  {
		.Flags.Set(28)
		.JoinToSend = true
	} else {
		.Flags.Unset(28)
		.JoinToSend = false
	}
}

// GetJoinToSend returns value of JoinToSend conditional field.
func ( *Channel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(28)
}

// SetJoinRequest sets value of JoinRequest conditional field.
func ( *Channel) ( bool) {
	if  {
		.Flags.Set(29)
		.JoinRequest = true
	} else {
		.Flags.Unset(29)
		.JoinRequest = false
	}
}

// GetJoinRequest returns value of JoinRequest conditional field.
func ( *Channel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(29)
}

// SetForum sets value of Forum conditional field.
func ( *Channel) ( bool) {
	if  {
		.Flags.Set(30)
		.Forum = true
	} else {
		.Flags.Unset(30)
		.Forum = false
	}
}

// GetForum returns value of Forum conditional field.
func ( *Channel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(30)
}

// SetStoriesHidden sets value of StoriesHidden conditional field.
func ( *Channel) ( bool) {
	if  {
		.Flags2.Set(1)
		.StoriesHidden = true
	} else {
		.Flags2.Unset(1)
		.StoriesHidden = false
	}
}

// GetStoriesHidden returns value of StoriesHidden conditional field.
func ( *Channel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags2.Has(1)
}

// SetStoriesHiddenMin sets value of StoriesHiddenMin conditional field.
func ( *Channel) ( bool) {
	if  {
		.Flags2.Set(2)
		.StoriesHiddenMin = true
	} else {
		.Flags2.Unset(2)
		.StoriesHiddenMin = false
	}
}

// GetStoriesHiddenMin returns value of StoriesHiddenMin conditional field.
func ( *Channel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags2.Has(2)
}

// SetStoriesUnavailable sets value of StoriesUnavailable conditional field.
func ( *Channel) ( bool) {
	if  {
		.Flags2.Set(3)
		.StoriesUnavailable = true
	} else {
		.Flags2.Unset(3)
		.StoriesUnavailable = false
	}
}

// GetStoriesUnavailable returns value of StoriesUnavailable conditional field.
func ( *Channel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags2.Has(3)
}

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

// SetAccessHash sets value of AccessHash conditional field.
func ( *Channel) ( int64) {
	.Flags.Set(13)
	.AccessHash = 
}

// GetAccessHash returns value of AccessHash conditional field and
// boolean which is true if field was set.
func ( *Channel) () ( int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(13) {
		return , false
	}
	return .AccessHash, true
}

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

// SetUsername sets value of Username conditional field.
func ( *Channel) ( string) {
	.Flags.Set(6)
	.Username = 
}

// GetUsername returns value of Username conditional field and
// boolean which is true if field was set.
func ( *Channel) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(6) {
		return , false
	}
	return .Username, true
}

// GetPhoto returns value of Photo field.
func ( *Channel) () ( ChatPhotoClass) {
	if  == nil {
		return
	}
	return .Photo
}

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

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

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

// SetAdminRights sets value of AdminRights conditional field.
func ( *Channel) ( ChatAdminRights) {
	.Flags.Set(14)
	.AdminRights = 
}

// GetAdminRights returns value of AdminRights conditional field and
// boolean which is true if field was set.
func ( *Channel) () ( ChatAdminRights,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(14) {
		return , false
	}
	return .AdminRights, true
}

// SetBannedRights sets value of BannedRights conditional field.
func ( *Channel) ( ChatBannedRights) {
	.Flags.Set(15)
	.BannedRights = 
}

// GetBannedRights returns value of BannedRights conditional field and
// boolean which is true if field was set.
func ( *Channel) () ( ChatBannedRights,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(15) {
		return , false
	}
	return .BannedRights, true
}

// SetDefaultBannedRights sets value of DefaultBannedRights conditional field.
func ( *Channel) ( ChatBannedRights) {
	.Flags.Set(18)
	.DefaultBannedRights = 
}

// GetDefaultBannedRights returns value of DefaultBannedRights conditional field and
// boolean which is true if field was set.
func ( *Channel) () ( ChatBannedRights,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(18) {
		return , false
	}
	return .DefaultBannedRights, true
}

// SetParticipantsCount sets value of ParticipantsCount conditional field.
func ( *Channel) ( int) {
	.Flags.Set(17)
	.ParticipantsCount = 
}

// GetParticipantsCount returns value of ParticipantsCount conditional field and
// boolean which is true if field was set.
func ( *Channel) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(17) {
		return , false
	}
	return .ParticipantsCount, true
}

// SetUsernames sets value of Usernames conditional field.
func ( *Channel) ( []Username) {
	.Flags2.Set(0)
	.Usernames = 
}

// GetUsernames returns value of Usernames conditional field and
// boolean which is true if field was set.
func ( *Channel) () ( []Username,  bool) {
	if  == nil {
		return
	}
	if !.Flags2.Has(0) {
		return , false
	}
	return .Usernames, true
}

// SetStoriesMaxID sets value of StoriesMaxID conditional field.
func ( *Channel) ( int) {
	.Flags2.Set(4)
	.StoriesMaxID = 
}

// GetStoriesMaxID returns value of StoriesMaxID conditional field and
// boolean which is true if field was set.
func ( *Channel) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags2.Has(4) {
		return , false
	}
	return .StoriesMaxID, true
}

// SetColor sets value of Color conditional field.
func ( *Channel) ( PeerColor) {
	.Flags2.Set(7)
	.Color = 
}

// GetColor returns value of Color conditional field and
// boolean which is true if field was set.
func ( *Channel) () ( PeerColor,  bool) {
	if  == nil {
		return
	}
	if !.Flags2.Has(7) {
		return , false
	}
	return .Color, true
}

// SetProfileColor sets value of ProfileColor conditional field.
func ( *Channel) ( PeerColor) {
	.Flags2.Set(8)
	.ProfileColor = 
}

// GetProfileColor returns value of ProfileColor conditional field and
// boolean which is true if field was set.
func ( *Channel) () ( PeerColor,  bool) {
	if  == nil {
		return
	}
	if !.Flags2.Has(8) {
		return , false
	}
	return .ProfileColor, true
}

// SetEmojiStatus sets value of EmojiStatus conditional field.
func ( *Channel) ( EmojiStatusClass) {
	.Flags2.Set(9)
	.EmojiStatus = 
}

// GetEmojiStatus returns value of EmojiStatus conditional field and
// boolean which is true if field was set.
func ( *Channel) () ( EmojiStatusClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags2.Has(9) {
		return , false
	}
	return .EmojiStatus, true
}

// SetLevel sets value of Level conditional field.
func ( *Channel) ( int) {
	.Flags2.Set(10)
	.Level = 
}

// GetLevel returns value of Level conditional field and
// boolean which is true if field was set.
func ( *Channel) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags2.Has(10) {
		return , false
	}
	return .Level, true
}

// ChannelForbidden represents TL type `channelForbidden#17d493d5`.
// Indicates a channel/supergroup we can't access because we were banned, or for some
// other reason.
//
// See https://core.telegram.org/constructor/channelForbidden for reference.
type ChannelForbidden struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Is this a channel
	Broadcast bool
	// Is this a supergroup
	Megagroup bool
	// Channel ID
	ID int64
	// Access hash
	AccessHash int64
	// Title
	Title string
	// The ban is valid until the specified date
	//
	// Use SetUntilDate and GetUntilDate helpers.
	UntilDate int
}

// ChannelForbiddenTypeID is TL type id of ChannelForbidden.
const ChannelForbiddenTypeID = 0x17d493d5

// construct implements constructor of ChatClass.
func ( ChannelForbidden) () ChatClass { return & }

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

	_ ChatClass = &ChannelForbidden{}
)

func ( *ChannelForbidden) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Broadcast == false) {
		return false
	}
	if !(.Megagroup == false) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.AccessHash == 0) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.UntilDate == 0) {
		return false
	}

	return true
}

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

// FillFrom fills ChannelForbidden from given interface.
func ( *ChannelForbidden) ( interface {
	() ( bool)
	() ( bool)
	() ( int64)
	() ( int64)
	() ( string)
	() ( int,  bool)
}) {
	.Broadcast = .()
	.Megagroup = .()
	.ID = .()
	.AccessHash = .()
	.Title = .()
	if ,  := .();  {
		.UntilDate = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelForbidden) () tdp.Type {
	 := tdp.Type{
		Name: "channelForbidden",
		ID:   ChannelForbiddenTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Broadcast",
			SchemaName: "broadcast",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "Megagroup",
			SchemaName: "megagroup",
			Null:       !.Flags.Has(8),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "AccessHash",
			SchemaName: "access_hash",
		},
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "UntilDate",
			SchemaName: "until_date",
			Null:       !.Flags.Has(16),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ChannelForbidden) () {
	if !(.Broadcast == false) {
		.Flags.Set(5)
	}
	if !(.Megagroup == false) {
		.Flags.Set(8)
	}
	if !(.UntilDate == 0) {
		.Flags.Set(16)
	}
}

// Encode implements bin.Encoder.
func ( *ChannelForbidden) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channelForbidden#17d493d5 as nil")
	}
	.PutID(ChannelForbiddenTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelForbidden) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channelForbidden#17d493d5 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode channelForbidden#17d493d5: field flags: %w", )
	}
	.PutLong(.ID)
	.PutLong(.AccessHash)
	.PutString(.Title)
	if .Flags.Has(16) {
		.PutInt(.UntilDate)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *ChannelForbidden) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channelForbidden#17d493d5 to nil")
	}
	if  := .ConsumeID(ChannelForbiddenTypeID);  != nil {
		return fmt.Errorf("unable to decode channelForbidden#17d493d5: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ChannelForbidden) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channelForbidden#17d493d5 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode channelForbidden#17d493d5: field flags: %w", )
		}
	}
	.Broadcast = .Flags.Has(5)
	.Megagroup = .Flags.Has(8)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode channelForbidden#17d493d5: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode channelForbidden#17d493d5: field access_hash: %w", )
		}
		.AccessHash = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode channelForbidden#17d493d5: field title: %w", )
		}
		.Title = 
	}
	if .Flags.Has(16) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channelForbidden#17d493d5: field until_date: %w", )
		}
		.UntilDate = 
	}
	return nil
}

// SetBroadcast sets value of Broadcast conditional field.
func ( *ChannelForbidden) ( bool) {
	if  {
		.Flags.Set(5)
		.Broadcast = true
	} else {
		.Flags.Unset(5)
		.Broadcast = false
	}
}

// GetBroadcast returns value of Broadcast conditional field.
func ( *ChannelForbidden) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(5)
}

// SetMegagroup sets value of Megagroup conditional field.
func ( *ChannelForbidden) ( bool) {
	if  {
		.Flags.Set(8)
		.Megagroup = true
	} else {
		.Flags.Unset(8)
		.Megagroup = false
	}
}

// GetMegagroup returns value of Megagroup conditional field.
func ( *ChannelForbidden) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(8)
}

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

// GetAccessHash returns value of AccessHash field.
func ( *ChannelForbidden) () ( int64) {
	if  == nil {
		return
	}
	return .AccessHash
}

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

// SetUntilDate sets value of UntilDate conditional field.
func ( *ChannelForbidden) ( int) {
	.Flags.Set(16)
	.UntilDate = 
}

// GetUntilDate returns value of UntilDate conditional field and
// boolean which is true if field was set.
func ( *ChannelForbidden) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(16) {
		return , false
	}
	return .UntilDate, true
}

// ChatClassName is schema name of ChatClass.
const ChatClassName = "Chat"

// ChatClass represents Chat generic type.
//
// See https://core.telegram.org/type/Chat for reference.
//
// Example:
//
//	g, err := tg.DecodeChat(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.ChatEmpty: // chatEmpty#29562865
//	case *tg.Chat: // chat#41cbf256
//	case *tg.ChatForbidden: // chatForbidden#6592a1a7
//	case *tg.Channel: // channel#aadfc8f
//	case *tg.ChannelForbidden: // channelForbidden#17d493d5
//	default: panic(v)
//	}
type ChatClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() ChatClass

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

	// Group identifier
	GetID() (value int64)

	// AsNotEmpty tries to map ChatClass to NotEmptyChat.
	AsNotEmpty() (NotEmptyChat, bool)
	// AsNotForbidden tries to map ChatClass to NotForbiddenChat.
	AsNotForbidden() (NotForbiddenChat, bool)
	// AsFull tries to map ChatClass to FullChat.
	AsFull() (FullChat, bool)
}

// AsInputPeer tries to map Chat to InputPeerChat.
func ( *Chat) () *InputPeerChat {
	 := new(InputPeerChat)
	.ChatID = .GetID()

	return 
}

// AsInputPeer tries to map Channel to InputPeerChannel.
func ( *Channel) () *InputPeerChannel {
	 := new(InputPeerChannel)
	.ChannelID = .GetID()
	if ,  := .GetAccessHash();  {
		.AccessHash = 
	}

	return 
}

// AsInput tries to map Channel to InputChannel.
func ( *Channel) () *InputChannel {
	 := new(InputChannel)
	.ChannelID = .GetID()
	if ,  := .GetAccessHash();  {
		.AccessHash = 
	}

	return 
}

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

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

	// ID of the group
	GetID() (value int64)

	// Title
	GetTitle() (value string)
}

// AsNotEmpty tries to map ChatEmpty to NotEmptyChat.
func ( *ChatEmpty) () (NotEmptyChat, bool) {
	,  := (ChatClass()).(NotEmptyChat)
	return , 
}

// AsNotEmpty tries to map Chat to NotEmptyChat.
func ( *Chat) () (NotEmptyChat, bool) {
	,  := (ChatClass()).(NotEmptyChat)
	return , 
}

// AsNotEmpty tries to map ChatForbidden to NotEmptyChat.
func ( *ChatForbidden) () (NotEmptyChat, bool) {
	,  := (ChatClass()).(NotEmptyChat)
	return , 
}

// AsNotEmpty tries to map Channel to NotEmptyChat.
func ( *Channel) () (NotEmptyChat, bool) {
	,  := (ChatClass()).(NotEmptyChat)
	return , 
}

// AsNotEmpty tries to map ChannelForbidden to NotEmptyChat.
func ( *ChannelForbidden) () (NotEmptyChat, bool) {
	,  := (ChatClass()).(NotEmptyChat)
	return , 
}

// NotForbiddenChat represents NotForbidden subset of ChatClass.
type NotForbiddenChat interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() ChatClass

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

	// Group identifier
	GetID() (value int64)
}

// AsNotForbidden tries to map ChatEmpty to NotForbiddenChat.
func ( *ChatEmpty) () (NotForbiddenChat, bool) {
	,  := (ChatClass()).(NotForbiddenChat)
	return , 
}

// AsNotForbidden tries to map Chat to NotForbiddenChat.
func ( *Chat) () (NotForbiddenChat, bool) {
	,  := (ChatClass()).(NotForbiddenChat)
	return , 
}

// AsNotForbidden tries to map ChatForbidden to NotForbiddenChat.
func ( *ChatForbidden) () (NotForbiddenChat, bool) {
	,  := (ChatClass()).(NotForbiddenChat)
	return , 
}

// AsNotForbidden tries to map Channel to NotForbiddenChat.
func ( *Channel) () (NotForbiddenChat, bool) {
	,  := (ChatClass()).(NotForbiddenChat)
	return , 
}

// AsNotForbidden tries to map ChannelForbidden to NotForbiddenChat.
func ( *ChannelForbidden) () (NotForbiddenChat, bool) {
	,  := (ChatClass()).(NotForbiddenChat)
	return , 
}

// FullChat represents Full subset of ChatClass.
type FullChat interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() ChatClass

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

	// Whether the current user is the creator of the group
	GetCreator() (value bool)

	// Whether the current user has left the group
	GetLeft() (value bool)

	// Whether a group call is currently active
	GetCallActive() (value bool)

	// Whether there's anyone in the group call
	GetCallNotEmpty() (value bool)

	// Whether this group is protected¹, thus does not allow forwarding messages from it
	//
	// Links:
	//  1) https://telegram.org/blog/protected-content-delete-by-date-and-more
	GetNoforwards() (value bool)

	// ID of the group
	GetID() (value int64)

	// Title
	GetTitle() (value string)

	// Chat photo
	GetPhoto() (value ChatPhotoClass)

	// Date of creation of the group
	GetDate() (value int)

	// Admin rights¹ of the user in the group
	//
	// Links:
	//  1) https://core.telegram.org/api/rights
	GetAdminRights() (value ChatAdminRights, ok bool)

	// Default banned rights¹ of all users in the group
	//
	// Links:
	//  1) https://core.telegram.org/api/rights
	GetDefaultBannedRights() (value ChatBannedRights, ok bool)
}

// AsFull tries to map ChatEmpty to FullChat.
func ( *ChatEmpty) () (FullChat, bool) {
	,  := (ChatClass()).(FullChat)
	return , 
}

// AsFull tries to map Chat to FullChat.
func ( *Chat) () (FullChat, bool) {
	,  := (ChatClass()).(FullChat)
	return , 
}

// AsFull tries to map ChatForbidden to FullChat.
func ( *ChatForbidden) () (FullChat, bool) {
	,  := (ChatClass()).(FullChat)
	return , 
}

// AsFull tries to map Channel to FullChat.
func ( *Channel) () (FullChat, bool) {
	,  := (ChatClass()).(FullChat)
	return , 
}

// AsFull tries to map ChannelForbidden to FullChat.
func ( *ChannelForbidden) () (FullChat, bool) {
	,  := (ChatClass()).(FullChat)
	return , 
}

// DecodeChat implements binary de-serialization for ChatClass.
func ( *bin.Buffer) (ChatClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case ChatEmptyTypeID:
		// Decoding chatEmpty#29562865.
		 := ChatEmpty{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ChatClass: %w", )
		}
		return &, nil
	case ChatTypeID:
		// Decoding chat#41cbf256.
		 := Chat{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ChatClass: %w", )
		}
		return &, nil
	case ChatForbiddenTypeID:
		// Decoding chatForbidden#6592a1a7.
		 := ChatForbidden{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ChatClass: %w", )
		}
		return &, nil
	case ChannelTypeID:
		// Decoding channel#aadfc8f.
		 := Channel{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ChatClass: %w", )
		}
		return &, nil
	case ChannelForbiddenTypeID:
		// Decoding channelForbidden#17d493d5.
		 := ChannelForbidden{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ChatClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode ChatClass: %w", bin.NewUnexpectedID())
	}
}

// Chat boxes the ChatClass providing a helper.
type ChatBox struct {
	Chat ChatClass
}

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

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