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 MessagesGetDialogsRequest struct {
Flags bin .Fields
ExcludePinned bool
FolderID int
OffsetDate int
OffsetID int
OffsetPeer InputPeerClass
Limit int
Hash int64
}
const MessagesGetDialogsRequestTypeID = 0xa0f4cb4f
var (
_ bin .Encoder = &MessagesGetDialogsRequest {}
_ bin .Decoder = &MessagesGetDialogsRequest {}
_ bin .BareEncoder = &MessagesGetDialogsRequest {}
_ bin .BareDecoder = &MessagesGetDialogsRequest {}
)
func (g *MessagesGetDialogsRequest ) Zero () bool {
if g == nil {
return true
}
if !(g .Flags .Zero ()) {
return false
}
if !(g .ExcludePinned == false ) {
return false
}
if !(g .FolderID == 0 ) {
return false
}
if !(g .OffsetDate == 0 ) {
return false
}
if !(g .OffsetID == 0 ) {
return false
}
if !(g .OffsetPeer == nil ) {
return false
}
if !(g .Limit == 0 ) {
return false
}
if !(g .Hash == 0 ) {
return false
}
return true
}
func (g *MessagesGetDialogsRequest ) String () string {
if g == nil {
return "MessagesGetDialogsRequest(nil)"
}
type Alias MessagesGetDialogsRequest
return fmt .Sprintf ("MessagesGetDialogsRequest%+v" , Alias (*g ))
}
func (g *MessagesGetDialogsRequest ) FillFrom (from interface {
GetExcludePinned () (value bool )
GetFolderID () (value int , ok bool )
GetOffsetDate () (value int )
GetOffsetID () (value int )
GetOffsetPeer () (value InputPeerClass )
GetLimit () (value int )
GetHash () (value int64 )
}) {
g .ExcludePinned = from .GetExcludePinned ()
if val , ok := from .GetFolderID (); ok {
g .FolderID = val
}
g .OffsetDate = from .GetOffsetDate ()
g .OffsetID = from .GetOffsetID ()
g .OffsetPeer = from .GetOffsetPeer ()
g .Limit = from .GetLimit ()
g .Hash = from .GetHash ()
}
func (*MessagesGetDialogsRequest ) TypeID () uint32 {
return MessagesGetDialogsRequestTypeID
}
func (*MessagesGetDialogsRequest ) TypeName () string {
return "messages.getDialogs"
}
func (g *MessagesGetDialogsRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.getDialogs" ,
ID : MessagesGetDialogsRequestTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ExcludePinned" ,
SchemaName : "exclude_pinned" ,
Null : !g .Flags .Has (0 ),
},
{
Name : "FolderID" ,
SchemaName : "folder_id" ,
Null : !g .Flags .Has (1 ),
},
{
Name : "OffsetDate" ,
SchemaName : "offset_date" ,
},
{
Name : "OffsetID" ,
SchemaName : "offset_id" ,
},
{
Name : "OffsetPeer" ,
SchemaName : "offset_peer" ,
},
{
Name : "Limit" ,
SchemaName : "limit" ,
},
{
Name : "Hash" ,
SchemaName : "hash" ,
},
}
return typ
}
func (g *MessagesGetDialogsRequest ) SetFlags () {
if !(g .ExcludePinned == false ) {
g .Flags .Set (0 )
}
if !(g .FolderID == 0 ) {
g .Flags .Set (1 )
}
}
func (g *MessagesGetDialogsRequest ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode messages.getDialogs#a0f4cb4f as nil" )
}
b .PutID (MessagesGetDialogsRequestTypeID )
return g .EncodeBare (b )
}
func (g *MessagesGetDialogsRequest ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode messages.getDialogs#a0f4cb4f as nil" )
}
g .SetFlags ()
if err := g .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.getDialogs#a0f4cb4f: field flags: %w" , err )
}
if g .Flags .Has (1 ) {
b .PutInt (g .FolderID )
}
b .PutInt (g .OffsetDate )
b .PutInt (g .OffsetID )
if g .OffsetPeer == nil {
return fmt .Errorf ("unable to encode messages.getDialogs#a0f4cb4f: field offset_peer is nil" )
}
if err := g .OffsetPeer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.getDialogs#a0f4cb4f: field offset_peer: %w" , err )
}
b .PutInt (g .Limit )
b .PutLong (g .Hash )
return nil
}
func (g *MessagesGetDialogsRequest ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode messages.getDialogs#a0f4cb4f to nil" )
}
if err := b .ConsumeID (MessagesGetDialogsRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.getDialogs#a0f4cb4f: %w" , err )
}
return g .DecodeBare (b )
}
func (g *MessagesGetDialogsRequest ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode messages.getDialogs#a0f4cb4f to nil" )
}
{
if err := g .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.getDialogs#a0f4cb4f: field flags: %w" , err )
}
}
g .ExcludePinned = g .Flags .Has (0 )
if g .Flags .Has (1 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.getDialogs#a0f4cb4f: field folder_id: %w" , err )
}
g .FolderID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.getDialogs#a0f4cb4f: field offset_date: %w" , err )
}
g .OffsetDate = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.getDialogs#a0f4cb4f: field offset_id: %w" , err )
}
g .OffsetID = value
}
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.getDialogs#a0f4cb4f: field offset_peer: %w" , err )
}
g .OffsetPeer = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.getDialogs#a0f4cb4f: field limit: %w" , err )
}
g .Limit = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode messages.getDialogs#a0f4cb4f: field hash: %w" , err )
}
g .Hash = value
}
return nil
}
func (g *MessagesGetDialogsRequest ) SetExcludePinned (value bool ) {
if value {
g .Flags .Set (0 )
g .ExcludePinned = true
} else {
g .Flags .Unset (0 )
g .ExcludePinned = false
}
}
func (g *MessagesGetDialogsRequest ) GetExcludePinned () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (0 )
}
func (g *MessagesGetDialogsRequest ) SetFolderID (value int ) {
g .Flags .Set (1 )
g .FolderID = value
}
func (g *MessagesGetDialogsRequest ) GetFolderID () (value int , ok bool ) {
if g == nil {
return
}
if !g .Flags .Has (1 ) {
return value , false
}
return g .FolderID , true
}
func (g *MessagesGetDialogsRequest ) GetOffsetDate () (value int ) {
if g == nil {
return
}
return g .OffsetDate
}
func (g *MessagesGetDialogsRequest ) GetOffsetID () (value int ) {
if g == nil {
return
}
return g .OffsetID
}
func (g *MessagesGetDialogsRequest ) GetOffsetPeer () (value InputPeerClass ) {
if g == nil {
return
}
return g .OffsetPeer
}
func (g *MessagesGetDialogsRequest ) GetLimit () (value int ) {
if g == nil {
return
}
return g .Limit
}
func (g *MessagesGetDialogsRequest ) GetHash () (value int64 ) {
if g == nil {
return
}
return g .Hash
}
func (c *Client ) MessagesGetDialogs (ctx context .Context , request *MessagesGetDialogsRequest ) (MessagesDialogsClass , error ) {
var result MessagesDialogsBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .Dialogs , 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 .