package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type ChatBannedRights struct {
Flags bin .Fields
ViewMessages bool
SendMessages bool
SendMedia bool
SendStickers bool
SendGifs bool
SendGames bool
SendInline bool
EmbedLinks bool
SendPolls bool
ChangeInfo bool
InviteUsers bool
PinMessages bool
ManageTopics bool
SendPhotos bool
SendVideos bool
SendRoundvideos bool
SendAudios bool
SendVoices bool
SendDocs bool
SendPlain bool
UntilDate int
}
const ChatBannedRightsTypeID = 0x9f120418
var (
_ bin .Encoder = &ChatBannedRights {}
_ bin .Decoder = &ChatBannedRights {}
_ bin .BareEncoder = &ChatBannedRights {}
_ bin .BareDecoder = &ChatBannedRights {}
)
func (c *ChatBannedRights ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .ViewMessages == false ) {
return false
}
if !(c .SendMessages == false ) {
return false
}
if !(c .SendMedia == false ) {
return false
}
if !(c .SendStickers == false ) {
return false
}
if !(c .SendGifs == false ) {
return false
}
if !(c .SendGames == false ) {
return false
}
if !(c .SendInline == false ) {
return false
}
if !(c .EmbedLinks == false ) {
return false
}
if !(c .SendPolls == false ) {
return false
}
if !(c .ChangeInfo == false ) {
return false
}
if !(c .InviteUsers == false ) {
return false
}
if !(c .PinMessages == false ) {
return false
}
if !(c .ManageTopics == false ) {
return false
}
if !(c .SendPhotos == false ) {
return false
}
if !(c .SendVideos == false ) {
return false
}
if !(c .SendRoundvideos == false ) {
return false
}
if !(c .SendAudios == false ) {
return false
}
if !(c .SendVoices == false ) {
return false
}
if !(c .SendDocs == false ) {
return false
}
if !(c .SendPlain == false ) {
return false
}
if !(c .UntilDate == 0 ) {
return false
}
return true
}
func (c *ChatBannedRights ) String () string {
if c == nil {
return "ChatBannedRights(nil)"
}
type Alias ChatBannedRights
return fmt .Sprintf ("ChatBannedRights%+v" , Alias (*c ))
}
func (c *ChatBannedRights ) FillFrom (from interface {
GetViewMessages () (value bool )
GetSendMessages () (value bool )
GetSendMedia () (value bool )
GetSendStickers () (value bool )
GetSendGifs () (value bool )
GetSendGames () (value bool )
GetSendInline () (value bool )
GetEmbedLinks () (value bool )
GetSendPolls () (value bool )
GetChangeInfo () (value bool )
GetInviteUsers () (value bool )
GetPinMessages () (value bool )
GetManageTopics () (value bool )
GetSendPhotos () (value bool )
GetSendVideos () (value bool )
GetSendRoundvideos () (value bool )
GetSendAudios () (value bool )
GetSendVoices () (value bool )
GetSendDocs () (value bool )
GetSendPlain () (value bool )
GetUntilDate () (value int )
}) {
c .ViewMessages = from .GetViewMessages ()
c .SendMessages = from .GetSendMessages ()
c .SendMedia = from .GetSendMedia ()
c .SendStickers = from .GetSendStickers ()
c .SendGifs = from .GetSendGifs ()
c .SendGames = from .GetSendGames ()
c .SendInline = from .GetSendInline ()
c .EmbedLinks = from .GetEmbedLinks ()
c .SendPolls = from .GetSendPolls ()
c .ChangeInfo = from .GetChangeInfo ()
c .InviteUsers = from .GetInviteUsers ()
c .PinMessages = from .GetPinMessages ()
c .ManageTopics = from .GetManageTopics ()
c .SendPhotos = from .GetSendPhotos ()
c .SendVideos = from .GetSendVideos ()
c .SendRoundvideos = from .GetSendRoundvideos ()
c .SendAudios = from .GetSendAudios ()
c .SendVoices = from .GetSendVoices ()
c .SendDocs = from .GetSendDocs ()
c .SendPlain = from .GetSendPlain ()
c .UntilDate = from .GetUntilDate ()
}
func (*ChatBannedRights ) TypeID () uint32 {
return ChatBannedRightsTypeID
}
func (*ChatBannedRights ) TypeName () string {
return "chatBannedRights"
}
func (c *ChatBannedRights ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chatBannedRights" ,
ID : ChatBannedRightsTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ViewMessages" ,
SchemaName : "view_messages" ,
Null : !c .Flags .Has (0 ),
},
{
Name : "SendMessages" ,
SchemaName : "send_messages" ,
Null : !c .Flags .Has (1 ),
},
{
Name : "SendMedia" ,
SchemaName : "send_media" ,
Null : !c .Flags .Has (2 ),
},
{
Name : "SendStickers" ,
SchemaName : "send_stickers" ,
Null : !c .Flags .Has (3 ),
},
{
Name : "SendGifs" ,
SchemaName : "send_gifs" ,
Null : !c .Flags .Has (4 ),
},
{
Name : "SendGames" ,
SchemaName : "send_games" ,
Null : !c .Flags .Has (5 ),
},
{
Name : "SendInline" ,
SchemaName : "send_inline" ,
Null : !c .Flags .Has (6 ),
},
{
Name : "EmbedLinks" ,
SchemaName : "embed_links" ,
Null : !c .Flags .Has (7 ),
},
{
Name : "SendPolls" ,
SchemaName : "send_polls" ,
Null : !c .Flags .Has (8 ),
},
{
Name : "ChangeInfo" ,
SchemaName : "change_info" ,
Null : !c .Flags .Has (10 ),
},
{
Name : "InviteUsers" ,
SchemaName : "invite_users" ,
Null : !c .Flags .Has (15 ),
},
{
Name : "PinMessages" ,
SchemaName : "pin_messages" ,
Null : !c .Flags .Has (17 ),
},
{
Name : "ManageTopics" ,
SchemaName : "manage_topics" ,
Null : !c .Flags .Has (18 ),
},
{
Name : "SendPhotos" ,
SchemaName : "send_photos" ,
Null : !c .Flags .Has (19 ),
},
{
Name : "SendVideos" ,
SchemaName : "send_videos" ,
Null : !c .Flags .Has (20 ),
},
{
Name : "SendRoundvideos" ,
SchemaName : "send_roundvideos" ,
Null : !c .Flags .Has (21 ),
},
{
Name : "SendAudios" ,
SchemaName : "send_audios" ,
Null : !c .Flags .Has (22 ),
},
{
Name : "SendVoices" ,
SchemaName : "send_voices" ,
Null : !c .Flags .Has (23 ),
},
{
Name : "SendDocs" ,
SchemaName : "send_docs" ,
Null : !c .Flags .Has (24 ),
},
{
Name : "SendPlain" ,
SchemaName : "send_plain" ,
Null : !c .Flags .Has (25 ),
},
{
Name : "UntilDate" ,
SchemaName : "until_date" ,
},
}
return typ
}
func (c *ChatBannedRights ) SetFlags () {
if !(c .ViewMessages == false ) {
c .Flags .Set (0 )
}
if !(c .SendMessages == false ) {
c .Flags .Set (1 )
}
if !(c .SendMedia == false ) {
c .Flags .Set (2 )
}
if !(c .SendStickers == false ) {
c .Flags .Set (3 )
}
if !(c .SendGifs == false ) {
c .Flags .Set (4 )
}
if !(c .SendGames == false ) {
c .Flags .Set (5 )
}
if !(c .SendInline == false ) {
c .Flags .Set (6 )
}
if !(c .EmbedLinks == false ) {
c .Flags .Set (7 )
}
if !(c .SendPolls == false ) {
c .Flags .Set (8 )
}
if !(c .ChangeInfo == false ) {
c .Flags .Set (10 )
}
if !(c .InviteUsers == false ) {
c .Flags .Set (15 )
}
if !(c .PinMessages == false ) {
c .Flags .Set (17 )
}
if !(c .ManageTopics == false ) {
c .Flags .Set (18 )
}
if !(c .SendPhotos == false ) {
c .Flags .Set (19 )
}
if !(c .SendVideos == false ) {
c .Flags .Set (20 )
}
if !(c .SendRoundvideos == false ) {
c .Flags .Set (21 )
}
if !(c .SendAudios == false ) {
c .Flags .Set (22 )
}
if !(c .SendVoices == false ) {
c .Flags .Set (23 )
}
if !(c .SendDocs == false ) {
c .Flags .Set (24 )
}
if !(c .SendPlain == false ) {
c .Flags .Set (25 )
}
}
func (c *ChatBannedRights ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatBannedRights#9f120418 as nil" )
}
b .PutID (ChatBannedRightsTypeID )
return c .EncodeBare (b )
}
func (c *ChatBannedRights ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatBannedRights#9f120418 as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chatBannedRights#9f120418: field flags: %w" , err )
}
b .PutInt (c .UntilDate )
return nil
}
func (c *ChatBannedRights ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatBannedRights#9f120418 to nil" )
}
if err := b .ConsumeID (ChatBannedRightsTypeID ); err != nil {
return fmt .Errorf ("unable to decode chatBannedRights#9f120418: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChatBannedRights ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatBannedRights#9f120418 to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode chatBannedRights#9f120418: field flags: %w" , err )
}
}
c .ViewMessages = c .Flags .Has (0 )
c .SendMessages = c .Flags .Has (1 )
c .SendMedia = c .Flags .Has (2 )
c .SendStickers = c .Flags .Has (3 )
c .SendGifs = c .Flags .Has (4 )
c .SendGames = c .Flags .Has (5 )
c .SendInline = c .Flags .Has (6 )
c .EmbedLinks = c .Flags .Has (7 )
c .SendPolls = c .Flags .Has (8 )
c .ChangeInfo = c .Flags .Has (10 )
c .InviteUsers = c .Flags .Has (15 )
c .PinMessages = c .Flags .Has (17 )
c .ManageTopics = c .Flags .Has (18 )
c .SendPhotos = c .Flags .Has (19 )
c .SendVideos = c .Flags .Has (20 )
c .SendRoundvideos = c .Flags .Has (21 )
c .SendAudios = c .Flags .Has (22 )
c .SendVoices = c .Flags .Has (23 )
c .SendDocs = c .Flags .Has (24 )
c .SendPlain = c .Flags .Has (25 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode chatBannedRights#9f120418: field until_date: %w" , err )
}
c .UntilDate = value
}
return nil
}
func (c *ChatBannedRights ) SetViewMessages (value bool ) {
if value {
c .Flags .Set (0 )
c .ViewMessages = true
} else {
c .Flags .Unset (0 )
c .ViewMessages = false
}
}
func (c *ChatBannedRights ) GetViewMessages () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (0 )
}
func (c *ChatBannedRights ) SetSendMessages (value bool ) {
if value {
c .Flags .Set (1 )
c .SendMessages = true
} else {
c .Flags .Unset (1 )
c .SendMessages = false
}
}
func (c *ChatBannedRights ) GetSendMessages () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (1 )
}
func (c *ChatBannedRights ) SetSendMedia (value bool ) {
if value {
c .Flags .Set (2 )
c .SendMedia = true
} else {
c .Flags .Unset (2 )
c .SendMedia = false
}
}
func (c *ChatBannedRights ) GetSendMedia () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (2 )
}
func (c *ChatBannedRights ) SetSendStickers (value bool ) {
if value {
c .Flags .Set (3 )
c .SendStickers = true
} else {
c .Flags .Unset (3 )
c .SendStickers = false
}
}
func (c *ChatBannedRights ) GetSendStickers () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (3 )
}
func (c *ChatBannedRights ) SetSendGifs (value bool ) {
if value {
c .Flags .Set (4 )
c .SendGifs = true
} else {
c .Flags .Unset (4 )
c .SendGifs = false
}
}
func (c *ChatBannedRights ) GetSendGifs () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (4 )
}
func (c *ChatBannedRights ) SetSendGames (value bool ) {
if value {
c .Flags .Set (5 )
c .SendGames = true
} else {
c .Flags .Unset (5 )
c .SendGames = false
}
}
func (c *ChatBannedRights ) GetSendGames () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (5 )
}
func (c *ChatBannedRights ) SetSendInline (value bool ) {
if value {
c .Flags .Set (6 )
c .SendInline = true
} else {
c .Flags .Unset (6 )
c .SendInline = false
}
}
func (c *ChatBannedRights ) GetSendInline () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (6 )
}
func (c *ChatBannedRights ) SetEmbedLinks (value bool ) {
if value {
c .Flags .Set (7 )
c .EmbedLinks = true
} else {
c .Flags .Unset (7 )
c .EmbedLinks = false
}
}
func (c *ChatBannedRights ) GetEmbedLinks () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (7 )
}
func (c *ChatBannedRights ) SetSendPolls (value bool ) {
if value {
c .Flags .Set (8 )
c .SendPolls = true
} else {
c .Flags .Unset (8 )
c .SendPolls = false
}
}
func (c *ChatBannedRights ) GetSendPolls () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (8 )
}
func (c *ChatBannedRights ) SetChangeInfo (value bool ) {
if value {
c .Flags .Set (10 )
c .ChangeInfo = true
} else {
c .Flags .Unset (10 )
c .ChangeInfo = false
}
}
func (c *ChatBannedRights ) GetChangeInfo () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (10 )
}
func (c *ChatBannedRights ) SetInviteUsers (value bool ) {
if value {
c .Flags .Set (15 )
c .InviteUsers = true
} else {
c .Flags .Unset (15 )
c .InviteUsers = false
}
}
func (c *ChatBannedRights ) GetInviteUsers () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (15 )
}
func (c *ChatBannedRights ) SetPinMessages (value bool ) {
if value {
c .Flags .Set (17 )
c .PinMessages = true
} else {
c .Flags .Unset (17 )
c .PinMessages = false
}
}
func (c *ChatBannedRights ) GetPinMessages () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (17 )
}
func (c *ChatBannedRights ) SetManageTopics (value bool ) {
if value {
c .Flags .Set (18 )
c .ManageTopics = true
} else {
c .Flags .Unset (18 )
c .ManageTopics = false
}
}
func (c *ChatBannedRights ) GetManageTopics () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (18 )
}
func (c *ChatBannedRights ) SetSendPhotos (value bool ) {
if value {
c .Flags .Set (19 )
c .SendPhotos = true
} else {
c .Flags .Unset (19 )
c .SendPhotos = false
}
}
func (c *ChatBannedRights ) GetSendPhotos () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (19 )
}
func (c *ChatBannedRights ) SetSendVideos (value bool ) {
if value {
c .Flags .Set (20 )
c .SendVideos = true
} else {
c .Flags .Unset (20 )
c .SendVideos = false
}
}
func (c *ChatBannedRights ) GetSendVideos () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (20 )
}
func (c *ChatBannedRights ) SetSendRoundvideos (value bool ) {
if value {
c .Flags .Set (21 )
c .SendRoundvideos = true
} else {
c .Flags .Unset (21 )
c .SendRoundvideos = false
}
}
func (c *ChatBannedRights ) GetSendRoundvideos () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (21 )
}
func (c *ChatBannedRights ) SetSendAudios (value bool ) {
if value {
c .Flags .Set (22 )
c .SendAudios = true
} else {
c .Flags .Unset (22 )
c .SendAudios = false
}
}
func (c *ChatBannedRights ) GetSendAudios () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (22 )
}
func (c *ChatBannedRights ) SetSendVoices (value bool ) {
if value {
c .Flags .Set (23 )
c .SendVoices = true
} else {
c .Flags .Unset (23 )
c .SendVoices = false
}
}
func (c *ChatBannedRights ) GetSendVoices () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (23 )
}
func (c *ChatBannedRights ) SetSendDocs (value bool ) {
if value {
c .Flags .Set (24 )
c .SendDocs = true
} else {
c .Flags .Unset (24 )
c .SendDocs = false
}
}
func (c *ChatBannedRights ) GetSendDocs () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (24 )
}
func (c *ChatBannedRights ) SetSendPlain (value bool ) {
if value {
c .Flags .Set (25 )
c .SendPlain = true
} else {
c .Flags .Unset (25 )
c .SendPlain = false
}
}
func (c *ChatBannedRights ) GetSendPlain () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (25 )
}
func (c *ChatBannedRights ) GetUntilDate () (value int ) {
if c == nil {
return
}
return c .UntilDate
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .