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