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 ChatAdminRights struct {
Flags bin .Fields
ChangeInfo bool
PostMessages bool
EditMessages bool
DeleteMessages bool
BanUsers bool
InviteUsers bool
PinMessages bool
AddAdmins bool
Anonymous bool
ManageCall bool
Other bool
ManageTopics bool
PostStories bool
EditStories bool
DeleteStories bool
}
const ChatAdminRightsTypeID = 0x5fb224d5
var (
_ bin .Encoder = &ChatAdminRights {}
_ bin .Decoder = &ChatAdminRights {}
_ bin .BareEncoder = &ChatAdminRights {}
_ bin .BareDecoder = &ChatAdminRights {}
)
func (c *ChatAdminRights ) Zero () bool {
if c == nil {
return true
}
if !(c .Flags .Zero ()) {
return false
}
if !(c .ChangeInfo == false ) {
return false
}
if !(c .PostMessages == false ) {
return false
}
if !(c .EditMessages == false ) {
return false
}
if !(c .DeleteMessages == false ) {
return false
}
if !(c .BanUsers == false ) {
return false
}
if !(c .InviteUsers == false ) {
return false
}
if !(c .PinMessages == false ) {
return false
}
if !(c .AddAdmins == false ) {
return false
}
if !(c .Anonymous == false ) {
return false
}
if !(c .ManageCall == false ) {
return false
}
if !(c .Other == false ) {
return false
}
if !(c .ManageTopics == false ) {
return false
}
if !(c .PostStories == false ) {
return false
}
if !(c .EditStories == false ) {
return false
}
if !(c .DeleteStories == false ) {
return false
}
return true
}
func (c *ChatAdminRights ) String () string {
if c == nil {
return "ChatAdminRights(nil)"
}
type Alias ChatAdminRights
return fmt .Sprintf ("ChatAdminRights%+v" , Alias (*c ))
}
func (c *ChatAdminRights ) FillFrom (from interface {
GetChangeInfo () (value bool )
GetPostMessages () (value bool )
GetEditMessages () (value bool )
GetDeleteMessages () (value bool )
GetBanUsers () (value bool )
GetInviteUsers () (value bool )
GetPinMessages () (value bool )
GetAddAdmins () (value bool )
GetAnonymous () (value bool )
GetManageCall () (value bool )
GetOther () (value bool )
GetManageTopics () (value bool )
GetPostStories () (value bool )
GetEditStories () (value bool )
GetDeleteStories () (value bool )
}) {
c .ChangeInfo = from .GetChangeInfo ()
c .PostMessages = from .GetPostMessages ()
c .EditMessages = from .GetEditMessages ()
c .DeleteMessages = from .GetDeleteMessages ()
c .BanUsers = from .GetBanUsers ()
c .InviteUsers = from .GetInviteUsers ()
c .PinMessages = from .GetPinMessages ()
c .AddAdmins = from .GetAddAdmins ()
c .Anonymous = from .GetAnonymous ()
c .ManageCall = from .GetManageCall ()
c .Other = from .GetOther ()
c .ManageTopics = from .GetManageTopics ()
c .PostStories = from .GetPostStories ()
c .EditStories = from .GetEditStories ()
c .DeleteStories = from .GetDeleteStories ()
}
func (*ChatAdminRights ) TypeID () uint32 {
return ChatAdminRightsTypeID
}
func (*ChatAdminRights ) TypeName () string {
return "chatAdminRights"
}
func (c *ChatAdminRights ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "chatAdminRights" ,
ID : ChatAdminRightsTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ChangeInfo" ,
SchemaName : "change_info" ,
Null : !c .Flags .Has (0 ),
},
{
Name : "PostMessages" ,
SchemaName : "post_messages" ,
Null : !c .Flags .Has (1 ),
},
{
Name : "EditMessages" ,
SchemaName : "edit_messages" ,
Null : !c .Flags .Has (2 ),
},
{
Name : "DeleteMessages" ,
SchemaName : "delete_messages" ,
Null : !c .Flags .Has (3 ),
},
{
Name : "BanUsers" ,
SchemaName : "ban_users" ,
Null : !c .Flags .Has (4 ),
},
{
Name : "InviteUsers" ,
SchemaName : "invite_users" ,
Null : !c .Flags .Has (5 ),
},
{
Name : "PinMessages" ,
SchemaName : "pin_messages" ,
Null : !c .Flags .Has (7 ),
},
{
Name : "AddAdmins" ,
SchemaName : "add_admins" ,
Null : !c .Flags .Has (9 ),
},
{
Name : "Anonymous" ,
SchemaName : "anonymous" ,
Null : !c .Flags .Has (10 ),
},
{
Name : "ManageCall" ,
SchemaName : "manage_call" ,
Null : !c .Flags .Has (11 ),
},
{
Name : "Other" ,
SchemaName : "other" ,
Null : !c .Flags .Has (12 ),
},
{
Name : "ManageTopics" ,
SchemaName : "manage_topics" ,
Null : !c .Flags .Has (13 ),
},
{
Name : "PostStories" ,
SchemaName : "post_stories" ,
Null : !c .Flags .Has (14 ),
},
{
Name : "EditStories" ,
SchemaName : "edit_stories" ,
Null : !c .Flags .Has (15 ),
},
{
Name : "DeleteStories" ,
SchemaName : "delete_stories" ,
Null : !c .Flags .Has (16 ),
},
}
return typ
}
func (c *ChatAdminRights ) SetFlags () {
if !(c .ChangeInfo == false ) {
c .Flags .Set (0 )
}
if !(c .PostMessages == false ) {
c .Flags .Set (1 )
}
if !(c .EditMessages == false ) {
c .Flags .Set (2 )
}
if !(c .DeleteMessages == false ) {
c .Flags .Set (3 )
}
if !(c .BanUsers == false ) {
c .Flags .Set (4 )
}
if !(c .InviteUsers == false ) {
c .Flags .Set (5 )
}
if !(c .PinMessages == false ) {
c .Flags .Set (7 )
}
if !(c .AddAdmins == false ) {
c .Flags .Set (9 )
}
if !(c .Anonymous == false ) {
c .Flags .Set (10 )
}
if !(c .ManageCall == false ) {
c .Flags .Set (11 )
}
if !(c .Other == false ) {
c .Flags .Set (12 )
}
if !(c .ManageTopics == false ) {
c .Flags .Set (13 )
}
if !(c .PostStories == false ) {
c .Flags .Set (14 )
}
if !(c .EditStories == false ) {
c .Flags .Set (15 )
}
if !(c .DeleteStories == false ) {
c .Flags .Set (16 )
}
}
func (c *ChatAdminRights ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatAdminRights#5fb224d5 as nil" )
}
b .PutID (ChatAdminRightsTypeID )
return c .EncodeBare (b )
}
func (c *ChatAdminRights ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode chatAdminRights#5fb224d5 as nil" )
}
c .SetFlags ()
if err := c .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode chatAdminRights#5fb224d5: field flags: %w" , err )
}
return nil
}
func (c *ChatAdminRights ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatAdminRights#5fb224d5 to nil" )
}
if err := b .ConsumeID (ChatAdminRightsTypeID ); err != nil {
return fmt .Errorf ("unable to decode chatAdminRights#5fb224d5: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChatAdminRights ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode chatAdminRights#5fb224d5 to nil" )
}
{
if err := c .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode chatAdminRights#5fb224d5: field flags: %w" , err )
}
}
c .ChangeInfo = c .Flags .Has (0 )
c .PostMessages = c .Flags .Has (1 )
c .EditMessages = c .Flags .Has (2 )
c .DeleteMessages = c .Flags .Has (3 )
c .BanUsers = c .Flags .Has (4 )
c .InviteUsers = c .Flags .Has (5 )
c .PinMessages = c .Flags .Has (7 )
c .AddAdmins = c .Flags .Has (9 )
c .Anonymous = c .Flags .Has (10 )
c .ManageCall = c .Flags .Has (11 )
c .Other = c .Flags .Has (12 )
c .ManageTopics = c .Flags .Has (13 )
c .PostStories = c .Flags .Has (14 )
c .EditStories = c .Flags .Has (15 )
c .DeleteStories = c .Flags .Has (16 )
return nil
}
func (c *ChatAdminRights ) SetChangeInfo (value bool ) {
if value {
c .Flags .Set (0 )
c .ChangeInfo = true
} else {
c .Flags .Unset (0 )
c .ChangeInfo = false
}
}
func (c *ChatAdminRights ) GetChangeInfo () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (0 )
}
func (c *ChatAdminRights ) SetPostMessages (value bool ) {
if value {
c .Flags .Set (1 )
c .PostMessages = true
} else {
c .Flags .Unset (1 )
c .PostMessages = false
}
}
func (c *ChatAdminRights ) GetPostMessages () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (1 )
}
func (c *ChatAdminRights ) SetEditMessages (value bool ) {
if value {
c .Flags .Set (2 )
c .EditMessages = true
} else {
c .Flags .Unset (2 )
c .EditMessages = false
}
}
func (c *ChatAdminRights ) GetEditMessages () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (2 )
}
func (c *ChatAdminRights ) SetDeleteMessages (value bool ) {
if value {
c .Flags .Set (3 )
c .DeleteMessages = true
} else {
c .Flags .Unset (3 )
c .DeleteMessages = false
}
}
func (c *ChatAdminRights ) GetDeleteMessages () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (3 )
}
func (c *ChatAdminRights ) SetBanUsers (value bool ) {
if value {
c .Flags .Set (4 )
c .BanUsers = true
} else {
c .Flags .Unset (4 )
c .BanUsers = false
}
}
func (c *ChatAdminRights ) GetBanUsers () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (4 )
}
func (c *ChatAdminRights ) SetInviteUsers (value bool ) {
if value {
c .Flags .Set (5 )
c .InviteUsers = true
} else {
c .Flags .Unset (5 )
c .InviteUsers = false
}
}
func (c *ChatAdminRights ) GetInviteUsers () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (5 )
}
func (c *ChatAdminRights ) SetPinMessages (value bool ) {
if value {
c .Flags .Set (7 )
c .PinMessages = true
} else {
c .Flags .Unset (7 )
c .PinMessages = false
}
}
func (c *ChatAdminRights ) GetPinMessages () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (7 )
}
func (c *ChatAdminRights ) SetAddAdmins (value bool ) {
if value {
c .Flags .Set (9 )
c .AddAdmins = true
} else {
c .Flags .Unset (9 )
c .AddAdmins = false
}
}
func (c *ChatAdminRights ) GetAddAdmins () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (9 )
}
func (c *ChatAdminRights ) SetAnonymous (value bool ) {
if value {
c .Flags .Set (10 )
c .Anonymous = true
} else {
c .Flags .Unset (10 )
c .Anonymous = false
}
}
func (c *ChatAdminRights ) GetAnonymous () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (10 )
}
func (c *ChatAdminRights ) SetManageCall (value bool ) {
if value {
c .Flags .Set (11 )
c .ManageCall = true
} else {
c .Flags .Unset (11 )
c .ManageCall = false
}
}
func (c *ChatAdminRights ) GetManageCall () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (11 )
}
func (c *ChatAdminRights ) SetOther (value bool ) {
if value {
c .Flags .Set (12 )
c .Other = true
} else {
c .Flags .Unset (12 )
c .Other = false
}
}
func (c *ChatAdminRights ) GetOther () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (12 )
}
func (c *ChatAdminRights ) SetManageTopics (value bool ) {
if value {
c .Flags .Set (13 )
c .ManageTopics = true
} else {
c .Flags .Unset (13 )
c .ManageTopics = false
}
}
func (c *ChatAdminRights ) GetManageTopics () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (13 )
}
func (c *ChatAdminRights ) SetPostStories (value bool ) {
if value {
c .Flags .Set (14 )
c .PostStories = true
} else {
c .Flags .Unset (14 )
c .PostStories = false
}
}
func (c *ChatAdminRights ) GetPostStories () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (14 )
}
func (c *ChatAdminRights ) SetEditStories (value bool ) {
if value {
c .Flags .Set (15 )
c .EditStories = true
} else {
c .Flags .Unset (15 )
c .EditStories = false
}
}
func (c *ChatAdminRights ) GetEditStories () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (15 )
}
func (c *ChatAdminRights ) SetDeleteStories (value bool ) {
if value {
c .Flags .Set (16 )
c .DeleteStories = true
} else {
c .Flags .Unset (16 )
c .DeleteStories = false
}
}
func (c *ChatAdminRights ) GetDeleteStories () (value bool ) {
if c == nil {
return
}
return c .Flags .Has (16 )
}
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 .