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 LangpackGetStringsRequest struct {
LangPack string
LangCode string
Keys []string
}
const LangpackGetStringsRequestTypeID = 0xefea3803
var (
_ bin .Encoder = &LangpackGetStringsRequest {}
_ bin .Decoder = &LangpackGetStringsRequest {}
_ bin .BareEncoder = &LangpackGetStringsRequest {}
_ bin .BareDecoder = &LangpackGetStringsRequest {}
)
func (g *LangpackGetStringsRequest ) Zero () bool {
if g == nil {
return true
}
if !(g .LangPack == "" ) {
return false
}
if !(g .LangCode == "" ) {
return false
}
if !(g .Keys == nil ) {
return false
}
return true
}
func (g *LangpackGetStringsRequest ) String () string {
if g == nil {
return "LangpackGetStringsRequest(nil)"
}
type Alias LangpackGetStringsRequest
return fmt .Sprintf ("LangpackGetStringsRequest%+v" , Alias (*g ))
}
func (g *LangpackGetStringsRequest ) FillFrom (from interface {
GetLangPack () (value string )
GetLangCode () (value string )
GetKeys () (value []string )
}) {
g .LangPack = from .GetLangPack ()
g .LangCode = from .GetLangCode ()
g .Keys = from .GetKeys ()
}
func (*LangpackGetStringsRequest ) TypeID () uint32 {
return LangpackGetStringsRequestTypeID
}
func (*LangpackGetStringsRequest ) TypeName () string {
return "langpack.getStrings"
}
func (g *LangpackGetStringsRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "langpack.getStrings" ,
ID : LangpackGetStringsRequestTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "LangPack" ,
SchemaName : "lang_pack" ,
},
{
Name : "LangCode" ,
SchemaName : "lang_code" ,
},
{
Name : "Keys" ,
SchemaName : "keys" ,
},
}
return typ
}
func (g *LangpackGetStringsRequest ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode langpack.getStrings#efea3803 as nil" )
}
b .PutID (LangpackGetStringsRequestTypeID )
return g .EncodeBare (b )
}
func (g *LangpackGetStringsRequest ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode langpack.getStrings#efea3803 as nil" )
}
b .PutString (g .LangPack )
b .PutString (g .LangCode )
b .PutVectorHeader (len (g .Keys ))
for _ , v := range g .Keys {
b .PutString (v )
}
return nil
}
func (g *LangpackGetStringsRequest ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode langpack.getStrings#efea3803 to nil" )
}
if err := b .ConsumeID (LangpackGetStringsRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode langpack.getStrings#efea3803: %w" , err )
}
return g .DecodeBare (b )
}
func (g *LangpackGetStringsRequest ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode langpack.getStrings#efea3803 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode langpack.getStrings#efea3803: field lang_pack: %w" , err )
}
g .LangPack = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode langpack.getStrings#efea3803: field lang_code: %w" , err )
}
g .LangCode = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode langpack.getStrings#efea3803: field keys: %w" , err )
}
if headerLen > 0 {
g .Keys = 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 langpack.getStrings#efea3803: field keys: %w" , err )
}
g .Keys = append (g .Keys , value )
}
}
return nil
}
func (g *LangpackGetStringsRequest ) GetLangPack () (value string ) {
if g == nil {
return
}
return g .LangPack
}
func (g *LangpackGetStringsRequest ) GetLangCode () (value string ) {
if g == nil {
return
}
return g .LangCode
}
func (g *LangpackGetStringsRequest ) GetKeys () (value []string ) {
if g == nil {
return
}
return g .Keys
}
func (c *Client ) LangpackGetStrings (ctx context .Context , request *LangpackGetStringsRequest ) ([]LangPackStringClass , error ) {
var result LangPackStringClassVector
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return []LangPackStringClass (result .Elems ), 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 .