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

// ChatBannedRights represents TL type `chatBannedRights#9f120418`.
// Represents the rights of a normal user in a supergroup/channel/chat¹. In this case,
// the flags are inverted: if set, a flag does not allow a user to do X.
//
// Links:
//  1. https://core.telegram.org/api/channel
//
// See https://core.telegram.org/constructor/chatBannedRights for reference.
type ChatBannedRights struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, does not allow a user to view messages in a supergroup/channel/chat¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	ViewMessages bool
	// If set, does not allow a user to send messages in a supergroup/chat¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	SendMessages bool
	// If set, does not allow a user to send any media in a supergroup/chat¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	SendMedia bool
	// If set, does not allow a user to send stickers in a supergroup/chat¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	SendStickers bool
	// If set, does not allow a user to send gifs in a supergroup/chat¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	SendGifs bool
	// If set, does not allow a user to send games in a supergroup/chat¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	SendGames bool
	// If set, does not allow a user to use inline bots in a supergroup/chat¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	SendInline bool
	// If set, does not allow a user to embed links in the messages of a supergroup/chat¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	EmbedLinks bool
	// If set, does not allow a user to send polls in a supergroup/chat¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	SendPolls bool
	// If set, does not allow any user to change the description of a supergroup/chat¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	ChangeInfo bool
	// If set, does not allow any user to invite users in a supergroup/chat¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	InviteUsers bool
	// If set, does not allow any user to pin messages in a supergroup/chat¹
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	PinMessages bool
	// If set, does not allow any user to create, delete or modify forum topics »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/forum#forum-topics
	ManageTopics bool
	// If set, does not allow a user to send photos in a supergroup/chat¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	SendPhotos bool
	// If set, does not allow a user to send videos in a supergroup/chat¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	SendVideos bool
	// If set, does not allow a user to send round videos in a supergroup/chat¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	SendRoundvideos bool
	// If set, does not allow a user to send audio files in a supergroup/chat¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	SendAudios bool
	// If set, does not allow a user to send voice messages in a supergroup/chat¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	SendVoices bool
	// If set, does not allow a user to send documents in a supergroup/chat¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	SendDocs bool
	// If set, does not allow a user to send text messages in a supergroup/chat¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	SendPlain bool
	// Validity of said permissions (it is considered forever any value less then 30 seconds
	// or more then 366 days).
	UntilDate int
}

// ChatBannedRightsTypeID is TL type id of ChatBannedRights.
const ChatBannedRightsTypeID = 0x9f120418

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

func ( *ChatBannedRights) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ViewMessages == false) {
		return false
	}
	if !(.SendMessages == false) {
		return false
	}
	if !(.SendMedia == false) {
		return false
	}
	if !(.SendStickers == false) {
		return false
	}
	if !(.SendGifs == false) {
		return false
	}
	if !(.SendGames == false) {
		return false
	}
	if !(.SendInline == false) {
		return false
	}
	if !(.EmbedLinks == false) {
		return false
	}
	if !(.SendPolls == false) {
		return false
	}
	if !(.ChangeInfo == false) {
		return false
	}
	if !(.InviteUsers == false) {
		return false
	}
	if !(.PinMessages == false) {
		return false
	}
	if !(.ManageTopics == false) {
		return false
	}
	if !(.SendPhotos == false) {
		return false
	}
	if !(.SendVideos == false) {
		return false
	}
	if !(.SendRoundvideos == false) {
		return false
	}
	if !(.SendAudios == false) {
		return false
	}
	if !(.SendVoices == false) {
		return false
	}
	if !(.SendDocs == false) {
		return false
	}
	if !(.SendPlain == false) {
		return false
	}
	if !(.UntilDate == 0) {
		return false
	}

	return true
}

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

// FillFrom fills ChatBannedRights from given interface.
func ( *ChatBannedRights) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( int)
}) {
	.ViewMessages = .()
	.SendMessages = .()
	.SendMedia = .()
	.SendStickers = .()
	.SendGifs = .()
	.SendGames = .()
	.SendInline = .()
	.EmbedLinks = .()
	.SendPolls = .()
	.ChangeInfo = .()
	.InviteUsers = .()
	.PinMessages = .()
	.ManageTopics = .()
	.SendPhotos = .()
	.SendVideos = .()
	.SendRoundvideos = .()
	.SendAudios = .()
	.SendVoices = .()
	.SendDocs = .()
	.SendPlain = .()
	.UntilDate = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChatBannedRights) () tdp.Type {
	 := tdp.Type{
		Name: "chatBannedRights",
		ID:   ChatBannedRightsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ViewMessages",
			SchemaName: "view_messages",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "SendMessages",
			SchemaName: "send_messages",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "SendMedia",
			SchemaName: "send_media",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "SendStickers",
			SchemaName: "send_stickers",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "SendGifs",
			SchemaName: "send_gifs",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "SendGames",
			SchemaName: "send_games",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "SendInline",
			SchemaName: "send_inline",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "EmbedLinks",
			SchemaName: "embed_links",
			Null:       !.Flags.Has(7),
		},
		{
			Name:       "SendPolls",
			SchemaName: "send_polls",
			Null:       !.Flags.Has(8),
		},
		{
			Name:       "ChangeInfo",
			SchemaName: "change_info",
			Null:       !.Flags.Has(10),
		},
		{
			Name:       "InviteUsers",
			SchemaName: "invite_users",
			Null:       !.Flags.Has(15),
		},
		{
			Name:       "PinMessages",
			SchemaName: "pin_messages",
			Null:       !.Flags.Has(17),
		},
		{
			Name:       "ManageTopics",
			SchemaName: "manage_topics",
			Null:       !.Flags.Has(18),
		},
		{
			Name:       "SendPhotos",
			SchemaName: "send_photos",
			Null:       !.Flags.Has(19),
		},
		{
			Name:       "SendVideos",
			SchemaName: "send_videos",
			Null:       !.Flags.Has(20),
		},
		{
			Name:       "SendRoundvideos",
			SchemaName: "send_roundvideos",
			Null:       !.Flags.Has(21),
		},
		{
			Name:       "SendAudios",
			SchemaName: "send_audios",
			Null:       !.Flags.Has(22),
		},
		{
			Name:       "SendVoices",
			SchemaName: "send_voices",
			Null:       !.Flags.Has(23),
		},
		{
			Name:       "SendDocs",
			SchemaName: "send_docs",
			Null:       !.Flags.Has(24),
		},
		{
			Name:       "SendPlain",
			SchemaName: "send_plain",
			Null:       !.Flags.Has(25),
		},
		{
			Name:       "UntilDate",
			SchemaName: "until_date",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ChatBannedRights) () {
	if !(.ViewMessages == false) {
		.Flags.Set(0)
	}
	if !(.SendMessages == false) {
		.Flags.Set(1)
	}
	if !(.SendMedia == false) {
		.Flags.Set(2)
	}
	if !(.SendStickers == false) {
		.Flags.Set(3)
	}
	if !(.SendGifs == false) {
		.Flags.Set(4)
	}
	if !(.SendGames == false) {
		.Flags.Set(5)
	}
	if !(.SendInline == false) {
		.Flags.Set(6)
	}
	if !(.EmbedLinks == false) {
		.Flags.Set(7)
	}
	if !(.SendPolls == false) {
		.Flags.Set(8)
	}
	if !(.ChangeInfo == false) {
		.Flags.Set(10)
	}
	if !(.InviteUsers == false) {
		.Flags.Set(15)
	}
	if !(.PinMessages == false) {
		.Flags.Set(17)
	}
	if !(.ManageTopics == false) {
		.Flags.Set(18)
	}
	if !(.SendPhotos == false) {
		.Flags.Set(19)
	}
	if !(.SendVideos == false) {
		.Flags.Set(20)
	}
	if !(.SendRoundvideos == false) {
		.Flags.Set(21)
	}
	if !(.SendAudios == false) {
		.Flags.Set(22)
	}
	if !(.SendVoices == false) {
		.Flags.Set(23)
	}
	if !(.SendDocs == false) {
		.Flags.Set(24)
	}
	if !(.SendPlain == false) {
		.Flags.Set(25)
	}
}

// Encode implements bin.Encoder.
func ( *ChatBannedRights) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatBannedRights#9f120418 as nil")
	}
	.PutID(ChatBannedRightsTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *ChatBannedRights) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chatBannedRights#9f120418 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode chatBannedRights#9f120418: field flags: %w", )
		}
	}
	.ViewMessages = .Flags.Has(0)
	.SendMessages = .Flags.Has(1)
	.SendMedia = .Flags.Has(2)
	.SendStickers = .Flags.Has(3)
	.SendGifs = .Flags.Has(4)
	.SendGames = .Flags.Has(5)
	.SendInline = .Flags.Has(6)
	.EmbedLinks = .Flags.Has(7)
	.SendPolls = .Flags.Has(8)
	.ChangeInfo = .Flags.Has(10)
	.InviteUsers = .Flags.Has(15)
	.PinMessages = .Flags.Has(17)
	.ManageTopics = .Flags.Has(18)
	.SendPhotos = .Flags.Has(19)
	.SendVideos = .Flags.Has(20)
	.SendRoundvideos = .Flags.Has(21)
	.SendAudios = .Flags.Has(22)
	.SendVoices = .Flags.Has(23)
	.SendDocs = .Flags.Has(24)
	.SendPlain = .Flags.Has(25)
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode chatBannedRights#9f120418: field until_date: %w", )
		}
		.UntilDate = 
	}
	return nil
}

// SetViewMessages sets value of ViewMessages conditional field.
func ( *ChatBannedRights) ( bool) {
	if  {
		.Flags.Set(0)
		.ViewMessages = true
	} else {
		.Flags.Unset(0)
		.ViewMessages = false
	}
}

// GetViewMessages returns value of ViewMessages conditional field.
func ( *ChatBannedRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetSendMessages sets value of SendMessages conditional field.
func ( *ChatBannedRights) ( bool) {
	if  {
		.Flags.Set(1)
		.SendMessages = true
	} else {
		.Flags.Unset(1)
		.SendMessages = false
	}
}

// GetSendMessages returns value of SendMessages conditional field.
func ( *ChatBannedRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetSendMedia sets value of SendMedia conditional field.
func ( *ChatBannedRights) ( bool) {
	if  {
		.Flags.Set(2)
		.SendMedia = true
	} else {
		.Flags.Unset(2)
		.SendMedia = false
	}
}

// GetSendMedia returns value of SendMedia conditional field.
func ( *ChatBannedRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// SetSendStickers sets value of SendStickers conditional field.
func ( *ChatBannedRights) ( bool) {
	if  {
		.Flags.Set(3)
		.SendStickers = true
	} else {
		.Flags.Unset(3)
		.SendStickers = false
	}
}

// GetSendStickers returns value of SendStickers conditional field.
func ( *ChatBannedRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// SetSendGifs sets value of SendGifs conditional field.
func ( *ChatBannedRights) ( bool) {
	if  {
		.Flags.Set(4)
		.SendGifs = true
	} else {
		.Flags.Unset(4)
		.SendGifs = false
	}
}

// GetSendGifs returns value of SendGifs conditional field.
func ( *ChatBannedRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(4)
}

// SetSendGames sets value of SendGames conditional field.
func ( *ChatBannedRights) ( bool) {
	if  {
		.Flags.Set(5)
		.SendGames = true
	} else {
		.Flags.Unset(5)
		.SendGames = false
	}
}

// GetSendGames returns value of SendGames conditional field.
func ( *ChatBannedRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(5)
}

// SetSendInline sets value of SendInline conditional field.
func ( *ChatBannedRights) ( bool) {
	if  {
		.Flags.Set(6)
		.SendInline = true
	} else {
		.Flags.Unset(6)
		.SendInline = false
	}
}

// GetSendInline returns value of SendInline conditional field.
func ( *ChatBannedRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(6)
}

// SetEmbedLinks sets value of EmbedLinks conditional field.
func ( *ChatBannedRights) ( bool) {
	if  {
		.Flags.Set(7)
		.EmbedLinks = true
	} else {
		.Flags.Unset(7)
		.EmbedLinks = false
	}
}

// GetEmbedLinks returns value of EmbedLinks conditional field.
func ( *ChatBannedRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(7)
}

// SetSendPolls sets value of SendPolls conditional field.
func ( *ChatBannedRights) ( bool) {
	if  {
		.Flags.Set(8)
		.SendPolls = true
	} else {
		.Flags.Unset(8)
		.SendPolls = false
	}
}

// GetSendPolls returns value of SendPolls conditional field.
func ( *ChatBannedRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(8)
}

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

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

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

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

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

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

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

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

// SetSendPhotos sets value of SendPhotos conditional field.
func ( *ChatBannedRights) ( bool) {
	if  {
		.Flags.Set(19)
		.SendPhotos = true
	} else {
		.Flags.Unset(19)
		.SendPhotos = false
	}
}

// GetSendPhotos returns value of SendPhotos conditional field.
func ( *ChatBannedRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(19)
}

// SetSendVideos sets value of SendVideos conditional field.
func ( *ChatBannedRights) ( bool) {
	if  {
		.Flags.Set(20)
		.SendVideos = true
	} else {
		.Flags.Unset(20)
		.SendVideos = false
	}
}

// GetSendVideos returns value of SendVideos conditional field.
func ( *ChatBannedRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(20)
}

// SetSendRoundvideos sets value of SendRoundvideos conditional field.
func ( *ChatBannedRights) ( bool) {
	if  {
		.Flags.Set(21)
		.SendRoundvideos = true
	} else {
		.Flags.Unset(21)
		.SendRoundvideos = false
	}
}

// GetSendRoundvideos returns value of SendRoundvideos conditional field.
func ( *ChatBannedRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(21)
}

// SetSendAudios sets value of SendAudios conditional field.
func ( *ChatBannedRights) ( bool) {
	if  {
		.Flags.Set(22)
		.SendAudios = true
	} else {
		.Flags.Unset(22)
		.SendAudios = false
	}
}

// GetSendAudios returns value of SendAudios conditional field.
func ( *ChatBannedRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(22)
}

// SetSendVoices sets value of SendVoices conditional field.
func ( *ChatBannedRights) ( bool) {
	if  {
		.Flags.Set(23)
		.SendVoices = true
	} else {
		.Flags.Unset(23)
		.SendVoices = false
	}
}

// GetSendVoices returns value of SendVoices conditional field.
func ( *ChatBannedRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(23)
}

// SetSendDocs sets value of SendDocs conditional field.
func ( *ChatBannedRights) ( bool) {
	if  {
		.Flags.Set(24)
		.SendDocs = true
	} else {
		.Flags.Unset(24)
		.SendDocs = false
	}
}

// GetSendDocs returns value of SendDocs conditional field.
func ( *ChatBannedRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(24)
}

// SetSendPlain sets value of SendPlain conditional field.
func ( *ChatBannedRights) ( bool) {
	if  {
		.Flags.Set(25)
		.SendPlain = true
	} else {
		.Flags.Unset(25)
		.SendPlain = false
	}
}

// GetSendPlain returns value of SendPlain conditional field.
func ( *ChatBannedRights) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(25)
}

// GetUntilDate returns value of UntilDate field.
func ( *ChatBannedRights) () ( int) {
	if  == nil {
		return
	}
	return .UntilDate
}