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 GlobalPrivacySettings struct {
Flags bin .Fields
ArchiveAndMuteNewNoncontactPeers bool
KeepArchivedUnmuted bool
KeepArchivedFolders bool
}
const GlobalPrivacySettingsTypeID = 0x734c4ccb
var (
_ bin .Encoder = &GlobalPrivacySettings {}
_ bin .Decoder = &GlobalPrivacySettings {}
_ bin .BareEncoder = &GlobalPrivacySettings {}
_ bin .BareDecoder = &GlobalPrivacySettings {}
)
func (g *GlobalPrivacySettings ) Zero () bool {
if g == nil {
return true
}
if !(g .Flags .Zero ()) {
return false
}
if !(g .ArchiveAndMuteNewNoncontactPeers == false ) {
return false
}
if !(g .KeepArchivedUnmuted == false ) {
return false
}
if !(g .KeepArchivedFolders == false ) {
return false
}
return true
}
func (g *GlobalPrivacySettings ) String () string {
if g == nil {
return "GlobalPrivacySettings(nil)"
}
type Alias GlobalPrivacySettings
return fmt .Sprintf ("GlobalPrivacySettings%+v" , Alias (*g ))
}
func (g *GlobalPrivacySettings ) FillFrom (from interface {
GetArchiveAndMuteNewNoncontactPeers () (value bool )
GetKeepArchivedUnmuted () (value bool )
GetKeepArchivedFolders () (value bool )
}) {
g .ArchiveAndMuteNewNoncontactPeers = from .GetArchiveAndMuteNewNoncontactPeers ()
g .KeepArchivedUnmuted = from .GetKeepArchivedUnmuted ()
g .KeepArchivedFolders = from .GetKeepArchivedFolders ()
}
func (*GlobalPrivacySettings ) TypeID () uint32 {
return GlobalPrivacySettingsTypeID
}
func (*GlobalPrivacySettings ) TypeName () string {
return "globalPrivacySettings"
}
func (g *GlobalPrivacySettings ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "globalPrivacySettings" ,
ID : GlobalPrivacySettingsTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ArchiveAndMuteNewNoncontactPeers" ,
SchemaName : "archive_and_mute_new_noncontact_peers" ,
Null : !g .Flags .Has (0 ),
},
{
Name : "KeepArchivedUnmuted" ,
SchemaName : "keep_archived_unmuted" ,
Null : !g .Flags .Has (1 ),
},
{
Name : "KeepArchivedFolders" ,
SchemaName : "keep_archived_folders" ,
Null : !g .Flags .Has (2 ),
},
}
return typ
}
func (g *GlobalPrivacySettings ) SetFlags () {
if !(g .ArchiveAndMuteNewNoncontactPeers == false ) {
g .Flags .Set (0 )
}
if !(g .KeepArchivedUnmuted == false ) {
g .Flags .Set (1 )
}
if !(g .KeepArchivedFolders == false ) {
g .Flags .Set (2 )
}
}
func (g *GlobalPrivacySettings ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode globalPrivacySettings#734c4ccb as nil" )
}
b .PutID (GlobalPrivacySettingsTypeID )
return g .EncodeBare (b )
}
func (g *GlobalPrivacySettings ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode globalPrivacySettings#734c4ccb as nil" )
}
g .SetFlags ()
if err := g .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode globalPrivacySettings#734c4ccb: field flags: %w" , err )
}
return nil
}
func (g *GlobalPrivacySettings ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode globalPrivacySettings#734c4ccb to nil" )
}
if err := b .ConsumeID (GlobalPrivacySettingsTypeID ); err != nil {
return fmt .Errorf ("unable to decode globalPrivacySettings#734c4ccb: %w" , err )
}
return g .DecodeBare (b )
}
func (g *GlobalPrivacySettings ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode globalPrivacySettings#734c4ccb to nil" )
}
{
if err := g .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode globalPrivacySettings#734c4ccb: field flags: %w" , err )
}
}
g .ArchiveAndMuteNewNoncontactPeers = g .Flags .Has (0 )
g .KeepArchivedUnmuted = g .Flags .Has (1 )
g .KeepArchivedFolders = g .Flags .Has (2 )
return nil
}
func (g *GlobalPrivacySettings ) SetArchiveAndMuteNewNoncontactPeers (value bool ) {
if value {
g .Flags .Set (0 )
g .ArchiveAndMuteNewNoncontactPeers = true
} else {
g .Flags .Unset (0 )
g .ArchiveAndMuteNewNoncontactPeers = false
}
}
func (g *GlobalPrivacySettings ) GetArchiveAndMuteNewNoncontactPeers () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (0 )
}
func (g *GlobalPrivacySettings ) SetKeepArchivedUnmuted (value bool ) {
if value {
g .Flags .Set (1 )
g .KeepArchivedUnmuted = true
} else {
g .Flags .Unset (1 )
g .KeepArchivedUnmuted = false
}
}
func (g *GlobalPrivacySettings ) GetKeepArchivedUnmuted () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (1 )
}
func (g *GlobalPrivacySettings ) SetKeepArchivedFolders (value bool ) {
if value {
g .Flags .Set (2 )
g .KeepArchivedFolders = true
} else {
g .Flags .Unset (2 )
g .KeepArchivedFolders = false
}
}
func (g *GlobalPrivacySettings ) GetKeepArchivedFolders () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (2 )
}
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 .