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