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 BotsPreviewInfo struct {
Media []BotPreviewMedia
LangCodes []string
}
const BotsPreviewInfoTypeID = 0xca71d64
var (
_ bin .Encoder = &BotsPreviewInfo {}
_ bin .Decoder = &BotsPreviewInfo {}
_ bin .BareEncoder = &BotsPreviewInfo {}
_ bin .BareDecoder = &BotsPreviewInfo {}
)
func (p *BotsPreviewInfo ) Zero () bool {
if p == nil {
return true
}
if !(p .Media == nil ) {
return false
}
if !(p .LangCodes == nil ) {
return false
}
return true
}
func (p *BotsPreviewInfo ) String () string {
if p == nil {
return "BotsPreviewInfo(nil)"
}
type Alias BotsPreviewInfo
return fmt .Sprintf ("BotsPreviewInfo%+v" , Alias (*p ))
}
func (p *BotsPreviewInfo ) FillFrom (from interface {
GetMedia () (value []BotPreviewMedia )
GetLangCodes () (value []string )
}) {
p .Media = from .GetMedia ()
p .LangCodes = from .GetLangCodes ()
}
func (*BotsPreviewInfo ) TypeID () uint32 {
return BotsPreviewInfoTypeID
}
func (*BotsPreviewInfo ) TypeName () string {
return "bots.previewInfo"
}
func (p *BotsPreviewInfo ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "bots.previewInfo" ,
ID : BotsPreviewInfoTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Media" ,
SchemaName : "media" ,
},
{
Name : "LangCodes" ,
SchemaName : "lang_codes" ,
},
}
return typ
}
func (p *BotsPreviewInfo ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode bots.previewInfo#ca71d64 as nil" )
}
b .PutID (BotsPreviewInfoTypeID )
return p .EncodeBare (b )
}
func (p *BotsPreviewInfo ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode bots.previewInfo#ca71d64 as nil" )
}
b .PutVectorHeader (len (p .Media ))
for idx , v := range p .Media {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode bots.previewInfo#ca71d64: field media element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (p .LangCodes ))
for _ , v := range p .LangCodes {
b .PutString (v )
}
return nil
}
func (p *BotsPreviewInfo ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode bots.previewInfo#ca71d64 to nil" )
}
if err := b .ConsumeID (BotsPreviewInfoTypeID ); err != nil {
return fmt .Errorf ("unable to decode bots.previewInfo#ca71d64: %w" , err )
}
return p .DecodeBare (b )
}
func (p *BotsPreviewInfo ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode bots.previewInfo#ca71d64 to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode bots.previewInfo#ca71d64: field media: %w" , err )
}
if headerLen > 0 {
p .Media = make ([]BotPreviewMedia , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value BotPreviewMedia
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode bots.previewInfo#ca71d64: field media: %w" , err )
}
p .Media = append (p .Media , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode bots.previewInfo#ca71d64: field lang_codes: %w" , err )
}
if headerLen > 0 {
p .LangCodes = make ([]string , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode bots.previewInfo#ca71d64: field lang_codes: %w" , err )
}
p .LangCodes = append (p .LangCodes , value )
}
}
return nil
}
func (p *BotsPreviewInfo ) GetMedia () (value []BotPreviewMedia ) {
if p == nil {
return
}
return p .Media
}
func (p *BotsPreviewInfo ) GetLangCodes () (value []string ) {
if p == nil {
return
}
return p .LangCodes
}
The pages are generated with Golds v0.8.4 . (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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .