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:
Adam Van Ymeren
2025-06-27 20:03:37 -07:00
committed by GitHub
parent 0952df0244
commit 7a04f298d2
19264 changed files with 1539697 additions and 84 deletions
+182
View File
@@ -0,0 +1,182 @@
// Code generated by gotdgen, DO NOT EDIT.
package td
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{}
)
// EchoVectorRequest represents TL type `echoVector#d4785939`.
//
// See https://localhost:80/doc/method/echoVector for reference.
type EchoVectorRequest struct {
// IDs field of EchoVectorRequest.
IDs []int
}
// EchoVectorRequestTypeID is TL type id of EchoVectorRequest.
const EchoVectorRequestTypeID = 0xd4785939
// Ensuring interfaces in compile-time for EchoVectorRequest.
var (
_ bin.Encoder = &EchoVectorRequest{}
_ bin.Decoder = &EchoVectorRequest{}
_ bin.BareEncoder = &EchoVectorRequest{}
_ bin.BareDecoder = &EchoVectorRequest{}
)
func (e *EchoVectorRequest) Zero() bool {
if e == nil {
return true
}
if !(e.IDs == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (e *EchoVectorRequest) String() string {
if e == nil {
return "EchoVectorRequest(nil)"
}
type Alias EchoVectorRequest
return fmt.Sprintf("EchoVectorRequest%+v", Alias(*e))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*EchoVectorRequest) TypeID() uint32 {
return EchoVectorRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*EchoVectorRequest) TypeName() string {
return "echoVector"
}
// TypeInfo returns info about TL type.
func (e *EchoVectorRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "echoVector",
ID: EchoVectorRequestTypeID,
}
if e == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "IDs",
SchemaName: "ids",
},
}
return typ
}
// Encode implements bin.Encoder.
func (e *EchoVectorRequest) Encode(b *bin.Buffer) error {
if e == nil {
return fmt.Errorf("can't encode echoVector#d4785939 as nil")
}
b.PutID(EchoVectorRequestTypeID)
return e.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (e *EchoVectorRequest) EncodeBare(b *bin.Buffer) error {
if e == nil {
return fmt.Errorf("can't encode echoVector#d4785939 as nil")
}
b.PutVectorHeader(len(e.IDs))
for _, v := range e.IDs {
b.PutInt(v)
}
return nil
}
// Decode implements bin.Decoder.
func (e *EchoVectorRequest) Decode(b *bin.Buffer) error {
if e == nil {
return fmt.Errorf("can't decode echoVector#d4785939 to nil")
}
if err := b.ConsumeID(EchoVectorRequestTypeID); err != nil {
return fmt.Errorf("unable to decode echoVector#d4785939: %w", err)
}
return e.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (e *EchoVectorRequest) DecodeBare(b *bin.Buffer) error {
if e == nil {
return fmt.Errorf("can't decode echoVector#d4785939 to nil")
}
{
headerLen, err := b.VectorHeader()
if err != nil {
return fmt.Errorf("unable to decode echoVector#d4785939: field ids: %w", err)
}
if headerLen > 0 {
e.IDs = make([]int, 0, headerLen%bin.PreallocateLimit)
}
for idx := 0; idx < headerLen; idx++ {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode echoVector#d4785939: field ids: %w", err)
}
e.IDs = append(e.IDs, value)
}
}
return nil
}
// GetIDs returns value of IDs field.
func (e *EchoVectorRequest) GetIDs() (value []int) {
if e == nil {
return
}
return e.IDs
}
// EchoVector invokes method echoVector#d4785939 returning error if any.
//
// See https://localhost:80/doc/method/echoVector for reference.
func (c *Client) EchoVector(ctx context.Context, ids []int) ([]int, error) {
var result IntVector
request := &EchoVectorRequest{
IDs: ids,
}
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
return nil, err
}
return []int(result.Elems), nil
}