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

// ChannelParticipant represents TL type `channelParticipant#c00c07c0`.
// Channel/supergroup participant
//
// See https://core.telegram.org/constructor/channelParticipant for reference.
type ChannelParticipant struct {
	// Participant user ID
	UserID int64
	// Date joined
	Date int
}

// ChannelParticipantTypeID is TL type id of ChannelParticipant.
const ChannelParticipantTypeID = 0xc00c07c0

// construct implements constructor of ChannelParticipantClass.
func ( ChannelParticipant) () ChannelParticipantClass { return & }

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

	_ ChannelParticipantClass = &ChannelParticipant{}
)

func ( *ChannelParticipant) () bool {
	if  == nil {
		return true
	}
	if !(.UserID == 0) {
		return false
	}
	if !(.Date == 0) {
		return false
	}

	return true
}

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

// FillFrom fills ChannelParticipant from given interface.
func ( *ChannelParticipant) ( interface {
	() ( int64)
	() ( int)
}) {
	.UserID = .()
	.Date = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelParticipant) () tdp.Type {
	 := tdp.Type{
		Name: "channelParticipant",
		ID:   ChannelParticipantTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChannelParticipant) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channelParticipant#c00c07c0 as nil")
	}
	.PutID(ChannelParticipantTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelParticipant) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channelParticipant#c00c07c0 as nil")
	}
	.PutLong(.UserID)
	.PutInt(.Date)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelParticipant) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channelParticipant#c00c07c0 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode channelParticipant#c00c07c0: field user_id: %w", )
		}
		.UserID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channelParticipant#c00c07c0: field date: %w", )
		}
		.Date = 
	}
	return nil
}

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

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

// ChannelParticipantSelf represents TL type `channelParticipantSelf#35a8bfa7`.
// Myself
//
// See https://core.telegram.org/constructor/channelParticipantSelf for reference.
type ChannelParticipantSelf struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether I joined upon specific approval of an admin
	ViaRequest bool
	// User ID
	UserID int64
	// User that invited me to the channel/supergroup
	InviterID int64
	// When did I join the channel/supergroup
	Date int
}

// ChannelParticipantSelfTypeID is TL type id of ChannelParticipantSelf.
const ChannelParticipantSelfTypeID = 0x35a8bfa7

// construct implements constructor of ChannelParticipantClass.
func ( ChannelParticipantSelf) () ChannelParticipantClass { return & }

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

	_ ChannelParticipantClass = &ChannelParticipantSelf{}
)

func ( *ChannelParticipantSelf) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ViaRequest == false) {
		return false
	}
	if !(.UserID == 0) {
		return false
	}
	if !(.InviterID == 0) {
		return false
	}
	if !(.Date == 0) {
		return false
	}

	return true
}

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

// FillFrom fills ChannelParticipantSelf from given interface.
func ( *ChannelParticipantSelf) ( interface {
	() ( bool)
	() ( int64)
	() ( int64)
	() ( int)
}) {
	.ViaRequest = .()
	.UserID = .()
	.InviterID = .()
	.Date = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelParticipantSelf) () tdp.Type {
	 := tdp.Type{
		Name: "channelParticipantSelf",
		ID:   ChannelParticipantSelfTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ViaRequest",
			SchemaName: "via_request",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "InviterID",
			SchemaName: "inviter_id",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *ChannelParticipantSelf) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channelParticipantSelf#35a8bfa7 as nil")
	}
	.PutID(ChannelParticipantSelfTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelParticipantSelf) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channelParticipantSelf#35a8bfa7 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode channelParticipantSelf#35a8bfa7: field flags: %w", )
	}
	.PutLong(.UserID)
	.PutLong(.InviterID)
	.PutInt(.Date)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelParticipantSelf) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channelParticipantSelf#35a8bfa7 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode channelParticipantSelf#35a8bfa7: field flags: %w", )
		}
	}
	.ViaRequest = .Flags.Has(0)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode channelParticipantSelf#35a8bfa7: field user_id: %w", )
		}
		.UserID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode channelParticipantSelf#35a8bfa7: field inviter_id: %w", )
		}
		.InviterID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channelParticipantSelf#35a8bfa7: field date: %w", )
		}
		.Date = 
	}
	return nil
}

// SetViaRequest sets value of ViaRequest conditional field.
func ( *ChannelParticipantSelf) ( bool) {
	if  {
		.Flags.Set(0)
		.ViaRequest = true
	} else {
		.Flags.Unset(0)
		.ViaRequest = false
	}
}

// GetViaRequest returns value of ViaRequest conditional field.
func ( *ChannelParticipantSelf) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

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

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

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

// ChannelParticipantCreator represents TL type `channelParticipantCreator#2fe601d3`.
// Channel/supergroup creator
//
// See https://core.telegram.org/constructor/channelParticipantCreator for reference.
type ChannelParticipantCreator struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// User ID
	UserID int64
	// Creator admin rights
	AdminRights ChatAdminRights
	// The role (rank) of the group creator in the group: just an arbitrary string, admin by
	// default
	//
	// Use SetRank and GetRank helpers.
	Rank string
}

// ChannelParticipantCreatorTypeID is TL type id of ChannelParticipantCreator.
const ChannelParticipantCreatorTypeID = 0x2fe601d3

// construct implements constructor of ChannelParticipantClass.
func ( ChannelParticipantCreator) () ChannelParticipantClass { return & }

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

	_ ChannelParticipantClass = &ChannelParticipantCreator{}
)

func ( *ChannelParticipantCreator) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.UserID == 0) {
		return false
	}
	if !(.AdminRights.Zero()) {
		return false
	}
	if !(.Rank == "") {
		return false
	}

	return true
}

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

// FillFrom fills ChannelParticipantCreator from given interface.
func ( *ChannelParticipantCreator) ( interface {
	() ( int64)
	() ( ChatAdminRights)
	() ( string,  bool)
}) {
	.UserID = .()
	.AdminRights = .()
	if ,  := .();  {
		.Rank = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelParticipantCreator) () tdp.Type {
	 := tdp.Type{
		Name: "channelParticipantCreator",
		ID:   ChannelParticipantCreatorTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "AdminRights",
			SchemaName: "admin_rights",
		},
		{
			Name:       "Rank",
			SchemaName: "rank",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ChannelParticipantCreator) () {
	if !(.Rank == "") {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *ChannelParticipantCreator) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channelParticipantCreator#2fe601d3 as nil")
	}
	.PutID(ChannelParticipantCreatorTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelParticipantCreator) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channelParticipantCreator#2fe601d3 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode channelParticipantCreator#2fe601d3: field flags: %w", )
	}
	.PutLong(.UserID)
	if  := .AdminRights.Encode();  != nil {
		return fmt.Errorf("unable to encode channelParticipantCreator#2fe601d3: field admin_rights: %w", )
	}
	if .Flags.Has(0) {
		.PutString(.Rank)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelParticipantCreator) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channelParticipantCreator#2fe601d3 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode channelParticipantCreator#2fe601d3: field flags: %w", )
		}
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode channelParticipantCreator#2fe601d3: field user_id: %w", )
		}
		.UserID = 
	}
	{
		if  := .AdminRights.Decode();  != nil {
			return fmt.Errorf("unable to decode channelParticipantCreator#2fe601d3: field admin_rights: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode channelParticipantCreator#2fe601d3: field rank: %w", )
		}
		.Rank = 
	}
	return nil
}

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

// GetAdminRights returns value of AdminRights field.
func ( *ChannelParticipantCreator) () ( ChatAdminRights) {
	if  == nil {
		return
	}
	return .AdminRights
}

// SetRank sets value of Rank conditional field.
func ( *ChannelParticipantCreator) ( string) {
	.Flags.Set(0)
	.Rank = 
}

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

// ChannelParticipantAdmin represents TL type `channelParticipantAdmin#34c3bb53`.
// Admin
//
// See https://core.telegram.org/constructor/channelParticipantAdmin for reference.
type ChannelParticipantAdmin struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Can this admin promote other admins with the same permissions?
	CanEdit bool
	// Is this the current user
	Self bool
	// Admin user ID
	UserID int64
	// User that invited the admin to the channel/group
	//
	// Use SetInviterID and GetInviterID helpers.
	InviterID int64
	// User that promoted the user to admin
	PromotedBy int64
	// When did the user join
	Date int
	// Admin rights¹
	//
	// Links:
	//  1) https://core.telegram.org/api/rights
	AdminRights ChatAdminRights
	// The role (rank) of the admin in the group: just an arbitrary string, admin by default
	//
	// Use SetRank and GetRank helpers.
	Rank string
}

// ChannelParticipantAdminTypeID is TL type id of ChannelParticipantAdmin.
const ChannelParticipantAdminTypeID = 0x34c3bb53

// construct implements constructor of ChannelParticipantClass.
func ( ChannelParticipantAdmin) () ChannelParticipantClass { return & }

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

	_ ChannelParticipantClass = &ChannelParticipantAdmin{}
)

func ( *ChannelParticipantAdmin) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.CanEdit == false) {
		return false
	}
	if !(.Self == false) {
		return false
	}
	if !(.UserID == 0) {
		return false
	}
	if !(.InviterID == 0) {
		return false
	}
	if !(.PromotedBy == 0) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.AdminRights.Zero()) {
		return false
	}
	if !(.Rank == "") {
		return false
	}

	return true
}

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

// FillFrom fills ChannelParticipantAdmin from given interface.
func ( *ChannelParticipantAdmin) ( interface {
	() ( bool)
	() ( bool)
	() ( int64)
	() ( int64,  bool)
	() ( int64)
	() ( int)
	() ( ChatAdminRights)
	() ( string,  bool)
}) {
	.CanEdit = .()
	.Self = .()
	.UserID = .()
	if ,  := .();  {
		.InviterID = 
	}

	.PromotedBy = .()
	.Date = .()
	.AdminRights = .()
	if ,  := .();  {
		.Rank = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelParticipantAdmin) () tdp.Type {
	 := tdp.Type{
		Name: "channelParticipantAdmin",
		ID:   ChannelParticipantAdminTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "CanEdit",
			SchemaName: "can_edit",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Self",
			SchemaName: "self",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "InviterID",
			SchemaName: "inviter_id",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "PromotedBy",
			SchemaName: "promoted_by",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "AdminRights",
			SchemaName: "admin_rights",
		},
		{
			Name:       "Rank",
			SchemaName: "rank",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ChannelParticipantAdmin) () {
	if !(.CanEdit == false) {
		.Flags.Set(0)
	}
	if !(.Self == false) {
		.Flags.Set(1)
	}
	if !(.InviterID == 0) {
		.Flags.Set(1)
	}
	if !(.Rank == "") {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *ChannelParticipantAdmin) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channelParticipantAdmin#34c3bb53 as nil")
	}
	.PutID(ChannelParticipantAdminTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelParticipantAdmin) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channelParticipantAdmin#34c3bb53 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode channelParticipantAdmin#34c3bb53: field flags: %w", )
	}
	.PutLong(.UserID)
	if .Flags.Has(1) {
		.PutLong(.InviterID)
	}
	.PutLong(.PromotedBy)
	.PutInt(.Date)
	if  := .AdminRights.Encode();  != nil {
		return fmt.Errorf("unable to encode channelParticipantAdmin#34c3bb53: field admin_rights: %w", )
	}
	if .Flags.Has(2) {
		.PutString(.Rank)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelParticipantAdmin) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channelParticipantAdmin#34c3bb53 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode channelParticipantAdmin#34c3bb53: field flags: %w", )
		}
	}
	.CanEdit = .Flags.Has(0)
	.Self = .Flags.Has(1)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode channelParticipantAdmin#34c3bb53: field user_id: %w", )
		}
		.UserID = 
	}
	if .Flags.Has(1) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode channelParticipantAdmin#34c3bb53: field inviter_id: %w", )
		}
		.InviterID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode channelParticipantAdmin#34c3bb53: field promoted_by: %w", )
		}
		.PromotedBy = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channelParticipantAdmin#34c3bb53: field date: %w", )
		}
		.Date = 
	}
	{
		if  := .AdminRights.Decode();  != nil {
			return fmt.Errorf("unable to decode channelParticipantAdmin#34c3bb53: field admin_rights: %w", )
		}
	}
	if .Flags.Has(2) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode channelParticipantAdmin#34c3bb53: field rank: %w", )
		}
		.Rank = 
	}
	return nil
}

// SetCanEdit sets value of CanEdit conditional field.
func ( *ChannelParticipantAdmin) ( bool) {
	if  {
		.Flags.Set(0)
		.CanEdit = true
	} else {
		.Flags.Unset(0)
		.CanEdit = false
	}
}

// GetCanEdit returns value of CanEdit conditional field.
func ( *ChannelParticipantAdmin) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetSelf sets value of Self conditional field.
func ( *ChannelParticipantAdmin) ( bool) {
	if  {
		.Flags.Set(1)
		.Self = true
	} else {
		.Flags.Unset(1)
		.Self = false
	}
}

// GetSelf returns value of Self conditional field.
func ( *ChannelParticipantAdmin) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

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

// SetInviterID sets value of InviterID conditional field.
func ( *ChannelParticipantAdmin) ( int64) {
	.Flags.Set(1)
	.InviterID = 
}

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

// GetPromotedBy returns value of PromotedBy field.
func ( *ChannelParticipantAdmin) () ( int64) {
	if  == nil {
		return
	}
	return .PromotedBy
}

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

// GetAdminRights returns value of AdminRights field.
func ( *ChannelParticipantAdmin) () ( ChatAdminRights) {
	if  == nil {
		return
	}
	return .AdminRights
}

// SetRank sets value of Rank conditional field.
func ( *ChannelParticipantAdmin) ( string) {
	.Flags.Set(2)
	.Rank = 
}

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

// ChannelParticipantBanned represents TL type `channelParticipantBanned#6df8014e`.
// Banned/kicked user
//
// See https://core.telegram.org/constructor/channelParticipantBanned for reference.
type ChannelParticipantBanned struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the user has left the group
	Left bool
	// The banned peer
	Peer PeerClass
	// User was kicked by the specified admin
	KickedBy int64
	// When did the user join the group
	Date int
	// Banned rights¹
	//
	// Links:
	//  1) https://core.telegram.org/api/rights
	BannedRights ChatBannedRights
}

// ChannelParticipantBannedTypeID is TL type id of ChannelParticipantBanned.
const ChannelParticipantBannedTypeID = 0x6df8014e

// construct implements constructor of ChannelParticipantClass.
func ( ChannelParticipantBanned) () ChannelParticipantClass { return & }

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

	_ ChannelParticipantClass = &ChannelParticipantBanned{}
)

func ( *ChannelParticipantBanned) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Left == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.KickedBy == 0) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.BannedRights.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills ChannelParticipantBanned from given interface.
func ( *ChannelParticipantBanned) ( interface {
	() ( bool)
	() ( PeerClass)
	() ( int64)
	() ( int)
	() ( ChatBannedRights)
}) {
	.Left = .()
	.Peer = .()
	.KickedBy = .()
	.Date = .()
	.BannedRights = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelParticipantBanned) () tdp.Type {
	 := tdp.Type{
		Name: "channelParticipantBanned",
		ID:   ChannelParticipantBannedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Left",
			SchemaName: "left",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "KickedBy",
			SchemaName: "kicked_by",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "BannedRights",
			SchemaName: "banned_rights",
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *ChannelParticipantBanned) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channelParticipantBanned#6df8014e as nil")
	}
	.PutID(ChannelParticipantBannedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelParticipantBanned) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channelParticipantBanned#6df8014e as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode channelParticipantBanned#6df8014e: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode channelParticipantBanned#6df8014e: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode channelParticipantBanned#6df8014e: field peer: %w", )
	}
	.PutLong(.KickedBy)
	.PutInt(.Date)
	if  := .BannedRights.Encode();  != nil {
		return fmt.Errorf("unable to encode channelParticipantBanned#6df8014e: field banned_rights: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelParticipantBanned) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channelParticipantBanned#6df8014e to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode channelParticipantBanned#6df8014e: field flags: %w", )
		}
	}
	.Left = .Flags.Has(0)
	{
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode channelParticipantBanned#6df8014e: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode channelParticipantBanned#6df8014e: field kicked_by: %w", )
		}
		.KickedBy = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channelParticipantBanned#6df8014e: field date: %w", )
		}
		.Date = 
	}
	{
		if  := .BannedRights.Decode();  != nil {
			return fmt.Errorf("unable to decode channelParticipantBanned#6df8014e: field banned_rights: %w", )
		}
	}
	return nil
}

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

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

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

// GetKickedBy returns value of KickedBy field.
func ( *ChannelParticipantBanned) () ( int64) {
	if  == nil {
		return
	}
	return .KickedBy
}

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

// GetBannedRights returns value of BannedRights field.
func ( *ChannelParticipantBanned) () ( ChatBannedRights) {
	if  == nil {
		return
	}
	return .BannedRights
}

// ChannelParticipantLeft represents TL type `channelParticipantLeft#1b03f006`.
// A participant that left the channel/supergroup
//
// See https://core.telegram.org/constructor/channelParticipantLeft for reference.
type ChannelParticipantLeft struct {
	// The peer that left
	Peer PeerClass
}

// ChannelParticipantLeftTypeID is TL type id of ChannelParticipantLeft.
const ChannelParticipantLeftTypeID = 0x1b03f006

// construct implements constructor of ChannelParticipantClass.
func ( ChannelParticipantLeft) () ChannelParticipantClass { return & }

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

	_ ChannelParticipantClass = &ChannelParticipantLeft{}
)

func ( *ChannelParticipantLeft) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}

	return true
}

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

// FillFrom fills ChannelParticipantLeft from given interface.
func ( *ChannelParticipantLeft) ( interface {
	() ( PeerClass)
}) {
	.Peer = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelParticipantLeft) () tdp.Type {
	 := tdp.Type{
		Name: "channelParticipantLeft",
		ID:   ChannelParticipantLeftTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChannelParticipantLeft) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channelParticipantLeft#1b03f006 as nil")
	}
	.PutID(ChannelParticipantLeftTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelParticipantLeft) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channelParticipantLeft#1b03f006 as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode channelParticipantLeft#1b03f006: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode channelParticipantLeft#1b03f006: field peer: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelParticipantLeft) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channelParticipantLeft#1b03f006 to nil")
	}
	{
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode channelParticipantLeft#1b03f006: field peer: %w", )
		}
		.Peer = 
	}
	return nil
}

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

// ChannelParticipantClassName is schema name of ChannelParticipantClass.
const ChannelParticipantClassName = "ChannelParticipant"

// ChannelParticipantClass represents ChannelParticipant generic type.
//
// See https://core.telegram.org/type/ChannelParticipant for reference.
//
// Example:
//
//	g, err := tg.DecodeChannelParticipant(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.ChannelParticipant: // channelParticipant#c00c07c0
//	case *tg.ChannelParticipantSelf: // channelParticipantSelf#35a8bfa7
//	case *tg.ChannelParticipantCreator: // channelParticipantCreator#2fe601d3
//	case *tg.ChannelParticipantAdmin: // channelParticipantAdmin#34c3bb53
//	case *tg.ChannelParticipantBanned: // channelParticipantBanned#6df8014e
//	case *tg.ChannelParticipantLeft: // channelParticipantLeft#1b03f006
//	default: panic(v)
//	}
type ChannelParticipantClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() ChannelParticipantClass

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

// DecodeChannelParticipant implements binary de-serialization for ChannelParticipantClass.
func ( *bin.Buffer) (ChannelParticipantClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case ChannelParticipantTypeID:
		// Decoding channelParticipant#c00c07c0.
		 := ChannelParticipant{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ChannelParticipantClass: %w", )
		}
		return &, nil
	case ChannelParticipantSelfTypeID:
		// Decoding channelParticipantSelf#35a8bfa7.
		 := ChannelParticipantSelf{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ChannelParticipantClass: %w", )
		}
		return &, nil
	case ChannelParticipantCreatorTypeID:
		// Decoding channelParticipantCreator#2fe601d3.
		 := ChannelParticipantCreator{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ChannelParticipantClass: %w", )
		}
		return &, nil
	case ChannelParticipantAdminTypeID:
		// Decoding channelParticipantAdmin#34c3bb53.
		 := ChannelParticipantAdmin{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ChannelParticipantClass: %w", )
		}
		return &, nil
	case ChannelParticipantBannedTypeID:
		// Decoding channelParticipantBanned#6df8014e.
		 := ChannelParticipantBanned{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ChannelParticipantClass: %w", )
		}
		return &, nil
	case ChannelParticipantLeftTypeID:
		// Decoding channelParticipantLeft#1b03f006.
		 := ChannelParticipantLeft{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ChannelParticipantClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode ChannelParticipantClass: %w", bin.NewUnexpectedID())
	}
}

// ChannelParticipant boxes the ChannelParticipantClass providing a helper.
type ChannelParticipantBox struct {
	ChannelParticipant ChannelParticipantClass
}

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

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