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
BusinessBotPaused bool
BusinessBotCanReply bool
GeoDistance int
RequestChatTitle string
RequestChatDate int
BusinessBotID int64
BusinessBotManageURL string
ChargePaidMessageStars int64
RegistrationMonth string
PhoneCountry string
NameChangeDate int
PhotoChangeDate int
}
const PeerSettingsTypeID = 0xf47741f7
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 .BusinessBotPaused == false ) {
return false
}
if !(p .BusinessBotCanReply == false ) {
return false
}
if !(p .GeoDistance == 0 ) {
return false
}
if !(p .RequestChatTitle == "" ) {
return false
}
if !(p .RequestChatDate == 0 ) {
return false
}
if !(p .BusinessBotID == 0 ) {
return false
}
if !(p .BusinessBotManageURL == "" ) {
return false
}
if !(p .ChargePaidMessageStars == 0 ) {
return false
}
if !(p .RegistrationMonth == "" ) {
return false
}
if !(p .PhoneCountry == "" ) {
return false
}
if !(p .NameChangeDate == 0 ) {
return false
}
if !(p .PhotoChangeDate == 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 )
GetBusinessBotPaused () (value bool )
GetBusinessBotCanReply () (value bool )
GetGeoDistance () (value int , ok bool )
GetRequestChatTitle () (value string , ok bool )
GetRequestChatDate () (value int , ok bool )
GetBusinessBotID () (value int64 , ok bool )
GetBusinessBotManageURL () (value string , ok bool )
GetChargePaidMessageStars () (value int64 , ok bool )
GetRegistrationMonth () (value string , ok bool )
GetPhoneCountry () (value string , ok bool )
GetNameChangeDate () (value int , ok bool )
GetPhotoChangeDate () (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 ()
p .BusinessBotPaused = from .GetBusinessBotPaused ()
p .BusinessBotCanReply = from .GetBusinessBotCanReply ()
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
}
if val , ok := from .GetBusinessBotID (); ok {
p .BusinessBotID = val
}
if val , ok := from .GetBusinessBotManageURL (); ok {
p .BusinessBotManageURL = val
}
if val , ok := from .GetChargePaidMessageStars (); ok {
p .ChargePaidMessageStars = val
}
if val , ok := from .GetRegistrationMonth (); ok {
p .RegistrationMonth = val
}
if val , ok := from .GetPhoneCountry (); ok {
p .PhoneCountry = val
}
if val , ok := from .GetNameChangeDate (); ok {
p .NameChangeDate = val
}
if val , ok := from .GetPhotoChangeDate (); ok {
p .PhotoChangeDate = 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 : "BusinessBotPaused" ,
SchemaName : "business_bot_paused" ,
Null : !p .Flags .Has (11 ),
},
{
Name : "BusinessBotCanReply" ,
SchemaName : "business_bot_can_reply" ,
Null : !p .Flags .Has (12 ),
},
{
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 ),
},
{
Name : "BusinessBotID" ,
SchemaName : "business_bot_id" ,
Null : !p .Flags .Has (13 ),
},
{
Name : "BusinessBotManageURL" ,
SchemaName : "business_bot_manage_url" ,
Null : !p .Flags .Has (13 ),
},
{
Name : "ChargePaidMessageStars" ,
SchemaName : "charge_paid_message_stars" ,
Null : !p .Flags .Has (14 ),
},
{
Name : "RegistrationMonth" ,
SchemaName : "registration_month" ,
Null : !p .Flags .Has (15 ),
},
{
Name : "PhoneCountry" ,
SchemaName : "phone_country" ,
Null : !p .Flags .Has (16 ),
},
{
Name : "NameChangeDate" ,
SchemaName : "name_change_date" ,
Null : !p .Flags .Has (17 ),
},
{
Name : "PhotoChangeDate" ,
SchemaName : "photo_change_date" ,
Null : !p .Flags .Has (18 ),
},
}
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 .BusinessBotPaused == false ) {
p .Flags .Set (11 )
}
if !(p .BusinessBotCanReply == false ) {
p .Flags .Set (12 )
}
if !(p .GeoDistance == 0 ) {
p .Flags .Set (6 )
}
if !(p .RequestChatTitle == "" ) {
p .Flags .Set (9 )
}
if !(p .RequestChatDate == 0 ) {
p .Flags .Set (9 )
}
if !(p .BusinessBotID == 0 ) {
p .Flags .Set (13 )
}
if !(p .BusinessBotManageURL == "" ) {
p .Flags .Set (13 )
}
if !(p .ChargePaidMessageStars == 0 ) {
p .Flags .Set (14 )
}
if !(p .RegistrationMonth == "" ) {
p .Flags .Set (15 )
}
if !(p .PhoneCountry == "" ) {
p .Flags .Set (16 )
}
if !(p .NameChangeDate == 0 ) {
p .Flags .Set (17 )
}
if !(p .PhotoChangeDate == 0 ) {
p .Flags .Set (18 )
}
}
func (p *PeerSettings ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode peerSettings#f47741f7 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#f47741f7 as nil" )
}
p .SetFlags ()
if err := p .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode peerSettings#f47741f7: 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 )
}
if p .Flags .Has (13 ) {
b .PutLong (p .BusinessBotID )
}
if p .Flags .Has (13 ) {
b .PutString (p .BusinessBotManageURL )
}
if p .Flags .Has (14 ) {
b .PutLong (p .ChargePaidMessageStars )
}
if p .Flags .Has (15 ) {
b .PutString (p .RegistrationMonth )
}
if p .Flags .Has (16 ) {
b .PutString (p .PhoneCountry )
}
if p .Flags .Has (17 ) {
b .PutInt (p .NameChangeDate )
}
if p .Flags .Has (18 ) {
b .PutInt (p .PhotoChangeDate )
}
return nil
}
func (p *PeerSettings ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode peerSettings#f47741f7 to nil" )
}
if err := b .ConsumeID (PeerSettingsTypeID ); err != nil {
return fmt .Errorf ("unable to decode peerSettings#f47741f7: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PeerSettings ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode peerSettings#f47741f7 to nil" )
}
{
if err := p .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode peerSettings#f47741f7: 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 )
p .BusinessBotPaused = p .Flags .Has (11 )
p .BusinessBotCanReply = p .Flags .Has (12 )
if p .Flags .Has (6 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode peerSettings#f47741f7: 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#f47741f7: 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#f47741f7: field request_chat_date: %w" , err )
}
p .RequestChatDate = value
}
if p .Flags .Has (13 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode peerSettings#f47741f7: field business_bot_id: %w" , err )
}
p .BusinessBotID = value
}
if p .Flags .Has (13 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode peerSettings#f47741f7: field business_bot_manage_url: %w" , err )
}
p .BusinessBotManageURL = value
}
if p .Flags .Has (14 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode peerSettings#f47741f7: field charge_paid_message_stars: %w" , err )
}
p .ChargePaidMessageStars = value
}
if p .Flags .Has (15 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode peerSettings#f47741f7: field registration_month: %w" , err )
}
p .RegistrationMonth = value
}
if p .Flags .Has (16 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode peerSettings#f47741f7: field phone_country: %w" , err )
}
p .PhoneCountry = value
}
if p .Flags .Has (17 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode peerSettings#f47741f7: field name_change_date: %w" , err )
}
p .NameChangeDate = value
}
if p .Flags .Has (18 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode peerSettings#f47741f7: field photo_change_date: %w" , err )
}
p .PhotoChangeDate = 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 ) SetBusinessBotPaused (value bool ) {
if value {
p .Flags .Set (11 )
p .BusinessBotPaused = true
} else {
p .Flags .Unset (11 )
p .BusinessBotPaused = false
}
}
func (p *PeerSettings ) GetBusinessBotPaused () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (11 )
}
func (p *PeerSettings ) SetBusinessBotCanReply (value bool ) {
if value {
p .Flags .Set (12 )
p .BusinessBotCanReply = true
} else {
p .Flags .Unset (12 )
p .BusinessBotCanReply = false
}
}
func (p *PeerSettings ) GetBusinessBotCanReply () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (12 )
}
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
}
func (p *PeerSettings ) SetBusinessBotID (value int64 ) {
p .Flags .Set (13 )
p .BusinessBotID = value
}
func (p *PeerSettings ) GetBusinessBotID () (value int64 , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (13 ) {
return value , false
}
return p .BusinessBotID , true
}
func (p *PeerSettings ) SetBusinessBotManageURL (value string ) {
p .Flags .Set (13 )
p .BusinessBotManageURL = value
}
func (p *PeerSettings ) GetBusinessBotManageURL () (value string , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (13 ) {
return value , false
}
return p .BusinessBotManageURL , true
}
func (p *PeerSettings ) SetChargePaidMessageStars (value int64 ) {
p .Flags .Set (14 )
p .ChargePaidMessageStars = value
}
func (p *PeerSettings ) GetChargePaidMessageStars () (value int64 , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (14 ) {
return value , false
}
return p .ChargePaidMessageStars , true
}
func (p *PeerSettings ) SetRegistrationMonth (value string ) {
p .Flags .Set (15 )
p .RegistrationMonth = value
}
func (p *PeerSettings ) GetRegistrationMonth () (value string , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (15 ) {
return value , false
}
return p .RegistrationMonth , true
}
func (p *PeerSettings ) SetPhoneCountry (value string ) {
p .Flags .Set (16 )
p .PhoneCountry = value
}
func (p *PeerSettings ) GetPhoneCountry () (value string , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (16 ) {
return value , false
}
return p .PhoneCountry , true
}
func (p *PeerSettings ) SetNameChangeDate (value int ) {
p .Flags .Set (17 )
p .NameChangeDate = value
}
func (p *PeerSettings ) GetNameChangeDate () (value int , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (17 ) {
return value , false
}
return p .NameChangeDate , true
}
func (p *PeerSettings ) SetPhotoChangeDate (value int ) {
p .Flags .Set (18 )
p .PhotoChangeDate = value
}
func (p *PeerSettings ) GetPhotoChangeDate () (value int , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (18 ) {
return value , false
}
return p .PhotoChangeDate , 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 .