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 MessagesGetChatsRequest struct {
ID []int64
}
const MessagesGetChatsRequestTypeID = 0x49e9528f
var (
_ bin .Encoder = &MessagesGetChatsRequest {}
_ bin .Decoder = &MessagesGetChatsRequest {}
_ bin .BareEncoder = &MessagesGetChatsRequest {}
_ bin .BareDecoder = &MessagesGetChatsRequest {}
)
func (g *MessagesGetChatsRequest ) Zero () bool {
if g == nil {
return true
}
if !(g .ID == nil ) {
return false
}
return true
}
func (g *MessagesGetChatsRequest ) String () string {
if g == nil {
return "MessagesGetChatsRequest(nil)"
}
type Alias MessagesGetChatsRequest
return fmt .Sprintf ("MessagesGetChatsRequest%+v" , Alias (*g ))
}
func (g *MessagesGetChatsRequest ) FillFrom (from interface {
GetID () (value []int64 )
}) {
g .ID = from .GetID ()
}
func (*MessagesGetChatsRequest ) TypeID () uint32 {
return MessagesGetChatsRequestTypeID
}
func (*MessagesGetChatsRequest ) TypeName () string {
return "messages.getChats"
}
func (g *MessagesGetChatsRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.getChats" ,
ID : MessagesGetChatsRequestTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
}
return typ
}
func (g *MessagesGetChatsRequest ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode messages.getChats#49e9528f as nil" )
}
b .PutID (MessagesGetChatsRequestTypeID )
return g .EncodeBare (b )
}
func (g *MessagesGetChatsRequest ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode messages.getChats#49e9528f as nil" )
}
b .PutVectorHeader (len (g .ID ))
for _ , v := range g .ID {
b .PutLong (v )
}
return nil
}
func (g *MessagesGetChatsRequest ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode messages.getChats#49e9528f to nil" )
}
if err := b .ConsumeID (MessagesGetChatsRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.getChats#49e9528f: %w" , err )
}
return g .DecodeBare (b )
}
func (g *MessagesGetChatsRequest ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode messages.getChats#49e9528f to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.getChats#49e9528f: field id: %w" , err )
}
if headerLen > 0 {
g .ID = make ([]int64 , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode messages.getChats#49e9528f: field id: %w" , err )
}
g .ID = append (g .ID , value )
}
}
return nil
}
func (g *MessagesGetChatsRequest ) GetID () (value []int64 ) {
if g == nil {
return
}
return g .ID
}
func (c *Client ) MessagesGetChats (ctx context .Context , id []int64 ) (MessagesChatsClass , error ) {
var result MessagesChatsBox
request := &MessagesGetChatsRequest {
ID : id ,
}
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .Chats , 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 .