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 PeerSettings struct {
Flags bin .Fields
ReportSpam bool
AddContact bool
BlockContact bool
ShareContact bool
NeedContactsException bool
ReportGeo bool
Autoarchived bool
InviteMembers bool
RequestChatBroadcast bool
GeoDistance int
RequestChatTitle string
RequestChatDate int
}
const PeerSettingsTypeID = 0xa518110d
var (
_ bin .Encoder = &PeerSettings {}
_ bin .Decoder = &PeerSettings {}
_ bin .BareEncoder = &PeerSettings {}
_ bin .BareDecoder = &PeerSettings {}
)
func (p *PeerSettings ) Zero () bool {
if p == nil {
return true
}
if !(p .Flags .Zero ()) {
return false
}
if !(p .ReportSpam == false ) {
return false
}
if !(p .AddContact == false ) {
return false
}
if !(p .BlockContact == false ) {
return false
}
if !(p .ShareContact == false ) {
return false
}
if !(p .NeedContactsException == false ) {
return false
}
if !(p .ReportGeo == false ) {
return false
}
if !(p .Autoarchived == false ) {
return false
}
if !(p .InviteMembers == false ) {
return false
}
if !(p .RequestChatBroadcast == false ) {
return false
}
if !(p .GeoDistance == 0 ) {
return false
}
if !(p .RequestChatTitle == "" ) {
return false
}
if !(p .RequestChatDate == 0 ) {
return false
}
return true
}
func (p *PeerSettings ) String () string {
if p == nil {
return "PeerSettings(nil)"
}
type Alias PeerSettings
return fmt .Sprintf ("PeerSettings%+v" , Alias (*p ))
}
func (p *PeerSettings ) FillFrom (from interface {
GetReportSpam () (value bool )
GetAddContact () (value bool )
GetBlockContact () (value bool )
GetShareContact () (value bool )
GetNeedContactsException () (value bool )
GetReportGeo () (value bool )
GetAutoarchived () (value bool )
GetInviteMembers () (value bool )
GetRequestChatBroadcast () (value bool )
GetGeoDistance () (value int , ok bool )
GetRequestChatTitle () (value string , ok bool )
GetRequestChatDate () (value int , ok bool )
}) {
p .ReportSpam = from .GetReportSpam ()
p .AddContact = from .GetAddContact ()
p .BlockContact = from .GetBlockContact ()
p .ShareContact = from .GetShareContact ()
p .NeedContactsException = from .GetNeedContactsException ()
p .ReportGeo = from .GetReportGeo ()
p .Autoarchived = from .GetAutoarchived ()
p .InviteMembers = from .GetInviteMembers ()
p .RequestChatBroadcast = from .GetRequestChatBroadcast ()
if val , ok := from .GetGeoDistance (); ok {
p .GeoDistance = val
}
if val , ok := from .GetRequestChatTitle (); ok {
p .RequestChatTitle = val
}
if val , ok := from .GetRequestChatDate (); ok {
p .RequestChatDate = val
}
}
func (*PeerSettings ) TypeID () uint32 {
return PeerSettingsTypeID
}
func (*PeerSettings ) TypeName () string {
return "peerSettings"
}
func (p *PeerSettings ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "peerSettings" ,
ID : PeerSettingsTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ReportSpam" ,
SchemaName : "report_spam" ,
Null : !p .Flags .Has (0 ),
},
{
Name : "AddContact" ,
SchemaName : "add_contact" ,
Null : !p .Flags .Has (1 ),
},
{
Name : "BlockContact" ,
SchemaName : "block_contact" ,
Null : !p .Flags .Has (2 ),
},
{
Name : "ShareContact" ,
SchemaName : "share_contact" ,
Null : !p .Flags .Has (3 ),
},
{
Name : "NeedContactsException" ,
SchemaName : "need_contacts_exception" ,
Null : !p .Flags .Has (4 ),
},
{
Name : "ReportGeo" ,
SchemaName : "report_geo" ,
Null : !p .Flags .Has (5 ),
},
{
Name : "Autoarchived" ,
SchemaName : "autoarchived" ,
Null : !p .Flags .Has (7 ),
},
{
Name : "InviteMembers" ,
SchemaName : "invite_members" ,
Null : !p .Flags .Has (8 ),
},
{
Name : "RequestChatBroadcast" ,
SchemaName : "request_chat_broadcast" ,
Null : !p .Flags .Has (10 ),
},
{
Name : "GeoDistance" ,
SchemaName : "geo_distance" ,
Null : !p .Flags .Has (6 ),
},
{
Name : "RequestChatTitle" ,
SchemaName : "request_chat_title" ,
Null : !p .Flags .Has (9 ),
},
{
Name : "RequestChatDate" ,
SchemaName : "request_chat_date" ,
Null : !p .Flags .Has (9 ),
},
}
return typ
}
func (p *PeerSettings ) SetFlags () {
if !(p .ReportSpam == false ) {
p .Flags .Set (0 )
}
if !(p .AddContact == false ) {
p .Flags .Set (1 )
}
if !(p .BlockContact == false ) {
p .Flags .Set (2 )
}
if !(p .ShareContact == false ) {
p .Flags .Set (3 )
}
if !(p .NeedContactsException == false ) {
p .Flags .Set (4 )
}
if !(p .ReportGeo == false ) {
p .Flags .Set (5 )
}
if !(p .Autoarchived == false ) {
p .Flags .Set (7 )
}
if !(p .InviteMembers == false ) {
p .Flags .Set (8 )
}
if !(p .RequestChatBroadcast == false ) {
p .Flags .Set (10 )
}
if !(p .GeoDistance == 0 ) {
p .Flags .Set (6 )
}
if !(p .RequestChatTitle == "" ) {
p .Flags .Set (9 )
}
if !(p .RequestChatDate == 0 ) {
p .Flags .Set (9 )
}
}
func (p *PeerSettings ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode peerSettings#a518110d as nil" )
}
b .PutID (PeerSettingsTypeID )
return p .EncodeBare (b )
}
func (p *PeerSettings ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode peerSettings#a518110d as nil" )
}
p .SetFlags ()
if err := p .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode peerSettings#a518110d: field flags: %w" , err )
}
if p .Flags .Has (6 ) {
b .PutInt (p .GeoDistance )
}
if p .Flags .Has (9 ) {
b .PutString (p .RequestChatTitle )
}
if p .Flags .Has (9 ) {
b .PutInt (p .RequestChatDate )
}
return nil
}
func (p *PeerSettings ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode peerSettings#a518110d to nil" )
}
if err := b .ConsumeID (PeerSettingsTypeID ); err != nil {
return fmt .Errorf ("unable to decode peerSettings#a518110d: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PeerSettings ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode peerSettings#a518110d to nil" )
}
{
if err := p .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode peerSettings#a518110d: field flags: %w" , err )
}
}
p .ReportSpam = p .Flags .Has (0 )
p .AddContact = p .Flags .Has (1 )
p .BlockContact = p .Flags .Has (2 )
p .ShareContact = p .Flags .Has (3 )
p .NeedContactsException = p .Flags .Has (4 )
p .ReportGeo = p .Flags .Has (5 )
p .Autoarchived = p .Flags .Has (7 )
p .InviteMembers = p .Flags .Has (8 )
p .RequestChatBroadcast = p .Flags .Has (10 )
if p .Flags .Has (6 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode peerSettings#a518110d: field geo_distance: %w" , err )
}
p .GeoDistance = value
}
if p .Flags .Has (9 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode peerSettings#a518110d: field request_chat_title: %w" , err )
}
p .RequestChatTitle = value
}
if p .Flags .Has (9 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode peerSettings#a518110d: field request_chat_date: %w" , err )
}
p .RequestChatDate = value
}
return nil
}
func (p *PeerSettings ) SetReportSpam (value bool ) {
if value {
p .Flags .Set (0 )
p .ReportSpam = true
} else {
p .Flags .Unset (0 )
p .ReportSpam = false
}
}
func (p *PeerSettings ) GetReportSpam () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (0 )
}
func (p *PeerSettings ) SetAddContact (value bool ) {
if value {
p .Flags .Set (1 )
p .AddContact = true
} else {
p .Flags .Unset (1 )
p .AddContact = false
}
}
func (p *PeerSettings ) GetAddContact () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (1 )
}
func (p *PeerSettings ) SetBlockContact (value bool ) {
if value {
p .Flags .Set (2 )
p .BlockContact = true
} else {
p .Flags .Unset (2 )
p .BlockContact = false
}
}
func (p *PeerSettings ) GetBlockContact () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (2 )
}
func (p *PeerSettings ) SetShareContact (value bool ) {
if value {
p .Flags .Set (3 )
p .ShareContact = true
} else {
p .Flags .Unset (3 )
p .ShareContact = false
}
}
func (p *PeerSettings ) GetShareContact () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (3 )
}
func (p *PeerSettings ) SetNeedContactsException (value bool ) {
if value {
p .Flags .Set (4 )
p .NeedContactsException = true
} else {
p .Flags .Unset (4 )
p .NeedContactsException = false
}
}
func (p *PeerSettings ) GetNeedContactsException () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (4 )
}
func (p *PeerSettings ) SetReportGeo (value bool ) {
if value {
p .Flags .Set (5 )
p .ReportGeo = true
} else {
p .Flags .Unset (5 )
p .ReportGeo = false
}
}
func (p *PeerSettings ) GetReportGeo () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (5 )
}
func (p *PeerSettings ) SetAutoarchived (value bool ) {
if value {
p .Flags .Set (7 )
p .Autoarchived = true
} else {
p .Flags .Unset (7 )
p .Autoarchived = false
}
}
func (p *PeerSettings ) GetAutoarchived () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (7 )
}
func (p *PeerSettings ) SetInviteMembers (value bool ) {
if value {
p .Flags .Set (8 )
p .InviteMembers = true
} else {
p .Flags .Unset (8 )
p .InviteMembers = false
}
}
func (p *PeerSettings ) GetInviteMembers () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (8 )
}
func (p *PeerSettings ) SetRequestChatBroadcast (value bool ) {
if value {
p .Flags .Set (10 )
p .RequestChatBroadcast = true
} else {
p .Flags .Unset (10 )
p .RequestChatBroadcast = false
}
}
func (p *PeerSettings ) GetRequestChatBroadcast () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (10 )
}
func (p *PeerSettings ) SetGeoDistance (value int ) {
p .Flags .Set (6 )
p .GeoDistance = value
}
func (p *PeerSettings ) GetGeoDistance () (value int , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (6 ) {
return value , false
}
return p .GeoDistance , true
}
func (p *PeerSettings ) SetRequestChatTitle (value string ) {
p .Flags .Set (9 )
p .RequestChatTitle = value
}
func (p *PeerSettings ) GetRequestChatTitle () (value string , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (9 ) {
return value , false
}
return p .RequestChatTitle , true
}
func (p *PeerSettings ) SetRequestChatDate (value int ) {
p .Flags .Set (9 )
p .RequestChatDate = value
}
func (p *PeerSettings ) GetRequestChatDate () (value int , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (9 ) {
return value , false
}
return p .RequestChatDate , true
}
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 .