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
HideReadMarks bool
NewNoncontactPeersRequirePremium bool
DisplayGiftsButton bool
NoncontactPeersPaidStars int64
DisallowedGifts DisallowedGiftsSettings
}
const GlobalPrivacySettingsTypeID = 0xfe41b34f
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
}
if !(g .HideReadMarks == false ) {
return false
}
if !(g .NewNoncontactPeersRequirePremium == false ) {
return false
}
if !(g .DisplayGiftsButton == false ) {
return false
}
if !(g .NoncontactPeersPaidStars == 0 ) {
return false
}
if !(g .DisallowedGifts .Zero ()) {
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 )
GetHideReadMarks () (value bool )
GetNewNoncontactPeersRequirePremium () (value bool )
GetDisplayGiftsButton () (value bool )
GetNoncontactPeersPaidStars () (value int64 , ok bool )
GetDisallowedGifts () (value DisallowedGiftsSettings , ok bool )
}) {
g .ArchiveAndMuteNewNoncontactPeers = from .GetArchiveAndMuteNewNoncontactPeers ()
g .KeepArchivedUnmuted = from .GetKeepArchivedUnmuted ()
g .KeepArchivedFolders = from .GetKeepArchivedFolders ()
g .HideReadMarks = from .GetHideReadMarks ()
g .NewNoncontactPeersRequirePremium = from .GetNewNoncontactPeersRequirePremium ()
g .DisplayGiftsButton = from .GetDisplayGiftsButton ()
if val , ok := from .GetNoncontactPeersPaidStars (); ok {
g .NoncontactPeersPaidStars = val
}
if val , ok := from .GetDisallowedGifts (); ok {
g .DisallowedGifts = val
}
}
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 ),
},
{
Name : "HideReadMarks" ,
SchemaName : "hide_read_marks" ,
Null : !g .Flags .Has (3 ),
},
{
Name : "NewNoncontactPeersRequirePremium" ,
SchemaName : "new_noncontact_peers_require_premium" ,
Null : !g .Flags .Has (4 ),
},
{
Name : "DisplayGiftsButton" ,
SchemaName : "display_gifts_button" ,
Null : !g .Flags .Has (7 ),
},
{
Name : "NoncontactPeersPaidStars" ,
SchemaName : "noncontact_peers_paid_stars" ,
Null : !g .Flags .Has (5 ),
},
{
Name : "DisallowedGifts" ,
SchemaName : "disallowed_gifts" ,
Null : !g .Flags .Has (6 ),
},
}
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 )
}
if !(g .HideReadMarks == false ) {
g .Flags .Set (3 )
}
if !(g .NewNoncontactPeersRequirePremium == false ) {
g .Flags .Set (4 )
}
if !(g .DisplayGiftsButton == false ) {
g .Flags .Set (7 )
}
if !(g .NoncontactPeersPaidStars == 0 ) {
g .Flags .Set (5 )
}
if !(g .DisallowedGifts .Zero ()) {
g .Flags .Set (6 )
}
}
func (g *GlobalPrivacySettings ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode globalPrivacySettings#fe41b34f 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#fe41b34f as nil" )
}
g .SetFlags ()
if err := g .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode globalPrivacySettings#fe41b34f: field flags: %w" , err )
}
if g .Flags .Has (5 ) {
b .PutLong (g .NoncontactPeersPaidStars )
}
if g .Flags .Has (6 ) {
if err := g .DisallowedGifts .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode globalPrivacySettings#fe41b34f: field disallowed_gifts: %w" , err )
}
}
return nil
}
func (g *GlobalPrivacySettings ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode globalPrivacySettings#fe41b34f to nil" )
}
if err := b .ConsumeID (GlobalPrivacySettingsTypeID ); err != nil {
return fmt .Errorf ("unable to decode globalPrivacySettings#fe41b34f: %w" , err )
}
return g .DecodeBare (b )
}
func (g *GlobalPrivacySettings ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode globalPrivacySettings#fe41b34f to nil" )
}
{
if err := g .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode globalPrivacySettings#fe41b34f: field flags: %w" , err )
}
}
g .ArchiveAndMuteNewNoncontactPeers = g .Flags .Has (0 )
g .KeepArchivedUnmuted = g .Flags .Has (1 )
g .KeepArchivedFolders = g .Flags .Has (2 )
g .HideReadMarks = g .Flags .Has (3 )
g .NewNoncontactPeersRequirePremium = g .Flags .Has (4 )
g .DisplayGiftsButton = g .Flags .Has (7 )
if g .Flags .Has (5 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode globalPrivacySettings#fe41b34f: field noncontact_peers_paid_stars: %w" , err )
}
g .NoncontactPeersPaidStars = value
}
if g .Flags .Has (6 ) {
if err := g .DisallowedGifts .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode globalPrivacySettings#fe41b34f: field disallowed_gifts: %w" , err )
}
}
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 )
}
func (g *GlobalPrivacySettings ) SetHideReadMarks (value bool ) {
if value {
g .Flags .Set (3 )
g .HideReadMarks = true
} else {
g .Flags .Unset (3 )
g .HideReadMarks = false
}
}
func (g *GlobalPrivacySettings ) GetHideReadMarks () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (3 )
}
func (g *GlobalPrivacySettings ) SetNewNoncontactPeersRequirePremium (value bool ) {
if value {
g .Flags .Set (4 )
g .NewNoncontactPeersRequirePremium = true
} else {
g .Flags .Unset (4 )
g .NewNoncontactPeersRequirePremium = false
}
}
func (g *GlobalPrivacySettings ) GetNewNoncontactPeersRequirePremium () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (4 )
}
func (g *GlobalPrivacySettings ) SetDisplayGiftsButton (value bool ) {
if value {
g .Flags .Set (7 )
g .DisplayGiftsButton = true
} else {
g .Flags .Unset (7 )
g .DisplayGiftsButton = false
}
}
func (g *GlobalPrivacySettings ) GetDisplayGiftsButton () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (7 )
}
func (g *GlobalPrivacySettings ) SetNoncontactPeersPaidStars (value int64 ) {
g .Flags .Set (5 )
g .NoncontactPeersPaidStars = value
}
func (g *GlobalPrivacySettings ) GetNoncontactPeersPaidStars () (value int64 , ok bool ) {
if g == nil {
return
}
if !g .Flags .Has (5 ) {
return value , false
}
return g .NoncontactPeersPaidStars , true
}
func (g *GlobalPrivacySettings ) SetDisallowedGifts (value DisallowedGiftsSettings ) {
g .Flags .Set (6 )
g .DisallowedGifts = value
}
func (g *GlobalPrivacySettings ) GetDisallowedGifts () (value DisallowedGiftsSettings , ok bool ) {
if g == nil {
return
}
if !g .Flags .Has (6 ) {
return value , false
}
return g .DisallowedGifts , true
}
The pages are generated with Golds v0.8.4 . (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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .