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

// ChatAdminRights represents TL type `chatAdminRights#5fb224d5`.
// Represents the rights of an admin in a channel/supergroup¹.
//
// Links:
//  1. https://core.telegram.org/api/channel
//
// See https://core.telegram.org/constructor/chatAdminRights for reference.
type ChatAdminRights struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, allows the admin to modify the description of the channel/supergroup¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	ChangeInfo bool
	// If set, allows the admin to post messages in the channel¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	PostMessages bool
	// If set, allows the admin to also edit messages from other admins in the channel¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	EditMessages bool
	// If set, allows the admin to also delete messages from other admins in the channel¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	DeleteMessages bool
	// If set, allows the admin to ban users from the channel/supergroup¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	BanUsers bool
	// If set, allows the admin to invite users in the channel/supergroup¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	InviteUsers bool
	// If set, allows the admin to pin messages in the channel/supergroup¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	PinMessages bool
	// If set, allows the admin to add other admins with the same (or more limited)
	// permissions in the channel/supergroup¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	AddAdmins bool
	// Whether this admin is anonymous
	Anonymous bool
	// If set, allows the admin to change group call/livestream settings
	ManageCall bool
	// Set this flag if none of the other flags are set, but you still want the user to be an
	// admin: if this or any of the other flags are set, the admin can get the chat admin
	// log¹, get chat statistics², get message statistics in channels³, get channel
	// members, see anonymous administrators in supergroups and ignore slow mode.
	//
	// Links:
	//  1) https://core.telegram.org/api/recent-actions
	//  2) https://core.telegram.org/api/stats
	//  3) https://core.telegram.org/api/stats
	Other bool
	// If set, allows the admin to create, delete or modify forum topics »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/forum#forum-topics
	ManageTopics bool
	// If set, allows the admin to post stories¹ as the channel².
	//
	// Links:
	//  1) https://core.telegram.org/api/stories
	//  2) https://core.telegram.org/api/channel
	PostStories bool
	// If set, allows the admin to edit stories¹ posted by the other admins of the channel².
	//
	// Links:
	//  1) https://core.telegram.org/api/stories
	//  2) https://core.telegram.org/api/channel
	EditStories bool
	// If set, allows the admin to delete stories¹ posted by the other admins of the
	// channel².
	//
	// Links:
	//  1) https://core.telegram.org/api/stories
	//  2) https://core.telegram.org/api/channel
	DeleteStories bool
}

// ChatAdminRightsTypeID is TL type id of ChatAdminRights.
const ChatAdminRightsTypeID = 0x5fb224d5

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

func ( *ChatAdminRights) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ChangeInfo == false) {
		return false
	}
	if !(.PostMessages == false) {
		return false
	}
	if !(.EditMessages == false) {
		return false
	}
	if !(.DeleteMessages == false) {
		return false
	}
	if !(.BanUsers == false) {
		return false
	}
	if !(.InviteUsers == false) {
		return false
	}
	if !(.PinMessages == false) {
		return false
	}
	if !(.AddAdmins == false) {
		return false
	}
	if !(.Anonymous == false) {
		return false
	}
	if !(.ManageCall == false) {
		return false
	}
	if !(.Other == false) {
		return false
	}
	if !(.ManageTopics == false) {
		return false
	}
	if !(.PostStories == false) {
		return false
	}
	if !(.EditStories == false) {
		return false
	}
	if !(.DeleteStories == false) {
		return false
	}

	return true
}

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

// FillFrom fills ChatAdminRights from given interface.
func ( *ChatAdminRights) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
}) {
	.ChangeInfo = .()
	.PostMessages = .()
	.EditMessages = .()
	.DeleteMessages = .()
	.BanUsers = .()
	.InviteUsers = .()
	.PinMessages = .()
	.AddAdmins = .()
	.Anonymous = .()
	.ManageCall = .()
	.Other = .()
	.ManageTopics = .()
	.PostStories = .()
	.EditStories = .()
	.DeleteStories = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChatAdminRights) () tdp.Type {
	 := tdp.Type{
		Name: "chatAdminRights",
		ID:   ChatAdminRightsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ChangeInfo",
			SchemaName: "change_info",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "PostMessages",
			SchemaName: "post_messages",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "EditMessages",
			SchemaName: "edit_messages",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "DeleteMessages",
			SchemaName: "delete_messages",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "BanUsers",
			SchemaName: "ban_users",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "InviteUsers",
			SchemaName: "invite_users",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "PinMessages",
			SchemaName: "pin_messages",
			Null:       !.Flags.Has(7),
		},
		{
			Name:       "AddAdmins",
			SchemaName: "add_admins",
			Null:       !.Flags.Has(9),
		},
		{
			Name:       "Anonymous",
			SchemaName: "anonymous",
			Null:       !.Flags.Has(10),
		},
		{
			Name:       "ManageCall",
			SchemaName: "manage_call",
			Null:       !.Flags.Has(11),
		},
		{
			Name:       "Other",
			SchemaName: "other",
			Null:       !.Flags.Has(12),
		},
		{
			Name:       "ManageTopics",
			SchemaName: "manage_topics",
			Null:       !.Flags.Has(13),
		},
		{
			Name:       "PostStories",
			SchemaName: "post_stories",
			Null:       !.Flags.Has(14),
		},
		{
			Name:       "EditStories",
			SchemaName: "edit_stories",
			Null:       !.Flags.Has(15),
		},
		{
			Name:       "DeleteStories",
			SchemaName: "delete_stories",
			Null:       !.Flags.Has(16),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ChatAdminRights) () {
	if !(.ChangeInfo == false) {
		.Flags.Set(0)
	}
	if !(.PostMessages == false) {
		.Flags.Set(1)
	}
	if !(.EditMessages == false) {
		.Flags.Set(2)
	}
	if !(.DeleteMessages == false) {
		.Flags.Set(3)
	}
	if !(.BanUsers == false) {
		.Flags.Set(4)
	}
	if !(.InviteUsers == false) {
		.Flags.Set(5)
	}
	if !(.PinMessages == false) {
		.Flags.Set(7)
	}
	if !(.AddAdmins == false) {
		.Flags.Set(9)
	}
	if !(.Anonymous == false) {
		.Flags.Set(10)
	}
	if !(.ManageCall == false) {
		.Flags.Set(11)
	}
	if !(.Other == false) {
		.Flags.Set(12)
	}
	if !(.ManageTopics == false) {
		.Flags.Set(13)
	}
	if !(.PostStories == false) {
		.Flags.Set(14)
	}
	if !(.EditStories == false) {
		.Flags.Set(15)
	}
	if !(.DeleteStories == false) {
		.Flags.Set(16)
	}
}

// Encode implements bin.Encoder.
func ( *ChatAdminRights) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatAdminRights#5fb224d5 as nil")
	}
	.PutID(ChatAdminRightsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChatAdminRights) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatAdminRights#5fb224d5 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode chatAdminRights#5fb224d5: field flags: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChatAdminRights) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chatAdminRights#5fb224d5 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode chatAdminRights#5fb224d5: field flags: %w", )
		}
	}
	.ChangeInfo = .Flags.Has(0)
	.PostMessages = .Flags.Has(1)
	.EditMessages = .Flags.Has(2)
	.DeleteMessages = .Flags.Has(3)
	.BanUsers = .Flags.Has(4)
	.InviteUsers = .Flags.Has(5)
	.PinMessages = .Flags.Has(7)
	.AddAdmins = .Flags.Has(9)
	.Anonymous = .Flags.Has(10)
	.ManageCall = .Flags.Has(11)
	.Other = .Flags.Has(12)
	.ManageTopics = .Flags.Has(13)
	.PostStories = .Flags.Has(14)
	.EditStories = .Flags.Has(15)
	.DeleteStories = .Flags.Has(16)
	return nil
}

// SetChangeInfo sets value of ChangeInfo conditional field.
func ( *ChatAdminRights) ( bool) {
	if  {
		.Flags.Set(0)
		.ChangeInfo = true
	} else {
		.Flags.Unset(0)
		.ChangeInfo = false
	}
}

// GetChangeInfo returns value of ChangeInfo conditional field.
func ( *ChatAdminRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetPostMessages sets value of PostMessages conditional field.
func ( *ChatAdminRights) ( bool) {
	if  {
		.Flags.Set(1)
		.PostMessages = true
	} else {
		.Flags.Unset(1)
		.PostMessages = false
	}
}

// GetPostMessages returns value of PostMessages conditional field.
func ( *ChatAdminRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetEditMessages sets value of EditMessages conditional field.
func ( *ChatAdminRights) ( bool) {
	if  {
		.Flags.Set(2)
		.EditMessages = true
	} else {
		.Flags.Unset(2)
		.EditMessages = false
	}
}

// GetEditMessages returns value of EditMessages conditional field.
func ( *ChatAdminRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// SetDeleteMessages sets value of DeleteMessages conditional field.
func ( *ChatAdminRights) ( bool) {
	if  {
		.Flags.Set(3)
		.DeleteMessages = true
	} else {
		.Flags.Unset(3)
		.DeleteMessages = false
	}
}

// GetDeleteMessages returns value of DeleteMessages conditional field.
func ( *ChatAdminRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// SetBanUsers sets value of BanUsers conditional field.
func ( *ChatAdminRights) ( bool) {
	if  {
		.Flags.Set(4)
		.BanUsers = true
	} else {
		.Flags.Unset(4)
		.BanUsers = false
	}
}

// GetBanUsers returns value of BanUsers conditional field.
func ( *ChatAdminRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(4)
}

// SetInviteUsers sets value of InviteUsers conditional field.
func ( *ChatAdminRights) ( bool) {
	if  {
		.Flags.Set(5)
		.InviteUsers = true
	} else {
		.Flags.Unset(5)
		.InviteUsers = false
	}
}

// GetInviteUsers returns value of InviteUsers conditional field.
func ( *ChatAdminRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(5)
}

// SetPinMessages sets value of PinMessages conditional field.
func ( *ChatAdminRights) ( bool) {
	if  {
		.Flags.Set(7)
		.PinMessages = true
	} else {
		.Flags.Unset(7)
		.PinMessages = false
	}
}

// GetPinMessages returns value of PinMessages conditional field.
func ( *ChatAdminRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(7)
}

// SetAddAdmins sets value of AddAdmins conditional field.
func ( *ChatAdminRights) ( bool) {
	if  {
		.Flags.Set(9)
		.AddAdmins = true
	} else {
		.Flags.Unset(9)
		.AddAdmins = false
	}
}

// GetAddAdmins returns value of AddAdmins conditional field.
func ( *ChatAdminRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(9)
}

// SetAnonymous sets value of Anonymous conditional field.
func ( *ChatAdminRights) ( bool) {
	if  {
		.Flags.Set(10)
		.Anonymous = true
	} else {
		.Flags.Unset(10)
		.Anonymous = false
	}
}

// GetAnonymous returns value of Anonymous conditional field.
func ( *ChatAdminRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(10)
}

// SetManageCall sets value of ManageCall conditional field.
func ( *ChatAdminRights) ( bool) {
	if  {
		.Flags.Set(11)
		.ManageCall = true
	} else {
		.Flags.Unset(11)
		.ManageCall = false
	}
}

// GetManageCall returns value of ManageCall conditional field.
func ( *ChatAdminRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(11)
}

// SetOther sets value of Other conditional field.
func ( *ChatAdminRights) ( bool) {
	if  {
		.Flags.Set(12)
		.Other = true
	} else {
		.Flags.Unset(12)
		.Other = false
	}
}

// GetOther returns value of Other conditional field.
func ( *ChatAdminRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(12)
}

// SetManageTopics sets value of ManageTopics conditional field.
func ( *ChatAdminRights) ( bool) {
	if  {
		.Flags.Set(13)
		.ManageTopics = true
	} else {
		.Flags.Unset(13)
		.ManageTopics = false
	}
}

// GetManageTopics returns value of ManageTopics conditional field.
func ( *ChatAdminRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(13)
}

// SetPostStories sets value of PostStories conditional field.
func ( *ChatAdminRights) ( bool) {
	if  {
		.Flags.Set(14)
		.PostStories = true
	} else {
		.Flags.Unset(14)
		.PostStories = false
	}
}

// GetPostStories returns value of PostStories conditional field.
func ( *ChatAdminRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(14)
}

// SetEditStories sets value of EditStories conditional field.
func ( *ChatAdminRights) ( bool) {
	if  {
		.Flags.Set(15)
		.EditStories = true
	} else {
		.Flags.Unset(15)
		.EditStories = false
	}
}

// GetEditStories returns value of EditStories conditional field.
func ( *ChatAdminRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(15)
}

// SetDeleteStories sets value of DeleteStories conditional field.
func ( *ChatAdminRights) ( bool) {
	if  {
		.Flags.Set(16)
		.DeleteStories = true
	} else {
		.Flags.Unset(16)
		.DeleteStories = false
	}
}

// GetDeleteStories returns value of DeleteStories conditional field.
func ( *ChatAdminRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(16)
}