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 ContactsGetTopPeersRequest struct {
Flags bin .Fields
Correspondents bool
BotsPm bool
BotsInline bool
PhoneCalls bool
ForwardUsers bool
ForwardChats bool
Groups bool
Channels bool
Offset int
Limit int
Hash int64
}
const ContactsGetTopPeersRequestTypeID = 0x973478b6
var (
_ bin .Encoder = &ContactsGetTopPeersRequest {}
_ bin .Decoder = &ContactsGetTopPeersRequest {}
_ bin .BareEncoder = &ContactsGetTopPeersRequest {}
_ bin .BareDecoder = &ContactsGetTopPeersRequest {}
)
func (g *ContactsGetTopPeersRequest ) Zero () bool {
if g == nil {
return true
}
if !(g .Flags .Zero ()) {
return false
}
if !(g .Correspondents == false ) {
return false
}
if !(g .BotsPm == false ) {
return false
}
if !(g .BotsInline == false ) {
return false
}
if !(g .PhoneCalls == false ) {
return false
}
if !(g .ForwardUsers == false ) {
return false
}
if !(g .ForwardChats == false ) {
return false
}
if !(g .Groups == false ) {
return false
}
if !(g .Channels == false ) {
return false
}
if !(g .Offset == 0 ) {
return false
}
if !(g .Limit == 0 ) {
return false
}
if !(g .Hash == 0 ) {
return false
}
return true
}
func (g *ContactsGetTopPeersRequest ) String () string {
if g == nil {
return "ContactsGetTopPeersRequest(nil)"
}
type Alias ContactsGetTopPeersRequest
return fmt .Sprintf ("ContactsGetTopPeersRequest%+v" , Alias (*g ))
}
func (g *ContactsGetTopPeersRequest ) FillFrom (from interface {
GetCorrespondents () (value bool )
GetBotsPm () (value bool )
GetBotsInline () (value bool )
GetPhoneCalls () (value bool )
GetForwardUsers () (value bool )
GetForwardChats () (value bool )
GetGroups () (value bool )
GetChannels () (value bool )
GetOffset () (value int )
GetLimit () (value int )
GetHash () (value int64 )
}) {
g .Correspondents = from .GetCorrespondents ()
g .BotsPm = from .GetBotsPm ()
g .BotsInline = from .GetBotsInline ()
g .PhoneCalls = from .GetPhoneCalls ()
g .ForwardUsers = from .GetForwardUsers ()
g .ForwardChats = from .GetForwardChats ()
g .Groups = from .GetGroups ()
g .Channels = from .GetChannels ()
g .Offset = from .GetOffset ()
g .Limit = from .GetLimit ()
g .Hash = from .GetHash ()
}
func (*ContactsGetTopPeersRequest ) TypeID () uint32 {
return ContactsGetTopPeersRequestTypeID
}
func (*ContactsGetTopPeersRequest ) TypeName () string {
return "contacts.getTopPeers"
}
func (g *ContactsGetTopPeersRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "contacts.getTopPeers" ,
ID : ContactsGetTopPeersRequestTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Correspondents" ,
SchemaName : "correspondents" ,
Null : !g .Flags .Has (0 ),
},
{
Name : "BotsPm" ,
SchemaName : "bots_pm" ,
Null : !g .Flags .Has (1 ),
},
{
Name : "BotsInline" ,
SchemaName : "bots_inline" ,
Null : !g .Flags .Has (2 ),
},
{
Name : "PhoneCalls" ,
SchemaName : "phone_calls" ,
Null : !g .Flags .Has (3 ),
},
{
Name : "ForwardUsers" ,
SchemaName : "forward_users" ,
Null : !g .Flags .Has (4 ),
},
{
Name : "ForwardChats" ,
SchemaName : "forward_chats" ,
Null : !g .Flags .Has (5 ),
},
{
Name : "Groups" ,
SchemaName : "groups" ,
Null : !g .Flags .Has (10 ),
},
{
Name : "Channels" ,
SchemaName : "channels" ,
Null : !g .Flags .Has (15 ),
},
{
Name : "Offset" ,
SchemaName : "offset" ,
},
{
Name : "Limit" ,
SchemaName : "limit" ,
},
{
Name : "Hash" ,
SchemaName : "hash" ,
},
}
return typ
}
func (g *ContactsGetTopPeersRequest ) SetFlags () {
if !(g .Correspondents == false ) {
g .Flags .Set (0 )
}
if !(g .BotsPm == false ) {
g .Flags .Set (1 )
}
if !(g .BotsInline == false ) {
g .Flags .Set (2 )
}
if !(g .PhoneCalls == false ) {
g .Flags .Set (3 )
}
if !(g .ForwardUsers == false ) {
g .Flags .Set (4 )
}
if !(g .ForwardChats == false ) {
g .Flags .Set (5 )
}
if !(g .Groups == false ) {
g .Flags .Set (10 )
}
if !(g .Channels == false ) {
g .Flags .Set (15 )
}
}
func (g *ContactsGetTopPeersRequest ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode contacts.getTopPeers#973478b6 as nil" )
}
b .PutID (ContactsGetTopPeersRequestTypeID )
return g .EncodeBare (b )
}
func (g *ContactsGetTopPeersRequest ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode contacts.getTopPeers#973478b6 as nil" )
}
g .SetFlags ()
if err := g .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode contacts.getTopPeers#973478b6: field flags: %w" , err )
}
b .PutInt (g .Offset )
b .PutInt (g .Limit )
b .PutLong (g .Hash )
return nil
}
func (g *ContactsGetTopPeersRequest ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode contacts.getTopPeers#973478b6 to nil" )
}
if err := b .ConsumeID (ContactsGetTopPeersRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode contacts.getTopPeers#973478b6: %w" , err )
}
return g .DecodeBare (b )
}
func (g *ContactsGetTopPeersRequest ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode contacts.getTopPeers#973478b6 to nil" )
}
{
if err := g .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode contacts.getTopPeers#973478b6: field flags: %w" , err )
}
}
g .Correspondents = g .Flags .Has (0 )
g .BotsPm = g .Flags .Has (1 )
g .BotsInline = g .Flags .Has (2 )
g .PhoneCalls = g .Flags .Has (3 )
g .ForwardUsers = g .Flags .Has (4 )
g .ForwardChats = g .Flags .Has (5 )
g .Groups = g .Flags .Has (10 )
g .Channels = g .Flags .Has (15 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.getTopPeers#973478b6: field offset: %w" , err )
}
g .Offset = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.getTopPeers#973478b6: field limit: %w" , err )
}
g .Limit = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.getTopPeers#973478b6: field hash: %w" , err )
}
g .Hash = value
}
return nil
}
func (g *ContactsGetTopPeersRequest ) SetCorrespondents (value bool ) {
if value {
g .Flags .Set (0 )
g .Correspondents = true
} else {
g .Flags .Unset (0 )
g .Correspondents = false
}
}
func (g *ContactsGetTopPeersRequest ) GetCorrespondents () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (0 )
}
func (g *ContactsGetTopPeersRequest ) SetBotsPm (value bool ) {
if value {
g .Flags .Set (1 )
g .BotsPm = true
} else {
g .Flags .Unset (1 )
g .BotsPm = false
}
}
func (g *ContactsGetTopPeersRequest ) GetBotsPm () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (1 )
}
func (g *ContactsGetTopPeersRequest ) SetBotsInline (value bool ) {
if value {
g .Flags .Set (2 )
g .BotsInline = true
} else {
g .Flags .Unset (2 )
g .BotsInline = false
}
}
func (g *ContactsGetTopPeersRequest ) GetBotsInline () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (2 )
}
func (g *ContactsGetTopPeersRequest ) SetPhoneCalls (value bool ) {
if value {
g .Flags .Set (3 )
g .PhoneCalls = true
} else {
g .Flags .Unset (3 )
g .PhoneCalls = false
}
}
func (g *ContactsGetTopPeersRequest ) GetPhoneCalls () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (3 )
}
func (g *ContactsGetTopPeersRequest ) SetForwardUsers (value bool ) {
if value {
g .Flags .Set (4 )
g .ForwardUsers = true
} else {
g .Flags .Unset (4 )
g .ForwardUsers = false
}
}
func (g *ContactsGetTopPeersRequest ) GetForwardUsers () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (4 )
}
func (g *ContactsGetTopPeersRequest ) SetForwardChats (value bool ) {
if value {
g .Flags .Set (5 )
g .ForwardChats = true
} else {
g .Flags .Unset (5 )
g .ForwardChats = false
}
}
func (g *ContactsGetTopPeersRequest ) GetForwardChats () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (5 )
}
func (g *ContactsGetTopPeersRequest ) SetGroups (value bool ) {
if value {
g .Flags .Set (10 )
g .Groups = true
} else {
g .Flags .Unset (10 )
g .Groups = false
}
}
func (g *ContactsGetTopPeersRequest ) GetGroups () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (10 )
}
func (g *ContactsGetTopPeersRequest ) SetChannels (value bool ) {
if value {
g .Flags .Set (15 )
g .Channels = true
} else {
g .Flags .Unset (15 )
g .Channels = false
}
}
func (g *ContactsGetTopPeersRequest ) GetChannels () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (15 )
}
func (g *ContactsGetTopPeersRequest ) GetOffset () (value int ) {
if g == nil {
return
}
return g .Offset
}
func (g *ContactsGetTopPeersRequest ) GetLimit () (value int ) {
if g == nil {
return
}
return g .Limit
}
func (g *ContactsGetTopPeersRequest ) GetHash () (value int64 ) {
if g == nil {
return
}
return g .Hash
}
func (c *Client ) ContactsGetTopPeers (ctx context .Context , request *ContactsGetTopPeersRequest ) (ContactsTopPeersClass , error ) {
var result ContactsTopPeersBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .TopPeers , nil
}
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 .