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 ChannelsGetChannelsRequest struct {
ID []InputChannelClass
}
const ChannelsGetChannelsRequestTypeID = 0xa7f6bbb
var (
_ bin .Encoder = &ChannelsGetChannelsRequest {}
_ bin .Decoder = &ChannelsGetChannelsRequest {}
_ bin .BareEncoder = &ChannelsGetChannelsRequest {}
_ bin .BareDecoder = &ChannelsGetChannelsRequest {}
)
func (g *ChannelsGetChannelsRequest ) Zero () bool {
if g == nil {
return true
}
if !(g .ID == nil ) {
return false
}
return true
}
func (g *ChannelsGetChannelsRequest ) String () string {
if g == nil {
return "ChannelsGetChannelsRequest(nil)"
}
type Alias ChannelsGetChannelsRequest
return fmt .Sprintf ("ChannelsGetChannelsRequest%+v" , Alias (*g ))
}
func (g *ChannelsGetChannelsRequest ) FillFrom (from interface {
GetID () (value []InputChannelClass )
}) {
g .ID = from .GetID ()
}
func (*ChannelsGetChannelsRequest ) TypeID () uint32 {
return ChannelsGetChannelsRequestTypeID
}
func (*ChannelsGetChannelsRequest ) TypeName () string {
return "channels.getChannels"
}
func (g *ChannelsGetChannelsRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "channels.getChannels" ,
ID : ChannelsGetChannelsRequestTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
}
return typ
}
func (g *ChannelsGetChannelsRequest ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode channels.getChannels#a7f6bbb as nil" )
}
b .PutID (ChannelsGetChannelsRequestTypeID )
return g .EncodeBare (b )
}
func (g *ChannelsGetChannelsRequest ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode channels.getChannels#a7f6bbb as nil" )
}
b .PutVectorHeader (len (g .ID ))
for idx , v := range g .ID {
if v == nil {
return fmt .Errorf ("unable to encode channels.getChannels#a7f6bbb: field id element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channels.getChannels#a7f6bbb: field id element with index %d: %w" , idx , err )
}
}
return nil
}
func (g *ChannelsGetChannelsRequest ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode channels.getChannels#a7f6bbb to nil" )
}
if err := b .ConsumeID (ChannelsGetChannelsRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode channels.getChannels#a7f6bbb: %w" , err )
}
return g .DecodeBare (b )
}
func (g *ChannelsGetChannelsRequest ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode channels.getChannels#a7f6bbb to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode channels.getChannels#a7f6bbb: field id: %w" , err )
}
if headerLen > 0 {
g .ID = make ([]InputChannelClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeInputChannel (b )
if err != nil {
return fmt .Errorf ("unable to decode channels.getChannels#a7f6bbb: field id: %w" , err )
}
g .ID = append (g .ID , value )
}
}
return nil
}
func (g *ChannelsGetChannelsRequest ) GetID () (value []InputChannelClass ) {
if g == nil {
return
}
return g .ID
}
func (g *ChannelsGetChannelsRequest ) MapID () (value InputChannelClassArray ) {
return InputChannelClassArray (g .ID )
}
func (c *Client ) ChannelsGetChannels (ctx context .Context , id []InputChannelClass ) (MessagesChatsClass , error ) {
var result MessagesChatsBox
request := &ChannelsGetChannelsRequest {
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 .