move gotd fork into repo. (#111)
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
This commit is contained in:
@@ -0,0 +1,251 @@
|
||||
// Code generated by gotdgen, DO NOT EDIT.
|
||||
|
||||
package tg
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"go.uber.org/multierr"
|
||||
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
|
||||
)
|
||||
|
||||
// No-op definition for keeping imports.
|
||||
var (
|
||||
_ = bin.Buffer{}
|
||||
_ = context.Background()
|
||||
_ = fmt.Stringer(nil)
|
||||
_ = strings.Builder{}
|
||||
_ = errors.Is
|
||||
_ = multierr.AppendInto
|
||||
_ = sort.Ints
|
||||
_ = tdp.Format
|
||||
_ = tgerr.Error{}
|
||||
_ = tdjson.Encoder{}
|
||||
)
|
||||
|
||||
// LangpackGetStringsRequest represents TL type `langpack.getStrings#efea3803`.
|
||||
// Get strings from a language pack
|
||||
//
|
||||
// See https://core.telegram.org/method/langpack.getStrings for reference.
|
||||
type LangpackGetStringsRequest struct {
|
||||
// Platform identifier (i.e. android, tdesktop, etc).
|
||||
LangPack string
|
||||
// Either an ISO 639-1 language code or a language pack name obtained from a language
|
||||
// pack link¹.
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/api/links#language-pack-links
|
||||
LangCode string
|
||||
// Strings to get
|
||||
Keys []string
|
||||
}
|
||||
|
||||
// LangpackGetStringsRequestTypeID is TL type id of LangpackGetStringsRequest.
|
||||
const LangpackGetStringsRequestTypeID = 0xefea3803
|
||||
|
||||
// Ensuring interfaces in compile-time for LangpackGetStringsRequest.
|
||||
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
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (g *LangpackGetStringsRequest) String() string {
|
||||
if g == nil {
|
||||
return "LangpackGetStringsRequest(nil)"
|
||||
}
|
||||
type Alias LangpackGetStringsRequest
|
||||
return fmt.Sprintf("LangpackGetStringsRequest%+v", Alias(*g))
|
||||
}
|
||||
|
||||
// FillFrom fills LangpackGetStringsRequest from given interface.
|
||||
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()
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*LangpackGetStringsRequest) TypeID() uint32 {
|
||||
return LangpackGetStringsRequestTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*LangpackGetStringsRequest) TypeName() string {
|
||||
return "langpack.getStrings"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
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
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
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)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
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
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
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)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
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
|
||||
}
|
||||
|
||||
// GetLangPack returns value of LangPack field.
|
||||
func (g *LangpackGetStringsRequest) GetLangPack() (value string) {
|
||||
if g == nil {
|
||||
return
|
||||
}
|
||||
return g.LangPack
|
||||
}
|
||||
|
||||
// GetLangCode returns value of LangCode field.
|
||||
func (g *LangpackGetStringsRequest) GetLangCode() (value string) {
|
||||
if g == nil {
|
||||
return
|
||||
}
|
||||
return g.LangCode
|
||||
}
|
||||
|
||||
// GetKeys returns value of Keys field.
|
||||
func (g *LangpackGetStringsRequest) GetKeys() (value []string) {
|
||||
if g == nil {
|
||||
return
|
||||
}
|
||||
return g.Keys
|
||||
}
|
||||
|
||||
// LangpackGetStrings invokes method langpack.getStrings#efea3803 returning error if any.
|
||||
// Get strings from a language pack
|
||||
//
|
||||
// Possible errors:
|
||||
//
|
||||
// 400 LANG_CODE_NOT_SUPPORTED: The specified language code is not supported.
|
||||
// 400 LANG_PACK_INVALID: The provided language pack is invalid.
|
||||
//
|
||||
// See https://core.telegram.org/method/langpack.getStrings for reference.
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user