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 MessagesGetPeerDialogsRequest struct {
Peers []InputDialogPeerClass
}
const MessagesGetPeerDialogsRequestTypeID = 0xe470bcfd
var (
_ bin .Encoder = &MessagesGetPeerDialogsRequest {}
_ bin .Decoder = &MessagesGetPeerDialogsRequest {}
_ bin .BareEncoder = &MessagesGetPeerDialogsRequest {}
_ bin .BareDecoder = &MessagesGetPeerDialogsRequest {}
)
func (g *MessagesGetPeerDialogsRequest ) Zero () bool {
if g == nil {
return true
}
if !(g .Peers == nil ) {
return false
}
return true
}
func (g *MessagesGetPeerDialogsRequest ) String () string {
if g == nil {
return "MessagesGetPeerDialogsRequest(nil)"
}
type Alias MessagesGetPeerDialogsRequest
return fmt .Sprintf ("MessagesGetPeerDialogsRequest%+v" , Alias (*g ))
}
func (g *MessagesGetPeerDialogsRequest ) FillFrom (from interface {
GetPeers () (value []InputDialogPeerClass )
}) {
g .Peers = from .GetPeers ()
}
func (*MessagesGetPeerDialogsRequest ) TypeID () uint32 {
return MessagesGetPeerDialogsRequestTypeID
}
func (*MessagesGetPeerDialogsRequest ) TypeName () string {
return "messages.getPeerDialogs"
}
func (g *MessagesGetPeerDialogsRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.getPeerDialogs" ,
ID : MessagesGetPeerDialogsRequestTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peers" ,
SchemaName : "peers" ,
},
}
return typ
}
func (g *MessagesGetPeerDialogsRequest ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode messages.getPeerDialogs#e470bcfd as nil" )
}
b .PutID (MessagesGetPeerDialogsRequestTypeID )
return g .EncodeBare (b )
}
func (g *MessagesGetPeerDialogsRequest ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode messages.getPeerDialogs#e470bcfd as nil" )
}
b .PutVectorHeader (len (g .Peers ))
for idx , v := range g .Peers {
if v == nil {
return fmt .Errorf ("unable to encode messages.getPeerDialogs#e470bcfd: field peers element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.getPeerDialogs#e470bcfd: field peers element with index %d: %w" , idx , err )
}
}
return nil
}
func (g *MessagesGetPeerDialogsRequest ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode messages.getPeerDialogs#e470bcfd to nil" )
}
if err := b .ConsumeID (MessagesGetPeerDialogsRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.getPeerDialogs#e470bcfd: %w" , err )
}
return g .DecodeBare (b )
}
func (g *MessagesGetPeerDialogsRequest ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode messages.getPeerDialogs#e470bcfd to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.getPeerDialogs#e470bcfd: field peers: %w" , err )
}
if headerLen > 0 {
g .Peers = make ([]InputDialogPeerClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeInputDialogPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.getPeerDialogs#e470bcfd: field peers: %w" , err )
}
g .Peers = append (g .Peers , value )
}
}
return nil
}
func (g *MessagesGetPeerDialogsRequest ) GetPeers () (value []InputDialogPeerClass ) {
if g == nil {
return
}
return g .Peers
}
func (g *MessagesGetPeerDialogsRequest ) MapPeers () (value InputDialogPeerClassArray ) {
return InputDialogPeerClassArray (g .Peers )
}
func (c *Client ) MessagesGetPeerDialogs (ctx context .Context , peers []InputDialogPeerClass ) (*MessagesPeerDialogs , error ) {
var result MessagesPeerDialogs
request := &MessagesGetPeerDialogsRequest {
Peers : peers ,
}
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return &result , 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 .