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,3 @@
|
||||
// Package td contains generated code from example schema and is used
|
||||
// for codegen testing.
|
||||
package td
|
||||
@@ -0,0 +1,292 @@
|
||||
package td
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/tmap"
|
||||
)
|
||||
|
||||
func BenchmarkMessage_Encode(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
|
||||
buf := new(bin.Buffer)
|
||||
msg := Message{
|
||||
Err: Error{
|
||||
Message: "Foo",
|
||||
Code: 134,
|
||||
Temporary: true,
|
||||
},
|
||||
}
|
||||
for i := 0; i < b.N; i++ {
|
||||
msg.Encode(buf)
|
||||
buf.Reset()
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkMessage_Decode(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
|
||||
encodeBuf := new(bin.Buffer)
|
||||
msg := &Message{
|
||||
Err: Error{
|
||||
Message: "Foo",
|
||||
Code: 134,
|
||||
Temporary: true,
|
||||
},
|
||||
}
|
||||
msg.Encode(encodeBuf)
|
||||
raw := encodeBuf.Raw()
|
||||
b.SetBytes(int64(len(raw)))
|
||||
|
||||
buf := new(bin.Buffer)
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
var decoded Message
|
||||
buf.ResetTo(raw)
|
||||
if err := decoded.Decode(buf); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkID_Decode(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
|
||||
encodeBuf := new(bin.Buffer)
|
||||
msg := ResponseID{ID: 1}
|
||||
_ = msg.Encode(encodeBuf)
|
||||
raw := encodeBuf.Raw()
|
||||
b.SetBytes(int64(len(raw)))
|
||||
|
||||
buf := new(bin.Buffer)
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
var decoded ResponseID
|
||||
buf.ResetTo(raw)
|
||||
if err := decoded.Decode(buf); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMessage(t *testing.T) {
|
||||
b := new(bin.Buffer)
|
||||
msg := Message{
|
||||
Err: Error{
|
||||
Message: "Foo",
|
||||
Code: 134,
|
||||
Temporary: true,
|
||||
},
|
||||
}
|
||||
msg.Encode(b)
|
||||
|
||||
result := Message{}
|
||||
if err := result.Decode(b); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTargetsMessage_Encode(t *testing.T) {
|
||||
b := new(bin.Buffer)
|
||||
msg := TargetsMessage{
|
||||
Targets: []int32{1, 2, 3},
|
||||
}
|
||||
msg.Encode(b)
|
||||
decoded := TargetsMessage{}
|
||||
if err := decoded.Decode(b); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.Equal(t, msg, decoded)
|
||||
}
|
||||
|
||||
func TestGetUpdatesResp(t *testing.T) {
|
||||
b := new(bin.Buffer)
|
||||
v := GetUpdatesResp{
|
||||
Updates: []AbstractMessageClass{
|
||||
&BigMessage{ID: 12, Count: 3, Escape: true, Summary: true, TargetID: 1},
|
||||
&NoMessage{},
|
||||
&BytesMessage{Data: []byte{0x1, 0xf3, 104, 205}},
|
||||
&TargetsMessage{Targets: []int32{1, 2, 3, 4}},
|
||||
},
|
||||
}
|
||||
v.Encode(b)
|
||||
decoded := GetUpdatesResp{}
|
||||
if err := decoded.Decode(b); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
require.Equal(t, v, decoded)
|
||||
}
|
||||
|
||||
func TestDecodeToNil(t *testing.T) {
|
||||
b := new(bin.Buffer)
|
||||
if err := (&TargetsMessage{}).Encode(b); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var msg *TargetsMessage
|
||||
if err := msg.Decode(b); err == nil {
|
||||
t.Fatal("unexpected success")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetUpdatesRespNilElem(t *testing.T) {
|
||||
b := new(bin.Buffer)
|
||||
var tMessage *TargetsMessage
|
||||
v := GetUpdatesResp{
|
||||
Updates: []AbstractMessageClass{
|
||||
&BigMessage{ID: 12, Count: 3, Escape: true, Summary: true, TargetID: 1},
|
||||
&NoMessage{},
|
||||
&TargetsMessage{Targets: []int32{1, 2, 3, 4}},
|
||||
tMessage,
|
||||
},
|
||||
}
|
||||
if err := v.Encode(b); err == nil {
|
||||
t.Fatal("unexpected success")
|
||||
}
|
||||
}
|
||||
|
||||
type mockInvoker struct {
|
||||
input bin.Encoder
|
||||
output bin.Encoder
|
||||
}
|
||||
|
||||
func (m *mockInvoker) Invoke(ctx context.Context, input bin.Encoder, output bin.Decoder) error {
|
||||
m.input = input
|
||||
|
||||
buf := bin.Buffer{}
|
||||
err := m.output.Encode(&buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return output.Decode(&buf)
|
||||
}
|
||||
|
||||
func TestVectorResponse(t *testing.T) {
|
||||
elems := []int{1, 2, 3}
|
||||
m := mockInvoker{
|
||||
output: &IntVector{Elems: []int{1, 2, 3}},
|
||||
}
|
||||
client := NewClient(&m)
|
||||
|
||||
r, err := client.EchoVector(context.Background(), nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
require.Equal(t, r, elems)
|
||||
}
|
||||
|
||||
func BenchmarkDecodeBool(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
|
||||
encodeBuf := new(bin.Buffer)
|
||||
(&True{}).Encode(encodeBuf)
|
||||
raw := encodeBuf.Raw()
|
||||
b.SetBytes(int64(len(raw)))
|
||||
|
||||
buf := new(bin.Buffer)
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
buf.ResetTo(raw)
|
||||
v, err := DecodeBool(buf)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
switch v.(type) {
|
||||
case *True: // ok
|
||||
default:
|
||||
b.Fatalf("Unexpected %T", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkDecodeResponse(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
|
||||
encodeBuf := new(bin.Buffer)
|
||||
(&ResponseID{ID: 13}).Encode(encodeBuf)
|
||||
raw := encodeBuf.Raw()
|
||||
b.SetBytes(int64(len(raw)))
|
||||
|
||||
buf := new(bin.Buffer)
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
buf.ResetTo(raw)
|
||||
v, err := DecodeResponse(buf)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
switch v.(type) {
|
||||
case *ResponseID: // ok
|
||||
default:
|
||||
b.Fatalf("Unexpected %T", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkDecodeAbstractMessage(b *testing.B) {
|
||||
b.Run("NoMessage", func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
|
||||
encodeBuf := new(bin.Buffer)
|
||||
(&NoMessage{}).Encode(encodeBuf)
|
||||
raw := encodeBuf.Raw()
|
||||
b.SetBytes(int64(len(raw)))
|
||||
|
||||
buf := new(bin.Buffer)
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
buf.ResetTo(raw)
|
||||
v, err := DecodeAbstractMessage(buf)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
switch v.(type) {
|
||||
case *NoMessage: // ok
|
||||
default:
|
||||
b.Fatalf("Unexpected %T", v)
|
||||
}
|
||||
}
|
||||
})
|
||||
b.Run("BigMessage", func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
|
||||
encodeBuf := new(bin.Buffer)
|
||||
(&BigMessage{}).Encode(encodeBuf)
|
||||
raw := encodeBuf.Raw()
|
||||
b.SetBytes(int64(len(raw)))
|
||||
|
||||
buf := new(bin.Buffer)
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
buf.ResetTo(raw)
|
||||
v, err := DecodeAbstractMessage(buf)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
switch v.(type) {
|
||||
case *BigMessage: // ok
|
||||
default:
|
||||
b.Fatalf("Unexpected %T", v)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestRegistry(t *testing.T) {
|
||||
c := tmap.NewConstructor(
|
||||
TypesConstructorMap(),
|
||||
)
|
||||
require.NotNil(t, c.New(TextEntityTypeStrikethroughTypeID))
|
||||
require.Nil(t, c.New(0x1))
|
||||
}
|
||||
@@ -0,0 +1,946 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// BigMessage represents TL type `bigMessage#7490dcc5`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/bigMessage for reference.
|
||||
type BigMessage struct {
|
||||
// ID field of BigMessage.
|
||||
ID int32
|
||||
// Count field of BigMessage.
|
||||
Count int32
|
||||
// TargetID field of BigMessage.
|
||||
TargetID int32
|
||||
// Escape field of BigMessage.
|
||||
Escape bool
|
||||
// Summary field of BigMessage.
|
||||
Summary bool
|
||||
}
|
||||
|
||||
// BigMessageTypeID is TL type id of BigMessage.
|
||||
const BigMessageTypeID = 0x7490dcc5
|
||||
|
||||
// construct implements constructor of AbstractMessageClass.
|
||||
func (b BigMessage) construct() AbstractMessageClass { return &b }
|
||||
|
||||
// Ensuring interfaces in compile-time for BigMessage.
|
||||
var (
|
||||
_ bin.Encoder = &BigMessage{}
|
||||
_ bin.Decoder = &BigMessage{}
|
||||
_ bin.BareEncoder = &BigMessage{}
|
||||
_ bin.BareDecoder = &BigMessage{}
|
||||
|
||||
_ AbstractMessageClass = &BigMessage{}
|
||||
)
|
||||
|
||||
func (b *BigMessage) Zero() bool {
|
||||
if b == nil {
|
||||
return true
|
||||
}
|
||||
if !(b.ID == 0) {
|
||||
return false
|
||||
}
|
||||
if !(b.Count == 0) {
|
||||
return false
|
||||
}
|
||||
if !(b.TargetID == 0) {
|
||||
return false
|
||||
}
|
||||
if !(b.Escape == false) {
|
||||
return false
|
||||
}
|
||||
if !(b.Summary == false) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (b *BigMessage) String() string {
|
||||
if b == nil {
|
||||
return "BigMessage(nil)"
|
||||
}
|
||||
type Alias BigMessage
|
||||
return fmt.Sprintf("BigMessage%+v", Alias(*b))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*BigMessage) TypeID() uint32 {
|
||||
return BigMessageTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*BigMessage) TypeName() string {
|
||||
return "bigMessage"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (b *BigMessage) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "bigMessage",
|
||||
ID: BigMessageTypeID,
|
||||
}
|
||||
if b == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "ID",
|
||||
SchemaName: "id",
|
||||
},
|
||||
{
|
||||
Name: "Count",
|
||||
SchemaName: "count",
|
||||
},
|
||||
{
|
||||
Name: "TargetID",
|
||||
SchemaName: "targetId",
|
||||
},
|
||||
{
|
||||
Name: "Escape",
|
||||
SchemaName: "escape",
|
||||
},
|
||||
{
|
||||
Name: "Summary",
|
||||
SchemaName: "summary",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (b *BigMessage) Encode(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("can't encode bigMessage#7490dcc5 as nil")
|
||||
}
|
||||
buf.PutID(BigMessageTypeID)
|
||||
return b.EncodeBare(buf)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (b *BigMessage) EncodeBare(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("can't encode bigMessage#7490dcc5 as nil")
|
||||
}
|
||||
buf.PutInt32(b.ID)
|
||||
buf.PutInt32(b.Count)
|
||||
buf.PutInt32(b.TargetID)
|
||||
buf.PutBool(b.Escape)
|
||||
buf.PutBool(b.Summary)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (b *BigMessage) Decode(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("can't decode bigMessage#7490dcc5 to nil")
|
||||
}
|
||||
if err := buf.ConsumeID(BigMessageTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode bigMessage#7490dcc5: %w", err)
|
||||
}
|
||||
return b.DecodeBare(buf)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (b *BigMessage) DecodeBare(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("can't decode bigMessage#7490dcc5 to nil")
|
||||
}
|
||||
{
|
||||
value, err := buf.Int32()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode bigMessage#7490dcc5: field id: %w", err)
|
||||
}
|
||||
b.ID = value
|
||||
}
|
||||
{
|
||||
value, err := buf.Int32()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode bigMessage#7490dcc5: field count: %w", err)
|
||||
}
|
||||
b.Count = value
|
||||
}
|
||||
{
|
||||
value, err := buf.Int32()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode bigMessage#7490dcc5: field targetId: %w", err)
|
||||
}
|
||||
b.TargetID = value
|
||||
}
|
||||
{
|
||||
value, err := buf.Bool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode bigMessage#7490dcc5: field escape: %w", err)
|
||||
}
|
||||
b.Escape = value
|
||||
}
|
||||
{
|
||||
value, err := buf.Bool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode bigMessage#7490dcc5: field summary: %w", err)
|
||||
}
|
||||
b.Summary = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetID returns value of ID field.
|
||||
func (b *BigMessage) GetID() (value int32) {
|
||||
if b == nil {
|
||||
return
|
||||
}
|
||||
return b.ID
|
||||
}
|
||||
|
||||
// GetCount returns value of Count field.
|
||||
func (b *BigMessage) GetCount() (value int32) {
|
||||
if b == nil {
|
||||
return
|
||||
}
|
||||
return b.Count
|
||||
}
|
||||
|
||||
// GetTargetID returns value of TargetID field.
|
||||
func (b *BigMessage) GetTargetID() (value int32) {
|
||||
if b == nil {
|
||||
return
|
||||
}
|
||||
return b.TargetID
|
||||
}
|
||||
|
||||
// GetEscape returns value of Escape field.
|
||||
func (b *BigMessage) GetEscape() (value bool) {
|
||||
if b == nil {
|
||||
return
|
||||
}
|
||||
return b.Escape
|
||||
}
|
||||
|
||||
// GetSummary returns value of Summary field.
|
||||
func (b *BigMessage) GetSummary() (value bool) {
|
||||
if b == nil {
|
||||
return
|
||||
}
|
||||
return b.Summary
|
||||
}
|
||||
|
||||
// NoMessage represents TL type `noMessage#ee6324c4`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/noMessage for reference.
|
||||
type NoMessage struct {
|
||||
}
|
||||
|
||||
// NoMessageTypeID is TL type id of NoMessage.
|
||||
const NoMessageTypeID = 0xee6324c4
|
||||
|
||||
// construct implements constructor of AbstractMessageClass.
|
||||
func (n NoMessage) construct() AbstractMessageClass { return &n }
|
||||
|
||||
// Ensuring interfaces in compile-time for NoMessage.
|
||||
var (
|
||||
_ bin.Encoder = &NoMessage{}
|
||||
_ bin.Decoder = &NoMessage{}
|
||||
_ bin.BareEncoder = &NoMessage{}
|
||||
_ bin.BareDecoder = &NoMessage{}
|
||||
|
||||
_ AbstractMessageClass = &NoMessage{}
|
||||
)
|
||||
|
||||
func (n *NoMessage) Zero() bool {
|
||||
if n == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (n *NoMessage) String() string {
|
||||
if n == nil {
|
||||
return "NoMessage(nil)"
|
||||
}
|
||||
type Alias NoMessage
|
||||
return fmt.Sprintf("NoMessage%+v", Alias(*n))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*NoMessage) TypeID() uint32 {
|
||||
return NoMessageTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*NoMessage) TypeName() string {
|
||||
return "noMessage"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (n *NoMessage) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "noMessage",
|
||||
ID: NoMessageTypeID,
|
||||
}
|
||||
if n == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (n *NoMessage) Encode(b *bin.Buffer) error {
|
||||
if n == nil {
|
||||
return fmt.Errorf("can't encode noMessage#ee6324c4 as nil")
|
||||
}
|
||||
b.PutID(NoMessageTypeID)
|
||||
return n.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (n *NoMessage) EncodeBare(b *bin.Buffer) error {
|
||||
if n == nil {
|
||||
return fmt.Errorf("can't encode noMessage#ee6324c4 as nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (n *NoMessage) Decode(b *bin.Buffer) error {
|
||||
if n == nil {
|
||||
return fmt.Errorf("can't decode noMessage#ee6324c4 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(NoMessageTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode noMessage#ee6324c4: %w", err)
|
||||
}
|
||||
return n.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (n *NoMessage) DecodeBare(b *bin.Buffer) error {
|
||||
if n == nil {
|
||||
return fmt.Errorf("can't decode noMessage#ee6324c4 to nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// TargetsMessage represents TL type `targetsMessage#cc6136f1`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/targetsMessage for reference.
|
||||
type TargetsMessage struct {
|
||||
// Targets field of TargetsMessage.
|
||||
Targets []int32
|
||||
}
|
||||
|
||||
// TargetsMessageTypeID is TL type id of TargetsMessage.
|
||||
const TargetsMessageTypeID = 0xcc6136f1
|
||||
|
||||
// construct implements constructor of AbstractMessageClass.
|
||||
func (t TargetsMessage) construct() AbstractMessageClass { return &t }
|
||||
|
||||
// Ensuring interfaces in compile-time for TargetsMessage.
|
||||
var (
|
||||
_ bin.Encoder = &TargetsMessage{}
|
||||
_ bin.Decoder = &TargetsMessage{}
|
||||
_ bin.BareEncoder = &TargetsMessage{}
|
||||
_ bin.BareDecoder = &TargetsMessage{}
|
||||
|
||||
_ AbstractMessageClass = &TargetsMessage{}
|
||||
)
|
||||
|
||||
func (t *TargetsMessage) Zero() bool {
|
||||
if t == nil {
|
||||
return true
|
||||
}
|
||||
if !(t.Targets == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (t *TargetsMessage) String() string {
|
||||
if t == nil {
|
||||
return "TargetsMessage(nil)"
|
||||
}
|
||||
type Alias TargetsMessage
|
||||
return fmt.Sprintf("TargetsMessage%+v", Alias(*t))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*TargetsMessage) TypeID() uint32 {
|
||||
return TargetsMessageTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*TargetsMessage) TypeName() string {
|
||||
return "targetsMessage"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (t *TargetsMessage) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "targetsMessage",
|
||||
ID: TargetsMessageTypeID,
|
||||
}
|
||||
if t == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Targets",
|
||||
SchemaName: "targets",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (t *TargetsMessage) Encode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode targetsMessage#cc6136f1 as nil")
|
||||
}
|
||||
b.PutID(TargetsMessageTypeID)
|
||||
return t.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (t *TargetsMessage) EncodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode targetsMessage#cc6136f1 as nil")
|
||||
}
|
||||
b.PutInt(len(t.Targets))
|
||||
for _, v := range t.Targets {
|
||||
b.PutInt32(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (t *TargetsMessage) Decode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode targetsMessage#cc6136f1 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(TargetsMessageTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode targetsMessage#cc6136f1: %w", err)
|
||||
}
|
||||
return t.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (t *TargetsMessage) DecodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode targetsMessage#cc6136f1 to nil")
|
||||
}
|
||||
{
|
||||
headerLen, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode targetsMessage#cc6136f1: field targets: %w", err)
|
||||
}
|
||||
|
||||
if headerLen > 0 {
|
||||
t.Targets = make([]int32, 0, headerLen%bin.PreallocateLimit)
|
||||
}
|
||||
for idx := 0; idx < headerLen; idx++ {
|
||||
value, err := b.Int32()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode targetsMessage#cc6136f1: field targets: %w", err)
|
||||
}
|
||||
t.Targets = append(t.Targets, value)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetTargets returns value of Targets field.
|
||||
func (t *TargetsMessage) GetTargets() (value []int32) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.Targets
|
||||
}
|
||||
|
||||
// FieldsMessage represents TL type `fieldsMessage#947225b5`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/fieldsMessage for reference.
|
||||
type FieldsMessage struct {
|
||||
// Flags field of FieldsMessage.
|
||||
Flags bin.Fields
|
||||
// Escape field of FieldsMessage.
|
||||
//
|
||||
// Use SetEscape and GetEscape helpers.
|
||||
Escape bool
|
||||
// TTLSeconds field of FieldsMessage.
|
||||
//
|
||||
// Use SetTTLSeconds and GetTTLSeconds helpers.
|
||||
TTLSeconds int
|
||||
}
|
||||
|
||||
// FieldsMessageTypeID is TL type id of FieldsMessage.
|
||||
const FieldsMessageTypeID = 0x947225b5
|
||||
|
||||
// construct implements constructor of AbstractMessageClass.
|
||||
func (f FieldsMessage) construct() AbstractMessageClass { return &f }
|
||||
|
||||
// Ensuring interfaces in compile-time for FieldsMessage.
|
||||
var (
|
||||
_ bin.Encoder = &FieldsMessage{}
|
||||
_ bin.Decoder = &FieldsMessage{}
|
||||
_ bin.BareEncoder = &FieldsMessage{}
|
||||
_ bin.BareDecoder = &FieldsMessage{}
|
||||
|
||||
_ AbstractMessageClass = &FieldsMessage{}
|
||||
)
|
||||
|
||||
func (f *FieldsMessage) Zero() bool {
|
||||
if f == nil {
|
||||
return true
|
||||
}
|
||||
if !(f.Flags.Zero()) {
|
||||
return false
|
||||
}
|
||||
if !(f.Escape == false) {
|
||||
return false
|
||||
}
|
||||
if !(f.TTLSeconds == 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (f *FieldsMessage) String() string {
|
||||
if f == nil {
|
||||
return "FieldsMessage(nil)"
|
||||
}
|
||||
type Alias FieldsMessage
|
||||
return fmt.Sprintf("FieldsMessage%+v", Alias(*f))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*FieldsMessage) TypeID() uint32 {
|
||||
return FieldsMessageTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*FieldsMessage) TypeName() string {
|
||||
return "fieldsMessage"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (f *FieldsMessage) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "fieldsMessage",
|
||||
ID: FieldsMessageTypeID,
|
||||
}
|
||||
if f == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Escape",
|
||||
SchemaName: "escape",
|
||||
Null: !f.Flags.Has(0),
|
||||
},
|
||||
{
|
||||
Name: "TTLSeconds",
|
||||
SchemaName: "ttl_seconds",
|
||||
Null: !f.Flags.Has(1),
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// SetFlags sets flags for non-zero fields.
|
||||
func (f *FieldsMessage) SetFlags() {
|
||||
if !(f.Escape == false) {
|
||||
f.Flags.Set(0)
|
||||
}
|
||||
if !(f.TTLSeconds == 0) {
|
||||
f.Flags.Set(1)
|
||||
}
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (f *FieldsMessage) Encode(b *bin.Buffer) error {
|
||||
if f == nil {
|
||||
return fmt.Errorf("can't encode fieldsMessage#947225b5 as nil")
|
||||
}
|
||||
b.PutID(FieldsMessageTypeID)
|
||||
return f.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (f *FieldsMessage) EncodeBare(b *bin.Buffer) error {
|
||||
if f == nil {
|
||||
return fmt.Errorf("can't encode fieldsMessage#947225b5 as nil")
|
||||
}
|
||||
f.SetFlags()
|
||||
if err := f.Flags.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode fieldsMessage#947225b5: field flags: %w", err)
|
||||
}
|
||||
if f.Flags.Has(0) {
|
||||
b.PutBool(f.Escape)
|
||||
}
|
||||
if f.Flags.Has(1) {
|
||||
b.PutInt(f.TTLSeconds)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (f *FieldsMessage) Decode(b *bin.Buffer) error {
|
||||
if f == nil {
|
||||
return fmt.Errorf("can't decode fieldsMessage#947225b5 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(FieldsMessageTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode fieldsMessage#947225b5: %w", err)
|
||||
}
|
||||
return f.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (f *FieldsMessage) DecodeBare(b *bin.Buffer) error {
|
||||
if f == nil {
|
||||
return fmt.Errorf("can't decode fieldsMessage#947225b5 to nil")
|
||||
}
|
||||
{
|
||||
if err := f.Flags.Decode(b); err != nil {
|
||||
return fmt.Errorf("unable to decode fieldsMessage#947225b5: field flags: %w", err)
|
||||
}
|
||||
}
|
||||
if f.Flags.Has(0) {
|
||||
value, err := b.Bool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode fieldsMessage#947225b5: field escape: %w", err)
|
||||
}
|
||||
f.Escape = value
|
||||
}
|
||||
if f.Flags.Has(1) {
|
||||
value, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode fieldsMessage#947225b5: field ttl_seconds: %w", err)
|
||||
}
|
||||
f.TTLSeconds = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetEscape sets value of Escape conditional field.
|
||||
func (f *FieldsMessage) SetEscape(value bool) {
|
||||
f.Flags.Set(0)
|
||||
f.Escape = value
|
||||
}
|
||||
|
||||
// GetEscape returns value of Escape conditional field and
|
||||
// boolean which is true if field was set.
|
||||
func (f *FieldsMessage) GetEscape() (value bool, ok bool) {
|
||||
if f == nil {
|
||||
return
|
||||
}
|
||||
if !f.Flags.Has(0) {
|
||||
return value, false
|
||||
}
|
||||
return f.Escape, true
|
||||
}
|
||||
|
||||
// SetTTLSeconds sets value of TTLSeconds conditional field.
|
||||
func (f *FieldsMessage) SetTTLSeconds(value int) {
|
||||
f.Flags.Set(1)
|
||||
f.TTLSeconds = value
|
||||
}
|
||||
|
||||
// GetTTLSeconds returns value of TTLSeconds conditional field and
|
||||
// boolean which is true if field was set.
|
||||
func (f *FieldsMessage) GetTTLSeconds() (value int, ok bool) {
|
||||
if f == nil {
|
||||
return
|
||||
}
|
||||
if !f.Flags.Has(1) {
|
||||
return value, false
|
||||
}
|
||||
return f.TTLSeconds, true
|
||||
}
|
||||
|
||||
// BytesMessage represents TL type `bytesMessage#f990a67d`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/bytesMessage for reference.
|
||||
type BytesMessage struct {
|
||||
// Data field of BytesMessage.
|
||||
Data []byte
|
||||
}
|
||||
|
||||
// BytesMessageTypeID is TL type id of BytesMessage.
|
||||
const BytesMessageTypeID = 0xf990a67d
|
||||
|
||||
// construct implements constructor of AbstractMessageClass.
|
||||
func (b BytesMessage) construct() AbstractMessageClass { return &b }
|
||||
|
||||
// Ensuring interfaces in compile-time for BytesMessage.
|
||||
var (
|
||||
_ bin.Encoder = &BytesMessage{}
|
||||
_ bin.Decoder = &BytesMessage{}
|
||||
_ bin.BareEncoder = &BytesMessage{}
|
||||
_ bin.BareDecoder = &BytesMessage{}
|
||||
|
||||
_ AbstractMessageClass = &BytesMessage{}
|
||||
)
|
||||
|
||||
func (b *BytesMessage) Zero() bool {
|
||||
if b == nil {
|
||||
return true
|
||||
}
|
||||
if !(b.Data == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (b *BytesMessage) String() string {
|
||||
if b == nil {
|
||||
return "BytesMessage(nil)"
|
||||
}
|
||||
type Alias BytesMessage
|
||||
return fmt.Sprintf("BytesMessage%+v", Alias(*b))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*BytesMessage) TypeID() uint32 {
|
||||
return BytesMessageTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*BytesMessage) TypeName() string {
|
||||
return "bytesMessage"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (b *BytesMessage) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "bytesMessage",
|
||||
ID: BytesMessageTypeID,
|
||||
}
|
||||
if b == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Data",
|
||||
SchemaName: "data",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (b *BytesMessage) Encode(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("can't encode bytesMessage#f990a67d as nil")
|
||||
}
|
||||
buf.PutID(BytesMessageTypeID)
|
||||
return b.EncodeBare(buf)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (b *BytesMessage) EncodeBare(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("can't encode bytesMessage#f990a67d as nil")
|
||||
}
|
||||
buf.PutBytes(b.Data)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (b *BytesMessage) Decode(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("can't decode bytesMessage#f990a67d to nil")
|
||||
}
|
||||
if err := buf.ConsumeID(BytesMessageTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode bytesMessage#f990a67d: %w", err)
|
||||
}
|
||||
return b.DecodeBare(buf)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (b *BytesMessage) DecodeBare(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("can't decode bytesMessage#f990a67d to nil")
|
||||
}
|
||||
{
|
||||
value, err := buf.Bytes()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode bytesMessage#f990a67d: field data: %w", err)
|
||||
}
|
||||
b.Data = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetData returns value of Data field.
|
||||
func (b *BytesMessage) GetData() (value []byte) {
|
||||
if b == nil {
|
||||
return
|
||||
}
|
||||
return b.Data
|
||||
}
|
||||
|
||||
// AbstractMessageClassName is schema name of AbstractMessageClass.
|
||||
const AbstractMessageClassName = "AbstractMessage"
|
||||
|
||||
// AbstractMessageClass represents AbstractMessage generic type.
|
||||
//
|
||||
// See https://localhost:80/doc/type/AbstractMessage for reference.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// g, err := td.DecodeAbstractMessage(buf)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// switch v := g.(type) {
|
||||
// case *td.BigMessage: // bigMessage#7490dcc5
|
||||
// case *td.NoMessage: // noMessage#ee6324c4
|
||||
// case *td.TargetsMessage: // targetsMessage#cc6136f1
|
||||
// case *td.FieldsMessage: // fieldsMessage#947225b5
|
||||
// case *td.BytesMessage: // bytesMessage#f990a67d
|
||||
// default: panic(v)
|
||||
// }
|
||||
type AbstractMessageClass interface {
|
||||
bin.Encoder
|
||||
bin.Decoder
|
||||
bin.BareEncoder
|
||||
bin.BareDecoder
|
||||
construct() AbstractMessageClass
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
TypeID() uint32
|
||||
// TypeName returns name of type in TL schema.
|
||||
TypeName() string
|
||||
// String implements fmt.Stringer.
|
||||
String() string
|
||||
// Zero returns true if current object has a zero value.
|
||||
Zero() bool
|
||||
}
|
||||
|
||||
// DecodeAbstractMessage implements binary de-serialization for AbstractMessageClass.
|
||||
func DecodeAbstractMessage(buf *bin.Buffer) (AbstractMessageClass, error) {
|
||||
id, err := buf.PeekID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch id {
|
||||
case BigMessageTypeID:
|
||||
// Decoding bigMessage#7490dcc5.
|
||||
v := BigMessage{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode AbstractMessageClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
case NoMessageTypeID:
|
||||
// Decoding noMessage#ee6324c4.
|
||||
v := NoMessage{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode AbstractMessageClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
case TargetsMessageTypeID:
|
||||
// Decoding targetsMessage#cc6136f1.
|
||||
v := TargetsMessage{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode AbstractMessageClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
case FieldsMessageTypeID:
|
||||
// Decoding fieldsMessage#947225b5.
|
||||
v := FieldsMessage{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode AbstractMessageClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
case BytesMessageTypeID:
|
||||
// Decoding bytesMessage#f990a67d.
|
||||
v := BytesMessage{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode AbstractMessageClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unable to decode AbstractMessageClass: %w", bin.NewUnexpectedID(id))
|
||||
}
|
||||
}
|
||||
|
||||
// AbstractMessage boxes the AbstractMessageClass providing a helper.
|
||||
type AbstractMessageBox struct {
|
||||
AbstractMessage AbstractMessageClass
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder for AbstractMessageBox.
|
||||
func (b *AbstractMessageBox) Decode(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("unable to decode AbstractMessageBox to nil")
|
||||
}
|
||||
v, err := DecodeAbstractMessage(buf)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode boxed value: %w", err)
|
||||
}
|
||||
b.AbstractMessage = v
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode implements bin.Encode for AbstractMessageBox.
|
||||
func (b *AbstractMessageBox) Encode(buf *bin.Buffer) error {
|
||||
if b == nil || b.AbstractMessage == nil {
|
||||
return fmt.Errorf("unable to encode AbstractMessageClass as nil")
|
||||
}
|
||||
return b.AbstractMessage.Encode(buf)
|
||||
}
|
||||
@@ -0,0 +1,389 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// AccountThemesNotModified represents TL type `account.themesNotModified#f41eb622`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/account.themesNotModified for reference.
|
||||
type AccountThemesNotModified struct {
|
||||
}
|
||||
|
||||
// AccountThemesNotModifiedTypeID is TL type id of AccountThemesNotModified.
|
||||
const AccountThemesNotModifiedTypeID = 0xf41eb622
|
||||
|
||||
// construct implements constructor of AccountThemesClass.
|
||||
func (t AccountThemesNotModified) construct() AccountThemesClass { return &t }
|
||||
|
||||
// Ensuring interfaces in compile-time for AccountThemesNotModified.
|
||||
var (
|
||||
_ bin.Encoder = &AccountThemesNotModified{}
|
||||
_ bin.Decoder = &AccountThemesNotModified{}
|
||||
_ bin.BareEncoder = &AccountThemesNotModified{}
|
||||
_ bin.BareDecoder = &AccountThemesNotModified{}
|
||||
|
||||
_ AccountThemesClass = &AccountThemesNotModified{}
|
||||
)
|
||||
|
||||
func (t *AccountThemesNotModified) Zero() bool {
|
||||
if t == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (t *AccountThemesNotModified) String() string {
|
||||
if t == nil {
|
||||
return "AccountThemesNotModified(nil)"
|
||||
}
|
||||
type Alias AccountThemesNotModified
|
||||
return fmt.Sprintf("AccountThemesNotModified%+v", Alias(*t))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*AccountThemesNotModified) TypeID() uint32 {
|
||||
return AccountThemesNotModifiedTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*AccountThemesNotModified) TypeName() string {
|
||||
return "account.themesNotModified"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (t *AccountThemesNotModified) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "account.themesNotModified",
|
||||
ID: AccountThemesNotModifiedTypeID,
|
||||
}
|
||||
if t == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (t *AccountThemesNotModified) Encode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode account.themesNotModified#f41eb622 as nil")
|
||||
}
|
||||
b.PutID(AccountThemesNotModifiedTypeID)
|
||||
return t.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (t *AccountThemesNotModified) EncodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode account.themesNotModified#f41eb622 as nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (t *AccountThemesNotModified) Decode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode account.themesNotModified#f41eb622 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(AccountThemesNotModifiedTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode account.themesNotModified#f41eb622: %w", err)
|
||||
}
|
||||
return t.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (t *AccountThemesNotModified) DecodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode account.themesNotModified#f41eb622 to nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AccountThemes represents TL type `account.themes#7f676421`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/account.themes for reference.
|
||||
type AccountThemes struct {
|
||||
// Hash field of AccountThemes.
|
||||
Hash int
|
||||
// Themes field of AccountThemes.
|
||||
Themes []Theme
|
||||
}
|
||||
|
||||
// AccountThemesTypeID is TL type id of AccountThemes.
|
||||
const AccountThemesTypeID = 0x7f676421
|
||||
|
||||
// construct implements constructor of AccountThemesClass.
|
||||
func (t AccountThemes) construct() AccountThemesClass { return &t }
|
||||
|
||||
// Ensuring interfaces in compile-time for AccountThemes.
|
||||
var (
|
||||
_ bin.Encoder = &AccountThemes{}
|
||||
_ bin.Decoder = &AccountThemes{}
|
||||
_ bin.BareEncoder = &AccountThemes{}
|
||||
_ bin.BareDecoder = &AccountThemes{}
|
||||
|
||||
_ AccountThemesClass = &AccountThemes{}
|
||||
)
|
||||
|
||||
func (t *AccountThemes) Zero() bool {
|
||||
if t == nil {
|
||||
return true
|
||||
}
|
||||
if !(t.Hash == 0) {
|
||||
return false
|
||||
}
|
||||
if !(t.Themes == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (t *AccountThemes) String() string {
|
||||
if t == nil {
|
||||
return "AccountThemes(nil)"
|
||||
}
|
||||
type Alias AccountThemes
|
||||
return fmt.Sprintf("AccountThemes%+v", Alias(*t))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*AccountThemes) TypeID() uint32 {
|
||||
return AccountThemesTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*AccountThemes) TypeName() string {
|
||||
return "account.themes"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (t *AccountThemes) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "account.themes",
|
||||
ID: AccountThemesTypeID,
|
||||
}
|
||||
if t == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Hash",
|
||||
SchemaName: "hash",
|
||||
},
|
||||
{
|
||||
Name: "Themes",
|
||||
SchemaName: "themes",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (t *AccountThemes) Encode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode account.themes#7f676421 as nil")
|
||||
}
|
||||
b.PutID(AccountThemesTypeID)
|
||||
return t.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (t *AccountThemes) EncodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode account.themes#7f676421 as nil")
|
||||
}
|
||||
b.PutInt(t.Hash)
|
||||
b.PutVectorHeader(len(t.Themes))
|
||||
for idx, v := range t.Themes {
|
||||
if err := v.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode account.themes#7f676421: field themes element with index %d: %w", idx, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (t *AccountThemes) Decode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode account.themes#7f676421 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(AccountThemesTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode account.themes#7f676421: %w", err)
|
||||
}
|
||||
return t.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (t *AccountThemes) DecodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode account.themes#7f676421 to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode account.themes#7f676421: field hash: %w", err)
|
||||
}
|
||||
t.Hash = value
|
||||
}
|
||||
{
|
||||
headerLen, err := b.VectorHeader()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode account.themes#7f676421: field themes: %w", err)
|
||||
}
|
||||
|
||||
if headerLen > 0 {
|
||||
t.Themes = make([]Theme, 0, headerLen%bin.PreallocateLimit)
|
||||
}
|
||||
for idx := 0; idx < headerLen; idx++ {
|
||||
var value Theme
|
||||
if err := value.Decode(b); err != nil {
|
||||
return fmt.Errorf("unable to decode account.themes#7f676421: field themes: %w", err)
|
||||
}
|
||||
t.Themes = append(t.Themes, value)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetHash returns value of Hash field.
|
||||
func (t *AccountThemes) GetHash() (value int) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.Hash
|
||||
}
|
||||
|
||||
// GetThemes returns value of Themes field.
|
||||
func (t *AccountThemes) GetThemes() (value []Theme) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.Themes
|
||||
}
|
||||
|
||||
// AccountThemesClassName is schema name of AccountThemesClass.
|
||||
const AccountThemesClassName = "account.Themes"
|
||||
|
||||
// AccountThemesClass represents account.Themes generic type.
|
||||
//
|
||||
// See https://localhost:80/doc/type/account.Themes for reference.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// g, err := td.DecodeAccountThemes(buf)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// switch v := g.(type) {
|
||||
// case *td.AccountThemesNotModified: // account.themesNotModified#f41eb622
|
||||
// case *td.AccountThemes: // account.themes#7f676421
|
||||
// default: panic(v)
|
||||
// }
|
||||
type AccountThemesClass interface {
|
||||
bin.Encoder
|
||||
bin.Decoder
|
||||
bin.BareEncoder
|
||||
bin.BareDecoder
|
||||
construct() AccountThemesClass
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
TypeID() uint32
|
||||
// TypeName returns name of type in TL schema.
|
||||
TypeName() string
|
||||
// String implements fmt.Stringer.
|
||||
String() string
|
||||
// Zero returns true if current object has a zero value.
|
||||
Zero() bool
|
||||
}
|
||||
|
||||
// DecodeAccountThemes implements binary de-serialization for AccountThemesClass.
|
||||
func DecodeAccountThemes(buf *bin.Buffer) (AccountThemesClass, error) {
|
||||
id, err := buf.PeekID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch id {
|
||||
case AccountThemesNotModifiedTypeID:
|
||||
// Decoding account.themesNotModified#f41eb622.
|
||||
v := AccountThemesNotModified{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode AccountThemesClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
case AccountThemesTypeID:
|
||||
// Decoding account.themes#7f676421.
|
||||
v := AccountThemes{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode AccountThemesClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unable to decode AccountThemesClass: %w", bin.NewUnexpectedID(id))
|
||||
}
|
||||
}
|
||||
|
||||
// AccountThemes boxes the AccountThemesClass providing a helper.
|
||||
type AccountThemesBox struct {
|
||||
Themes AccountThemesClass
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder for AccountThemesBox.
|
||||
func (b *AccountThemesBox) Decode(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("unable to decode AccountThemesBox to nil")
|
||||
}
|
||||
v, err := DecodeAccountThemes(buf)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode boxed value: %w", err)
|
||||
}
|
||||
b.Themes = v
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode implements bin.Encode for AccountThemesBox.
|
||||
func (b *AccountThemesBox) Encode(buf *bin.Buffer) error {
|
||||
if b == nil || b.Themes == nil {
|
||||
return fmt.Errorf("unable to encode AccountThemesClass as nil")
|
||||
}
|
||||
return b.Themes.Encode(buf)
|
||||
}
|
||||
@@ -0,0 +1,403 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// Auth represents TL type `auth#f8bb4a38`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/auth for reference.
|
||||
type Auth struct {
|
||||
// Name field of Auth.
|
||||
Name string
|
||||
}
|
||||
|
||||
// AuthTypeID is TL type id of Auth.
|
||||
const AuthTypeID = 0xf8bb4a38
|
||||
|
||||
// construct implements constructor of AuthClass.
|
||||
func (a Auth) construct() AuthClass { return &a }
|
||||
|
||||
// Ensuring interfaces in compile-time for Auth.
|
||||
var (
|
||||
_ bin.Encoder = &Auth{}
|
||||
_ bin.Decoder = &Auth{}
|
||||
_ bin.BareEncoder = &Auth{}
|
||||
_ bin.BareDecoder = &Auth{}
|
||||
|
||||
_ AuthClass = &Auth{}
|
||||
)
|
||||
|
||||
func (a *Auth) Zero() bool {
|
||||
if a == nil {
|
||||
return true
|
||||
}
|
||||
if !(a.Name == "") {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (a *Auth) String() string {
|
||||
if a == nil {
|
||||
return "Auth(nil)"
|
||||
}
|
||||
type Alias Auth
|
||||
return fmt.Sprintf("Auth%+v", Alias(*a))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*Auth) TypeID() uint32 {
|
||||
return AuthTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*Auth) TypeName() string {
|
||||
return "auth"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (a *Auth) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "auth",
|
||||
ID: AuthTypeID,
|
||||
}
|
||||
if a == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Name",
|
||||
SchemaName: "name",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (a *Auth) Encode(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't encode auth#f8bb4a38 as nil")
|
||||
}
|
||||
b.PutID(AuthTypeID)
|
||||
return a.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (a *Auth) EncodeBare(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't encode auth#f8bb4a38 as nil")
|
||||
}
|
||||
b.PutString(a.Name)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (a *Auth) Decode(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't decode auth#f8bb4a38 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(AuthTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode auth#f8bb4a38: %w", err)
|
||||
}
|
||||
return a.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (a *Auth) DecodeBare(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't decode auth#f8bb4a38 to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode auth#f8bb4a38: field name: %w", err)
|
||||
}
|
||||
a.Name = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetName returns value of Name field.
|
||||
func (a *Auth) GetName() (value string) {
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
return a.Name
|
||||
}
|
||||
|
||||
// AuthPassword represents TL type `authPassword#29bacabb`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/authPassword for reference.
|
||||
type AuthPassword struct {
|
||||
// Name field of AuthPassword.
|
||||
Name string
|
||||
// Password field of AuthPassword.
|
||||
Password string
|
||||
}
|
||||
|
||||
// AuthPasswordTypeID is TL type id of AuthPassword.
|
||||
const AuthPasswordTypeID = 0x29bacabb
|
||||
|
||||
// construct implements constructor of AuthClass.
|
||||
func (a AuthPassword) construct() AuthClass { return &a }
|
||||
|
||||
// Ensuring interfaces in compile-time for AuthPassword.
|
||||
var (
|
||||
_ bin.Encoder = &AuthPassword{}
|
||||
_ bin.Decoder = &AuthPassword{}
|
||||
_ bin.BareEncoder = &AuthPassword{}
|
||||
_ bin.BareDecoder = &AuthPassword{}
|
||||
|
||||
_ AuthClass = &AuthPassword{}
|
||||
)
|
||||
|
||||
func (a *AuthPassword) Zero() bool {
|
||||
if a == nil {
|
||||
return true
|
||||
}
|
||||
if !(a.Name == "") {
|
||||
return false
|
||||
}
|
||||
if !(a.Password == "") {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (a *AuthPassword) String() string {
|
||||
if a == nil {
|
||||
return "AuthPassword(nil)"
|
||||
}
|
||||
type Alias AuthPassword
|
||||
return fmt.Sprintf("AuthPassword%+v", Alias(*a))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*AuthPassword) TypeID() uint32 {
|
||||
return AuthPasswordTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*AuthPassword) TypeName() string {
|
||||
return "authPassword"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (a *AuthPassword) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "authPassword",
|
||||
ID: AuthPasswordTypeID,
|
||||
}
|
||||
if a == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Name",
|
||||
SchemaName: "name",
|
||||
},
|
||||
{
|
||||
Name: "Password",
|
||||
SchemaName: "password",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (a *AuthPassword) Encode(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't encode authPassword#29bacabb as nil")
|
||||
}
|
||||
b.PutID(AuthPasswordTypeID)
|
||||
return a.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (a *AuthPassword) EncodeBare(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't encode authPassword#29bacabb as nil")
|
||||
}
|
||||
b.PutString(a.Name)
|
||||
b.PutString(a.Password)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (a *AuthPassword) Decode(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't decode authPassword#29bacabb to nil")
|
||||
}
|
||||
if err := b.ConsumeID(AuthPasswordTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode authPassword#29bacabb: %w", err)
|
||||
}
|
||||
return a.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (a *AuthPassword) DecodeBare(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't decode authPassword#29bacabb to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode authPassword#29bacabb: field name: %w", err)
|
||||
}
|
||||
a.Name = value
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode authPassword#29bacabb: field password: %w", err)
|
||||
}
|
||||
a.Password = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetName returns value of Name field.
|
||||
func (a *AuthPassword) GetName() (value string) {
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
return a.Name
|
||||
}
|
||||
|
||||
// GetPassword returns value of Password field.
|
||||
func (a *AuthPassword) GetPassword() (value string) {
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
return a.Password
|
||||
}
|
||||
|
||||
// AuthClassName is schema name of AuthClass.
|
||||
const AuthClassName = "Auth"
|
||||
|
||||
// AuthClass represents Auth generic type.
|
||||
//
|
||||
// See https://localhost:80/doc/type/Auth for reference.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// g, err := td.DecodeAuth(buf)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// switch v := g.(type) {
|
||||
// case *td.Auth: // auth#f8bb4a38
|
||||
// case *td.AuthPassword: // authPassword#29bacabb
|
||||
// default: panic(v)
|
||||
// }
|
||||
type AuthClass interface {
|
||||
bin.Encoder
|
||||
bin.Decoder
|
||||
bin.BareEncoder
|
||||
bin.BareDecoder
|
||||
construct() AuthClass
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
TypeID() uint32
|
||||
// TypeName returns name of type in TL schema.
|
||||
TypeName() string
|
||||
// String implements fmt.Stringer.
|
||||
String() string
|
||||
// Zero returns true if current object has a zero value.
|
||||
Zero() bool
|
||||
|
||||
// Name field of Auth.
|
||||
GetName() (value string)
|
||||
}
|
||||
|
||||
// DecodeAuth implements binary de-serialization for AuthClass.
|
||||
func DecodeAuth(buf *bin.Buffer) (AuthClass, error) {
|
||||
id, err := buf.PeekID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch id {
|
||||
case AuthTypeID:
|
||||
// Decoding auth#f8bb4a38.
|
||||
v := Auth{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode AuthClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
case AuthPasswordTypeID:
|
||||
// Decoding authPassword#29bacabb.
|
||||
v := AuthPassword{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode AuthClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unable to decode AuthClass: %w", bin.NewUnexpectedID(id))
|
||||
}
|
||||
}
|
||||
|
||||
// Auth boxes the AuthClass providing a helper.
|
||||
type AuthBox struct {
|
||||
Auth AuthClass
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder for AuthBox.
|
||||
func (b *AuthBox) Decode(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("unable to decode AuthBox to nil")
|
||||
}
|
||||
v, err := DecodeAuth(buf)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode boxed value: %w", err)
|
||||
}
|
||||
b.Auth = v
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode implements bin.Encode for AuthBox.
|
||||
func (b *AuthBox) Encode(buf *bin.Buffer) error {
|
||||
if b == nil || b.Auth == nil {
|
||||
return fmt.Errorf("unable to encode AuthClass as nil")
|
||||
}
|
||||
return b.Auth.Encode(buf)
|
||||
}
|
||||
@@ -0,0 +1,323 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// False represents TL type `false#bc799737`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/false for reference.
|
||||
type False struct {
|
||||
}
|
||||
|
||||
// FalseTypeID is TL type id of False.
|
||||
const FalseTypeID = 0xbc799737
|
||||
|
||||
// construct implements constructor of BoolClass.
|
||||
func (f False) construct() BoolClass { return &f }
|
||||
|
||||
// Ensuring interfaces in compile-time for False.
|
||||
var (
|
||||
_ bin.Encoder = &False{}
|
||||
_ bin.Decoder = &False{}
|
||||
_ bin.BareEncoder = &False{}
|
||||
_ bin.BareDecoder = &False{}
|
||||
|
||||
_ BoolClass = &False{}
|
||||
)
|
||||
|
||||
func (f *False) Zero() bool {
|
||||
if f == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (f *False) String() string {
|
||||
if f == nil {
|
||||
return "False(nil)"
|
||||
}
|
||||
type Alias False
|
||||
return fmt.Sprintf("False%+v", Alias(*f))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*False) TypeID() uint32 {
|
||||
return FalseTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*False) TypeName() string {
|
||||
return "false"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (f *False) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "false",
|
||||
ID: FalseTypeID,
|
||||
}
|
||||
if f == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (f *False) Encode(b *bin.Buffer) error {
|
||||
if f == nil {
|
||||
return fmt.Errorf("can't encode false#bc799737 as nil")
|
||||
}
|
||||
b.PutID(FalseTypeID)
|
||||
return f.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (f *False) EncodeBare(b *bin.Buffer) error {
|
||||
if f == nil {
|
||||
return fmt.Errorf("can't encode false#bc799737 as nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (f *False) Decode(b *bin.Buffer) error {
|
||||
if f == nil {
|
||||
return fmt.Errorf("can't decode false#bc799737 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(FalseTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode false#bc799737: %w", err)
|
||||
}
|
||||
return f.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (f *False) DecodeBare(b *bin.Buffer) error {
|
||||
if f == nil {
|
||||
return fmt.Errorf("can't decode false#bc799737 to nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// True represents TL type `true#997275b5`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/true for reference.
|
||||
type True struct {
|
||||
}
|
||||
|
||||
// TrueTypeID is TL type id of True.
|
||||
const TrueTypeID = 0x997275b5
|
||||
|
||||
// construct implements constructor of BoolClass.
|
||||
func (t True) construct() BoolClass { return &t }
|
||||
|
||||
// Ensuring interfaces in compile-time for True.
|
||||
var (
|
||||
_ bin.Encoder = &True{}
|
||||
_ bin.Decoder = &True{}
|
||||
_ bin.BareEncoder = &True{}
|
||||
_ bin.BareDecoder = &True{}
|
||||
|
||||
_ BoolClass = &True{}
|
||||
)
|
||||
|
||||
func (t *True) Zero() bool {
|
||||
if t == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (t *True) String() string {
|
||||
if t == nil {
|
||||
return "True(nil)"
|
||||
}
|
||||
type Alias True
|
||||
return fmt.Sprintf("True%+v", Alias(*t))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*True) TypeID() uint32 {
|
||||
return TrueTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*True) TypeName() string {
|
||||
return "true"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (t *True) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "true",
|
||||
ID: TrueTypeID,
|
||||
}
|
||||
if t == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (t *True) Encode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode true#997275b5 as nil")
|
||||
}
|
||||
b.PutID(TrueTypeID)
|
||||
return t.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (t *True) EncodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode true#997275b5 as nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (t *True) Decode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode true#997275b5 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(TrueTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode true#997275b5: %w", err)
|
||||
}
|
||||
return t.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (t *True) DecodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode true#997275b5 to nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// BoolClassName is schema name of BoolClass.
|
||||
const BoolClassName = "Bool"
|
||||
|
||||
// BoolClass represents Bool generic type.
|
||||
//
|
||||
// See https://localhost:80/doc/type/Bool for reference.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// g, err := td.DecodeBool(buf)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// switch v := g.(type) {
|
||||
// case *td.False: // false#bc799737
|
||||
// case *td.True: // true#997275b5
|
||||
// default: panic(v)
|
||||
// }
|
||||
type BoolClass interface {
|
||||
bin.Encoder
|
||||
bin.Decoder
|
||||
bin.BareEncoder
|
||||
bin.BareDecoder
|
||||
construct() BoolClass
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
TypeID() uint32
|
||||
// TypeName returns name of type in TL schema.
|
||||
TypeName() string
|
||||
// String implements fmt.Stringer.
|
||||
String() string
|
||||
// Zero returns true if current object has a zero value.
|
||||
Zero() bool
|
||||
}
|
||||
|
||||
// DecodeBool implements binary de-serialization for BoolClass.
|
||||
func DecodeBool(buf *bin.Buffer) (BoolClass, error) {
|
||||
id, err := buf.PeekID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch id {
|
||||
case FalseTypeID:
|
||||
// Decoding false#bc799737.
|
||||
v := False{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode BoolClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
case TrueTypeID:
|
||||
// Decoding true#997275b5.
|
||||
v := True{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode BoolClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unable to decode BoolClass: %w", bin.NewUnexpectedID(id))
|
||||
}
|
||||
}
|
||||
|
||||
// Bool boxes the BoolClass providing a helper.
|
||||
type BoolBox struct {
|
||||
Bool BoolClass
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder for BoolBox.
|
||||
func (b *BoolBox) Decode(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("unable to decode BoolBox to nil")
|
||||
}
|
||||
v, err := DecodeBool(buf)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode boxed value: %w", err)
|
||||
}
|
||||
b.Bool = v
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode implements bin.Encode for BoolBox.
|
||||
func (b *BoolBox) Encode(buf *bin.Buffer) error {
|
||||
if b == nil || b.Bool == nil {
|
||||
return fmt.Errorf("unable to encode BoolClass as nil")
|
||||
}
|
||||
return b.Bool.Encode(buf)
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// Bytes represents TL type `bytes#e937bb82`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/bytes for reference.
|
||||
type Bytes struct {
|
||||
}
|
||||
|
||||
// BytesTypeID is TL type id of Bytes.
|
||||
const BytesTypeID = 0xe937bb82
|
||||
|
||||
// Ensuring interfaces in compile-time for Bytes.
|
||||
var (
|
||||
_ bin.Encoder = &Bytes{}
|
||||
_ bin.Decoder = &Bytes{}
|
||||
_ bin.BareEncoder = &Bytes{}
|
||||
_ bin.BareDecoder = &Bytes{}
|
||||
)
|
||||
|
||||
func (b *Bytes) Zero() bool {
|
||||
if b == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (b *Bytes) String() string {
|
||||
if b == nil {
|
||||
return "Bytes(nil)"
|
||||
}
|
||||
type Alias Bytes
|
||||
return fmt.Sprintf("Bytes%+v", Alias(*b))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*Bytes) TypeID() uint32 {
|
||||
return BytesTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*Bytes) TypeName() string {
|
||||
return "bytes"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (b *Bytes) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "bytes",
|
||||
ID: BytesTypeID,
|
||||
}
|
||||
if b == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (b *Bytes) Encode(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("can't encode bytes#e937bb82 as nil")
|
||||
}
|
||||
buf.PutID(BytesTypeID)
|
||||
return b.EncodeBare(buf)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (b *Bytes) EncodeBare(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("can't encode bytes#e937bb82 as nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (b *Bytes) Decode(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("can't decode bytes#e937bb82 to nil")
|
||||
}
|
||||
if err := buf.ConsumeID(BytesTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode bytes#e937bb82: %w", err)
|
||||
}
|
||||
return b.DecodeBare(buf)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (b *Bytes) DecodeBare(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("can't decode bytes#e937bb82 to nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// ClientDHInnerData represents TL type `client_DH_inner_data#6643b654`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/client_DH_inner_data for reference.
|
||||
type ClientDHInnerData struct {
|
||||
// Nonce field of ClientDHInnerData.
|
||||
Nonce bin.Int128
|
||||
// ServerNonce field of ClientDHInnerData.
|
||||
ServerNonce bin.Int128
|
||||
// RetryID field of ClientDHInnerData.
|
||||
RetryID int64
|
||||
// GB field of ClientDHInnerData.
|
||||
GB string
|
||||
}
|
||||
|
||||
// ClientDHInnerDataTypeID is TL type id of ClientDHInnerData.
|
||||
const ClientDHInnerDataTypeID = 0x6643b654
|
||||
|
||||
// Ensuring interfaces in compile-time for ClientDHInnerData.
|
||||
var (
|
||||
_ bin.Encoder = &ClientDHInnerData{}
|
||||
_ bin.Decoder = &ClientDHInnerData{}
|
||||
_ bin.BareEncoder = &ClientDHInnerData{}
|
||||
_ bin.BareDecoder = &ClientDHInnerData{}
|
||||
)
|
||||
|
||||
func (c *ClientDHInnerData) Zero() bool {
|
||||
if c == nil {
|
||||
return true
|
||||
}
|
||||
if !(c.Nonce == bin.Int128{}) {
|
||||
return false
|
||||
}
|
||||
if !(c.ServerNonce == bin.Int128{}) {
|
||||
return false
|
||||
}
|
||||
if !(c.RetryID == 0) {
|
||||
return false
|
||||
}
|
||||
if !(c.GB == "") {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (c *ClientDHInnerData) String() string {
|
||||
if c == nil {
|
||||
return "ClientDHInnerData(nil)"
|
||||
}
|
||||
type Alias ClientDHInnerData
|
||||
return fmt.Sprintf("ClientDHInnerData%+v", Alias(*c))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*ClientDHInnerData) TypeID() uint32 {
|
||||
return ClientDHInnerDataTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*ClientDHInnerData) TypeName() string {
|
||||
return "client_DH_inner_data"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (c *ClientDHInnerData) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "client_DH_inner_data",
|
||||
ID: ClientDHInnerDataTypeID,
|
||||
}
|
||||
if c == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Nonce",
|
||||
SchemaName: "nonce",
|
||||
},
|
||||
{
|
||||
Name: "ServerNonce",
|
||||
SchemaName: "server_nonce",
|
||||
},
|
||||
{
|
||||
Name: "RetryID",
|
||||
SchemaName: "retry_id",
|
||||
},
|
||||
{
|
||||
Name: "GB",
|
||||
SchemaName: "g_b",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (c *ClientDHInnerData) Encode(b *bin.Buffer) error {
|
||||
if c == nil {
|
||||
return fmt.Errorf("can't encode client_DH_inner_data#6643b654 as nil")
|
||||
}
|
||||
b.PutID(ClientDHInnerDataTypeID)
|
||||
return c.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (c *ClientDHInnerData) EncodeBare(b *bin.Buffer) error {
|
||||
if c == nil {
|
||||
return fmt.Errorf("can't encode client_DH_inner_data#6643b654 as nil")
|
||||
}
|
||||
b.PutInt128(c.Nonce)
|
||||
b.PutInt128(c.ServerNonce)
|
||||
b.PutLong(c.RetryID)
|
||||
b.PutString(c.GB)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (c *ClientDHInnerData) Decode(b *bin.Buffer) error {
|
||||
if c == nil {
|
||||
return fmt.Errorf("can't decode client_DH_inner_data#6643b654 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(ClientDHInnerDataTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode client_DH_inner_data#6643b654: %w", err)
|
||||
}
|
||||
return c.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (c *ClientDHInnerData) DecodeBare(b *bin.Buffer) error {
|
||||
if c == nil {
|
||||
return fmt.Errorf("can't decode client_DH_inner_data#6643b654 to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.Int128()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode client_DH_inner_data#6643b654: field nonce: %w", err)
|
||||
}
|
||||
c.Nonce = value
|
||||
}
|
||||
{
|
||||
value, err := b.Int128()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode client_DH_inner_data#6643b654: field server_nonce: %w", err)
|
||||
}
|
||||
c.ServerNonce = value
|
||||
}
|
||||
{
|
||||
value, err := b.Long()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode client_DH_inner_data#6643b654: field retry_id: %w", err)
|
||||
}
|
||||
c.RetryID = value
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode client_DH_inner_data#6643b654: field g_b: %w", err)
|
||||
}
|
||||
c.GB = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetNonce returns value of Nonce field.
|
||||
func (c *ClientDHInnerData) GetNonce() (value bin.Int128) {
|
||||
if c == nil {
|
||||
return
|
||||
}
|
||||
return c.Nonce
|
||||
}
|
||||
|
||||
// GetServerNonce returns value of ServerNonce field.
|
||||
func (c *ClientDHInnerData) GetServerNonce() (value bin.Int128) {
|
||||
if c == nil {
|
||||
return
|
||||
}
|
||||
return c.ServerNonce
|
||||
}
|
||||
|
||||
// GetRetryID returns value of RetryID field.
|
||||
func (c *ClientDHInnerData) GetRetryID() (value int64) {
|
||||
if c == nil {
|
||||
return
|
||||
}
|
||||
return c.RetryID
|
||||
}
|
||||
|
||||
// GetGB returns value of GB field.
|
||||
func (c *ClientDHInnerData) GetGB() (value string) {
|
||||
if c == nil {
|
||||
return
|
||||
}
|
||||
return c.GB
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// Invoker can invoke raw MTProto rpc calls.
|
||||
type Invoker interface {
|
||||
Invoke(ctx context.Context, input bin.Encoder, output bin.Decoder) error
|
||||
}
|
||||
|
||||
// Client implement methods for calling functions from TL schema via Invoker.
|
||||
type Client struct {
|
||||
rpc Invoker
|
||||
}
|
||||
|
||||
// Invoker returns Invoker used by this client.
|
||||
func (c *Client) Invoker() Invoker {
|
||||
return c.rpc
|
||||
}
|
||||
|
||||
// NewClient creates new Client.
|
||||
func NewClient(invoker Invoker) *Client {
|
||||
return &Client{
|
||||
rpc: invoker,
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,430 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// DCOption represents TL type `dcOption#18b7a10d`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/dcOption for reference.
|
||||
type DCOption struct {
|
||||
// Flags field of DCOption.
|
||||
Flags bin.Fields
|
||||
// Ipv6 field of DCOption.
|
||||
Ipv6 bool
|
||||
// MediaOnly field of DCOption.
|
||||
MediaOnly bool
|
||||
// TCPObfuscatedOnly field of DCOption.
|
||||
TCPObfuscatedOnly bool
|
||||
// CDN field of DCOption.
|
||||
CDN bool
|
||||
// Static field of DCOption.
|
||||
Static bool
|
||||
// ID field of DCOption.
|
||||
ID int
|
||||
// IPAddress field of DCOption.
|
||||
IPAddress string
|
||||
// Port field of DCOption.
|
||||
Port int
|
||||
// Secret field of DCOption.
|
||||
//
|
||||
// Use SetSecret and GetSecret helpers.
|
||||
Secret []byte
|
||||
}
|
||||
|
||||
// DCOptionTypeID is TL type id of DCOption.
|
||||
const DCOptionTypeID = 0x18b7a10d
|
||||
|
||||
// Ensuring interfaces in compile-time for DCOption.
|
||||
var (
|
||||
_ bin.Encoder = &DCOption{}
|
||||
_ bin.Decoder = &DCOption{}
|
||||
_ bin.BareEncoder = &DCOption{}
|
||||
_ bin.BareDecoder = &DCOption{}
|
||||
)
|
||||
|
||||
func (d *DCOption) Zero() bool {
|
||||
if d == nil {
|
||||
return true
|
||||
}
|
||||
if !(d.Flags.Zero()) {
|
||||
return false
|
||||
}
|
||||
if !(d.Ipv6 == false) {
|
||||
return false
|
||||
}
|
||||
if !(d.MediaOnly == false) {
|
||||
return false
|
||||
}
|
||||
if !(d.TCPObfuscatedOnly == false) {
|
||||
return false
|
||||
}
|
||||
if !(d.CDN == false) {
|
||||
return false
|
||||
}
|
||||
if !(d.Static == false) {
|
||||
return false
|
||||
}
|
||||
if !(d.ID == 0) {
|
||||
return false
|
||||
}
|
||||
if !(d.IPAddress == "") {
|
||||
return false
|
||||
}
|
||||
if !(d.Port == 0) {
|
||||
return false
|
||||
}
|
||||
if !(d.Secret == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (d *DCOption) String() string {
|
||||
if d == nil {
|
||||
return "DCOption(nil)"
|
||||
}
|
||||
type Alias DCOption
|
||||
return fmt.Sprintf("DCOption%+v", Alias(*d))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*DCOption) TypeID() uint32 {
|
||||
return DCOptionTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*DCOption) TypeName() string {
|
||||
return "dcOption"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (d *DCOption) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "dcOption",
|
||||
ID: DCOptionTypeID,
|
||||
}
|
||||
if d == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Ipv6",
|
||||
SchemaName: "ipv6",
|
||||
Null: !d.Flags.Has(0),
|
||||
},
|
||||
{
|
||||
Name: "MediaOnly",
|
||||
SchemaName: "media_only",
|
||||
Null: !d.Flags.Has(1),
|
||||
},
|
||||
{
|
||||
Name: "TCPObfuscatedOnly",
|
||||
SchemaName: "tcpo_only",
|
||||
Null: !d.Flags.Has(2),
|
||||
},
|
||||
{
|
||||
Name: "CDN",
|
||||
SchemaName: "cdn",
|
||||
Null: !d.Flags.Has(3),
|
||||
},
|
||||
{
|
||||
Name: "Static",
|
||||
SchemaName: "static",
|
||||
Null: !d.Flags.Has(4),
|
||||
},
|
||||
{
|
||||
Name: "ID",
|
||||
SchemaName: "id",
|
||||
},
|
||||
{
|
||||
Name: "IPAddress",
|
||||
SchemaName: "ip_address",
|
||||
},
|
||||
{
|
||||
Name: "Port",
|
||||
SchemaName: "port",
|
||||
},
|
||||
{
|
||||
Name: "Secret",
|
||||
SchemaName: "secret",
|
||||
Null: !d.Flags.Has(10),
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// SetFlags sets flags for non-zero fields.
|
||||
func (d *DCOption) SetFlags() {
|
||||
if !(d.Ipv6 == false) {
|
||||
d.Flags.Set(0)
|
||||
}
|
||||
if !(d.MediaOnly == false) {
|
||||
d.Flags.Set(1)
|
||||
}
|
||||
if !(d.TCPObfuscatedOnly == false) {
|
||||
d.Flags.Set(2)
|
||||
}
|
||||
if !(d.CDN == false) {
|
||||
d.Flags.Set(3)
|
||||
}
|
||||
if !(d.Static == false) {
|
||||
d.Flags.Set(4)
|
||||
}
|
||||
if !(d.Secret == nil) {
|
||||
d.Flags.Set(10)
|
||||
}
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (d *DCOption) Encode(b *bin.Buffer) error {
|
||||
if d == nil {
|
||||
return fmt.Errorf("can't encode dcOption#18b7a10d as nil")
|
||||
}
|
||||
b.PutID(DCOptionTypeID)
|
||||
return d.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (d *DCOption) EncodeBare(b *bin.Buffer) error {
|
||||
if d == nil {
|
||||
return fmt.Errorf("can't encode dcOption#18b7a10d as nil")
|
||||
}
|
||||
d.SetFlags()
|
||||
if err := d.Flags.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode dcOption#18b7a10d: field flags: %w", err)
|
||||
}
|
||||
b.PutInt(d.ID)
|
||||
b.PutString(d.IPAddress)
|
||||
b.PutInt(d.Port)
|
||||
if d.Flags.Has(10) {
|
||||
b.PutBytes(d.Secret)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (d *DCOption) Decode(b *bin.Buffer) error {
|
||||
if d == nil {
|
||||
return fmt.Errorf("can't decode dcOption#18b7a10d to nil")
|
||||
}
|
||||
if err := b.ConsumeID(DCOptionTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode dcOption#18b7a10d: %w", err)
|
||||
}
|
||||
return d.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (d *DCOption) DecodeBare(b *bin.Buffer) error {
|
||||
if d == nil {
|
||||
return fmt.Errorf("can't decode dcOption#18b7a10d to nil")
|
||||
}
|
||||
{
|
||||
if err := d.Flags.Decode(b); err != nil {
|
||||
return fmt.Errorf("unable to decode dcOption#18b7a10d: field flags: %w", err)
|
||||
}
|
||||
}
|
||||
d.Ipv6 = d.Flags.Has(0)
|
||||
d.MediaOnly = d.Flags.Has(1)
|
||||
d.TCPObfuscatedOnly = d.Flags.Has(2)
|
||||
d.CDN = d.Flags.Has(3)
|
||||
d.Static = d.Flags.Has(4)
|
||||
{
|
||||
value, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode dcOption#18b7a10d: field id: %w", err)
|
||||
}
|
||||
d.ID = value
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode dcOption#18b7a10d: field ip_address: %w", err)
|
||||
}
|
||||
d.IPAddress = value
|
||||
}
|
||||
{
|
||||
value, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode dcOption#18b7a10d: field port: %w", err)
|
||||
}
|
||||
d.Port = value
|
||||
}
|
||||
if d.Flags.Has(10) {
|
||||
value, err := b.Bytes()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode dcOption#18b7a10d: field secret: %w", err)
|
||||
}
|
||||
d.Secret = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetIpv6 sets value of Ipv6 conditional field.
|
||||
func (d *DCOption) SetIpv6(value bool) {
|
||||
if value {
|
||||
d.Flags.Set(0)
|
||||
d.Ipv6 = true
|
||||
} else {
|
||||
d.Flags.Unset(0)
|
||||
d.Ipv6 = false
|
||||
}
|
||||
}
|
||||
|
||||
// GetIpv6 returns value of Ipv6 conditional field.
|
||||
func (d *DCOption) GetIpv6() (value bool) {
|
||||
if d == nil {
|
||||
return
|
||||
}
|
||||
return d.Flags.Has(0)
|
||||
}
|
||||
|
||||
// SetMediaOnly sets value of MediaOnly conditional field.
|
||||
func (d *DCOption) SetMediaOnly(value bool) {
|
||||
if value {
|
||||
d.Flags.Set(1)
|
||||
d.MediaOnly = true
|
||||
} else {
|
||||
d.Flags.Unset(1)
|
||||
d.MediaOnly = false
|
||||
}
|
||||
}
|
||||
|
||||
// GetMediaOnly returns value of MediaOnly conditional field.
|
||||
func (d *DCOption) GetMediaOnly() (value bool) {
|
||||
if d == nil {
|
||||
return
|
||||
}
|
||||
return d.Flags.Has(1)
|
||||
}
|
||||
|
||||
// SetTCPObfuscatedOnly sets value of TCPObfuscatedOnly conditional field.
|
||||
func (d *DCOption) SetTCPObfuscatedOnly(value bool) {
|
||||
if value {
|
||||
d.Flags.Set(2)
|
||||
d.TCPObfuscatedOnly = true
|
||||
} else {
|
||||
d.Flags.Unset(2)
|
||||
d.TCPObfuscatedOnly = false
|
||||
}
|
||||
}
|
||||
|
||||
// GetTCPObfuscatedOnly returns value of TCPObfuscatedOnly conditional field.
|
||||
func (d *DCOption) GetTCPObfuscatedOnly() (value bool) {
|
||||
if d == nil {
|
||||
return
|
||||
}
|
||||
return d.Flags.Has(2)
|
||||
}
|
||||
|
||||
// SetCDN sets value of CDN conditional field.
|
||||
func (d *DCOption) SetCDN(value bool) {
|
||||
if value {
|
||||
d.Flags.Set(3)
|
||||
d.CDN = true
|
||||
} else {
|
||||
d.Flags.Unset(3)
|
||||
d.CDN = false
|
||||
}
|
||||
}
|
||||
|
||||
// GetCDN returns value of CDN conditional field.
|
||||
func (d *DCOption) GetCDN() (value bool) {
|
||||
if d == nil {
|
||||
return
|
||||
}
|
||||
return d.Flags.Has(3)
|
||||
}
|
||||
|
||||
// SetStatic sets value of Static conditional field.
|
||||
func (d *DCOption) SetStatic(value bool) {
|
||||
if value {
|
||||
d.Flags.Set(4)
|
||||
d.Static = true
|
||||
} else {
|
||||
d.Flags.Unset(4)
|
||||
d.Static = false
|
||||
}
|
||||
}
|
||||
|
||||
// GetStatic returns value of Static conditional field.
|
||||
func (d *DCOption) GetStatic() (value bool) {
|
||||
if d == nil {
|
||||
return
|
||||
}
|
||||
return d.Flags.Has(4)
|
||||
}
|
||||
|
||||
// GetID returns value of ID field.
|
||||
func (d *DCOption) GetID() (value int) {
|
||||
if d == nil {
|
||||
return
|
||||
}
|
||||
return d.ID
|
||||
}
|
||||
|
||||
// GetIPAddress returns value of IPAddress field.
|
||||
func (d *DCOption) GetIPAddress() (value string) {
|
||||
if d == nil {
|
||||
return
|
||||
}
|
||||
return d.IPAddress
|
||||
}
|
||||
|
||||
// GetPort returns value of Port field.
|
||||
func (d *DCOption) GetPort() (value int) {
|
||||
if d == nil {
|
||||
return
|
||||
}
|
||||
return d.Port
|
||||
}
|
||||
|
||||
// SetSecret sets value of Secret conditional field.
|
||||
func (d *DCOption) SetSecret(value []byte) {
|
||||
d.Flags.Set(10)
|
||||
d.Secret = value
|
||||
}
|
||||
|
||||
// GetSecret returns value of Secret conditional field and
|
||||
// boolean which is true if field was set.
|
||||
func (d *DCOption) GetSecret() (value []byte, ok bool) {
|
||||
if d == nil {
|
||||
return
|
||||
}
|
||||
if !d.Flags.Has(10) {
|
||||
return value, false
|
||||
}
|
||||
return d.Secret, true
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// DoAuthRequest represents TL type `doAuth#fd2f6687`.
|
||||
//
|
||||
// See https://localhost:80/doc/method/doAuth for reference.
|
||||
type DoAuthRequest struct {
|
||||
}
|
||||
|
||||
// DoAuthRequestTypeID is TL type id of DoAuthRequest.
|
||||
const DoAuthRequestTypeID = 0xfd2f6687
|
||||
|
||||
// Ensuring interfaces in compile-time for DoAuthRequest.
|
||||
var (
|
||||
_ bin.Encoder = &DoAuthRequest{}
|
||||
_ bin.Decoder = &DoAuthRequest{}
|
||||
_ bin.BareEncoder = &DoAuthRequest{}
|
||||
_ bin.BareDecoder = &DoAuthRequest{}
|
||||
)
|
||||
|
||||
func (d *DoAuthRequest) Zero() bool {
|
||||
if d == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (d *DoAuthRequest) String() string {
|
||||
if d == nil {
|
||||
return "DoAuthRequest(nil)"
|
||||
}
|
||||
type Alias DoAuthRequest
|
||||
return fmt.Sprintf("DoAuthRequest%+v", Alias(*d))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*DoAuthRequest) TypeID() uint32 {
|
||||
return DoAuthRequestTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*DoAuthRequest) TypeName() string {
|
||||
return "doAuth"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (d *DoAuthRequest) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "doAuth",
|
||||
ID: DoAuthRequestTypeID,
|
||||
}
|
||||
if d == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (d *DoAuthRequest) Encode(b *bin.Buffer) error {
|
||||
if d == nil {
|
||||
return fmt.Errorf("can't encode doAuth#fd2f6687 as nil")
|
||||
}
|
||||
b.PutID(DoAuthRequestTypeID)
|
||||
return d.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (d *DoAuthRequest) EncodeBare(b *bin.Buffer) error {
|
||||
if d == nil {
|
||||
return fmt.Errorf("can't encode doAuth#fd2f6687 as nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (d *DoAuthRequest) Decode(b *bin.Buffer) error {
|
||||
if d == nil {
|
||||
return fmt.Errorf("can't decode doAuth#fd2f6687 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(DoAuthRequestTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode doAuth#fd2f6687: %w", err)
|
||||
}
|
||||
return d.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (d *DoAuthRequest) DecodeBare(b *bin.Buffer) error {
|
||||
if d == nil {
|
||||
return fmt.Errorf("can't decode doAuth#fd2f6687 to nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DoAuth invokes method doAuth#fd2f6687 returning error if any.
|
||||
//
|
||||
// See https://localhost:80/doc/method/doAuth for reference.
|
||||
func (c *Client) DoAuth(ctx context.Context) (AuthClass, error) {
|
||||
var result AuthBox
|
||||
|
||||
request := &DoAuthRequest{}
|
||||
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.Auth, nil
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// Error represents TL type `error#14feebbc`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/error for reference.
|
||||
type Error struct {
|
||||
// Error code; subject to future changes. If the error code is 406, the error message
|
||||
// must not be processed in any way and must not be displayed to the user
|
||||
Code int32
|
||||
// Error message; subject to future changes
|
||||
Message string
|
||||
// Temporary field of Error.
|
||||
Temporary bool
|
||||
}
|
||||
|
||||
// ErrorTypeID is TL type id of Error.
|
||||
const ErrorTypeID = 0x14feebbc
|
||||
|
||||
// Ensuring interfaces in compile-time for Error.
|
||||
var (
|
||||
_ bin.Encoder = &Error{}
|
||||
_ bin.Decoder = &Error{}
|
||||
_ bin.BareEncoder = &Error{}
|
||||
_ bin.BareDecoder = &Error{}
|
||||
)
|
||||
|
||||
func (e *Error) Zero() bool {
|
||||
if e == nil {
|
||||
return true
|
||||
}
|
||||
if !(e.Code == 0) {
|
||||
return false
|
||||
}
|
||||
if !(e.Message == "") {
|
||||
return false
|
||||
}
|
||||
if !(e.Temporary == false) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (e *Error) String() string {
|
||||
if e == nil {
|
||||
return "Error(nil)"
|
||||
}
|
||||
type Alias Error
|
||||
return fmt.Sprintf("Error%+v", Alias(*e))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*Error) TypeID() uint32 {
|
||||
return ErrorTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*Error) TypeName() string {
|
||||
return "error"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (e *Error) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "error",
|
||||
ID: ErrorTypeID,
|
||||
}
|
||||
if e == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Code",
|
||||
SchemaName: "code",
|
||||
},
|
||||
{
|
||||
Name: "Message",
|
||||
SchemaName: "message",
|
||||
},
|
||||
{
|
||||
Name: "Temporary",
|
||||
SchemaName: "temporary",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (e *Error) Encode(b *bin.Buffer) error {
|
||||
if e == nil {
|
||||
return fmt.Errorf("can't encode error#14feebbc as nil")
|
||||
}
|
||||
b.PutID(ErrorTypeID)
|
||||
return e.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (e *Error) EncodeBare(b *bin.Buffer) error {
|
||||
if e == nil {
|
||||
return fmt.Errorf("can't encode error#14feebbc as nil")
|
||||
}
|
||||
b.PutInt32(e.Code)
|
||||
b.PutString(e.Message)
|
||||
b.PutBool(e.Temporary)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (e *Error) Decode(b *bin.Buffer) error {
|
||||
if e == nil {
|
||||
return fmt.Errorf("can't decode error#14feebbc to nil")
|
||||
}
|
||||
if err := b.ConsumeID(ErrorTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode error#14feebbc: %w", err)
|
||||
}
|
||||
return e.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (e *Error) DecodeBare(b *bin.Buffer) error {
|
||||
if e == nil {
|
||||
return fmt.Errorf("can't decode error#14feebbc to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.Int32()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode error#14feebbc: field code: %w", err)
|
||||
}
|
||||
e.Code = value
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode error#14feebbc: field message: %w", err)
|
||||
}
|
||||
e.Message = value
|
||||
}
|
||||
{
|
||||
value, err := b.Bool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode error#14feebbc: field temporary: %w", err)
|
||||
}
|
||||
e.Temporary = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetCode returns value of Code field.
|
||||
func (e *Error) GetCode() (value int32) {
|
||||
if e == nil {
|
||||
return
|
||||
}
|
||||
return e.Code
|
||||
}
|
||||
|
||||
// GetMessage returns value of Message field.
|
||||
func (e *Error) GetMessage() (value string) {
|
||||
if e == nil {
|
||||
return
|
||||
}
|
||||
return e.Message
|
||||
}
|
||||
|
||||
// GetTemporary returns value of Temporary field.
|
||||
func (e *Error) GetTemporary() (value bool) {
|
||||
if e == nil {
|
||||
return
|
||||
}
|
||||
return e.Temporary
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// GetUpdatesResp represents TL type `getUpdatesResp#300bb5e1`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/getUpdatesResp for reference.
|
||||
type GetUpdatesResp struct {
|
||||
// Updates field of GetUpdatesResp.
|
||||
Updates []AbstractMessageClass
|
||||
}
|
||||
|
||||
// GetUpdatesRespTypeID is TL type id of GetUpdatesResp.
|
||||
const GetUpdatesRespTypeID = 0x300bb5e1
|
||||
|
||||
// Ensuring interfaces in compile-time for GetUpdatesResp.
|
||||
var (
|
||||
_ bin.Encoder = &GetUpdatesResp{}
|
||||
_ bin.Decoder = &GetUpdatesResp{}
|
||||
_ bin.BareEncoder = &GetUpdatesResp{}
|
||||
_ bin.BareDecoder = &GetUpdatesResp{}
|
||||
)
|
||||
|
||||
func (g *GetUpdatesResp) Zero() bool {
|
||||
if g == nil {
|
||||
return true
|
||||
}
|
||||
if !(g.Updates == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (g *GetUpdatesResp) String() string {
|
||||
if g == nil {
|
||||
return "GetUpdatesResp(nil)"
|
||||
}
|
||||
type Alias GetUpdatesResp
|
||||
return fmt.Sprintf("GetUpdatesResp%+v", Alias(*g))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*GetUpdatesResp) TypeID() uint32 {
|
||||
return GetUpdatesRespTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*GetUpdatesResp) TypeName() string {
|
||||
return "getUpdatesResp"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (g *GetUpdatesResp) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "getUpdatesResp",
|
||||
ID: GetUpdatesRespTypeID,
|
||||
}
|
||||
if g == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Updates",
|
||||
SchemaName: "updates",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (g *GetUpdatesResp) Encode(b *bin.Buffer) error {
|
||||
if g == nil {
|
||||
return fmt.Errorf("can't encode getUpdatesResp#300bb5e1 as nil")
|
||||
}
|
||||
b.PutID(GetUpdatesRespTypeID)
|
||||
return g.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (g *GetUpdatesResp) EncodeBare(b *bin.Buffer) error {
|
||||
if g == nil {
|
||||
return fmt.Errorf("can't encode getUpdatesResp#300bb5e1 as nil")
|
||||
}
|
||||
b.PutVectorHeader(len(g.Updates))
|
||||
for idx, v := range g.Updates {
|
||||
if v == nil {
|
||||
return fmt.Errorf("unable to encode getUpdatesResp#300bb5e1: field updates element with index %d is nil", idx)
|
||||
}
|
||||
if err := v.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode getUpdatesResp#300bb5e1: field updates element with index %d: %w", idx, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (g *GetUpdatesResp) Decode(b *bin.Buffer) error {
|
||||
if g == nil {
|
||||
return fmt.Errorf("can't decode getUpdatesResp#300bb5e1 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(GetUpdatesRespTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode getUpdatesResp#300bb5e1: %w", err)
|
||||
}
|
||||
return g.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (g *GetUpdatesResp) DecodeBare(b *bin.Buffer) error {
|
||||
if g == nil {
|
||||
return fmt.Errorf("can't decode getUpdatesResp#300bb5e1 to nil")
|
||||
}
|
||||
{
|
||||
headerLen, err := b.VectorHeader()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode getUpdatesResp#300bb5e1: field updates: %w", err)
|
||||
}
|
||||
|
||||
if headerLen > 0 {
|
||||
g.Updates = make([]AbstractMessageClass, 0, headerLen%bin.PreallocateLimit)
|
||||
}
|
||||
for idx := 0; idx < headerLen; idx++ {
|
||||
value, err := DecodeAbstractMessage(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode getUpdatesResp#300bb5e1: field updates: %w", err)
|
||||
}
|
||||
g.Updates = append(g.Updates, value)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetUpdates returns value of Updates field.
|
||||
func (g *GetUpdatesResp) GetUpdates() (value []AbstractMessageClass) {
|
||||
if g == nil {
|
||||
return
|
||||
}
|
||||
return g.Updates
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// Int32 represents TL type `int32#5cb934fa`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/int32 for reference.
|
||||
type Int32 struct {
|
||||
}
|
||||
|
||||
// Int32TypeID is TL type id of Int32.
|
||||
const Int32TypeID = 0x5cb934fa
|
||||
|
||||
// Ensuring interfaces in compile-time for Int32.
|
||||
var (
|
||||
_ bin.Encoder = &Int32{}
|
||||
_ bin.Decoder = &Int32{}
|
||||
_ bin.BareEncoder = &Int32{}
|
||||
_ bin.BareDecoder = &Int32{}
|
||||
)
|
||||
|
||||
func (i *Int32) Zero() bool {
|
||||
if i == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (i *Int32) String() string {
|
||||
if i == nil {
|
||||
return "Int32(nil)"
|
||||
}
|
||||
type Alias Int32
|
||||
return fmt.Sprintf("Int32%+v", Alias(*i))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*Int32) TypeID() uint32 {
|
||||
return Int32TypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*Int32) TypeName() string {
|
||||
return "int32"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (i *Int32) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "int32",
|
||||
ID: Int32TypeID,
|
||||
}
|
||||
if i == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (i *Int32) Encode(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode int32#5cb934fa as nil")
|
||||
}
|
||||
b.PutID(Int32TypeID)
|
||||
return i.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (i *Int32) EncodeBare(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode int32#5cb934fa as nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (i *Int32) Decode(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode int32#5cb934fa to nil")
|
||||
}
|
||||
if err := b.ConsumeID(Int32TypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode int32#5cb934fa: %w", err)
|
||||
}
|
||||
return i.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (i *Int32) DecodeBare(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode int32#5cb934fa to nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// IntVector is a box for Vector<int>
|
||||
type IntVector struct {
|
||||
// Elements of Vector<int>
|
||||
Elems []int
|
||||
}
|
||||
|
||||
// IntVectorTypeID is TL type id of IntVector.
|
||||
const IntVectorTypeID = bin.TypeVector
|
||||
|
||||
// Ensuring interfaces in compile-time for IntVector.
|
||||
var (
|
||||
_ bin.Encoder = &IntVector{}
|
||||
_ bin.Decoder = &IntVector{}
|
||||
_ bin.BareEncoder = &IntVector{}
|
||||
_ bin.BareDecoder = &IntVector{}
|
||||
)
|
||||
|
||||
func (vec *IntVector) Zero() bool {
|
||||
if vec == nil {
|
||||
return true
|
||||
}
|
||||
if !(vec.Elems == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (vec *IntVector) String() string {
|
||||
if vec == nil {
|
||||
return "IntVector(nil)"
|
||||
}
|
||||
type Alias IntVector
|
||||
return fmt.Sprintf("IntVector%+v", Alias(*vec))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*IntVector) TypeID() uint32 {
|
||||
return IntVectorTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*IntVector) TypeName() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (vec *IntVector) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "",
|
||||
ID: IntVectorTypeID,
|
||||
}
|
||||
if vec == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Elems",
|
||||
SchemaName: "Elems",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (vec *IntVector) Encode(b *bin.Buffer) error {
|
||||
if vec == nil {
|
||||
return fmt.Errorf("can't encode Vector<int> as nil")
|
||||
}
|
||||
|
||||
return vec.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (vec *IntVector) EncodeBare(b *bin.Buffer) error {
|
||||
if vec == nil {
|
||||
return fmt.Errorf("can't encode Vector<int> as nil")
|
||||
}
|
||||
b.PutVectorHeader(len(vec.Elems))
|
||||
for _, v := range vec.Elems {
|
||||
b.PutInt(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (vec *IntVector) Decode(b *bin.Buffer) error {
|
||||
if vec == nil {
|
||||
return fmt.Errorf("can't decode Vector<int> to nil")
|
||||
}
|
||||
|
||||
return vec.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (vec *IntVector) DecodeBare(b *bin.Buffer) error {
|
||||
if vec == nil {
|
||||
return fmt.Errorf("can't decode Vector<int> to nil")
|
||||
}
|
||||
{
|
||||
headerLen, err := b.VectorHeader()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode Vector<int>: field Elems: %w", err)
|
||||
}
|
||||
|
||||
if headerLen > 0 {
|
||||
vec.Elems = 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 Vector<int>: field Elems: %w", err)
|
||||
}
|
||||
vec.Elems = append(vec.Elems, value)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetElems returns value of Elems field.
|
||||
func (vec *IntVector) GetElems() (value []int) {
|
||||
if vec == nil {
|
||||
return
|
||||
}
|
||||
return vec.Elems
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// InvokeWithLayer represents TL type `invokeWithLayer#da9b0d0d`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/invokeWithLayer for reference.
|
||||
type InvokeWithLayer struct {
|
||||
// Layer field of InvokeWithLayer.
|
||||
Layer int
|
||||
// Query field of InvokeWithLayer.
|
||||
Query bin.Object
|
||||
}
|
||||
|
||||
// InvokeWithLayerTypeID is TL type id of InvokeWithLayer.
|
||||
const InvokeWithLayerTypeID = 0xda9b0d0d
|
||||
|
||||
// Ensuring interfaces in compile-time for InvokeWithLayer.
|
||||
var (
|
||||
_ bin.Encoder = &InvokeWithLayer{}
|
||||
_ bin.Decoder = &InvokeWithLayer{}
|
||||
_ bin.BareEncoder = &InvokeWithLayer{}
|
||||
_ bin.BareDecoder = &InvokeWithLayer{}
|
||||
)
|
||||
|
||||
func (i *InvokeWithLayer) Zero() bool {
|
||||
if i == nil {
|
||||
return true
|
||||
}
|
||||
if !(i.Layer == 0) {
|
||||
return false
|
||||
}
|
||||
if !(i.Query == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (i *InvokeWithLayer) String() string {
|
||||
if i == nil {
|
||||
return "InvokeWithLayer(nil)"
|
||||
}
|
||||
type Alias InvokeWithLayer
|
||||
return fmt.Sprintf("InvokeWithLayer%+v", Alias(*i))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*InvokeWithLayer) TypeID() uint32 {
|
||||
return InvokeWithLayerTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*InvokeWithLayer) TypeName() string {
|
||||
return "invokeWithLayer"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (i *InvokeWithLayer) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "invokeWithLayer",
|
||||
ID: InvokeWithLayerTypeID,
|
||||
}
|
||||
if i == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Layer",
|
||||
SchemaName: "layer",
|
||||
},
|
||||
{
|
||||
Name: "Query",
|
||||
SchemaName: "query",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (i *InvokeWithLayer) Encode(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode invokeWithLayer#da9b0d0d as nil")
|
||||
}
|
||||
b.PutID(InvokeWithLayerTypeID)
|
||||
return i.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (i *InvokeWithLayer) EncodeBare(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode invokeWithLayer#da9b0d0d as nil")
|
||||
}
|
||||
b.PutInt(i.Layer)
|
||||
if err := i.Query.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode invokeWithLayer#da9b0d0d: field query: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (i *InvokeWithLayer) Decode(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode invokeWithLayer#da9b0d0d to nil")
|
||||
}
|
||||
if err := b.ConsumeID(InvokeWithLayerTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode invokeWithLayer#da9b0d0d: %w", err)
|
||||
}
|
||||
return i.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (i *InvokeWithLayer) DecodeBare(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode invokeWithLayer#da9b0d0d to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode invokeWithLayer#da9b0d0d: field layer: %w", err)
|
||||
}
|
||||
i.Layer = value
|
||||
}
|
||||
{
|
||||
if err := i.Query.Decode(b); err != nil {
|
||||
return fmt.Errorf("unable to decode invokeWithLayer#da9b0d0d: field query: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetLayer returns value of Layer field.
|
||||
func (i *InvokeWithLayer) GetLayer() (value int) {
|
||||
if i == nil {
|
||||
return
|
||||
}
|
||||
return i.Layer
|
||||
}
|
||||
|
||||
// GetQuery returns value of Query field.
|
||||
func (i *InvokeWithLayer) GetQuery() (value bin.Object) {
|
||||
if i == nil {
|
||||
return
|
||||
}
|
||||
return i.Query
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// Message represents TL type `message#ec200d96`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/message for reference.
|
||||
type Message struct {
|
||||
// Err field of Message.
|
||||
Err Error
|
||||
}
|
||||
|
||||
// MessageTypeID is TL type id of Message.
|
||||
const MessageTypeID = 0xec200d96
|
||||
|
||||
// Ensuring interfaces in compile-time for Message.
|
||||
var (
|
||||
_ bin.Encoder = &Message{}
|
||||
_ bin.Decoder = &Message{}
|
||||
_ bin.BareEncoder = &Message{}
|
||||
_ bin.BareDecoder = &Message{}
|
||||
)
|
||||
|
||||
func (m *Message) Zero() bool {
|
||||
if m == nil {
|
||||
return true
|
||||
}
|
||||
if !(m.Err.Zero()) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (m *Message) String() string {
|
||||
if m == nil {
|
||||
return "Message(nil)"
|
||||
}
|
||||
type Alias Message
|
||||
return fmt.Sprintf("Message%+v", Alias(*m))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*Message) TypeID() uint32 {
|
||||
return MessageTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*Message) TypeName() string {
|
||||
return "message"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (m *Message) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "message",
|
||||
ID: MessageTypeID,
|
||||
}
|
||||
if m == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Err",
|
||||
SchemaName: "err",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (m *Message) Encode(b *bin.Buffer) error {
|
||||
if m == nil {
|
||||
return fmt.Errorf("can't encode message#ec200d96 as nil")
|
||||
}
|
||||
b.PutID(MessageTypeID)
|
||||
return m.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (m *Message) EncodeBare(b *bin.Buffer) error {
|
||||
if m == nil {
|
||||
return fmt.Errorf("can't encode message#ec200d96 as nil")
|
||||
}
|
||||
if err := m.Err.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode message#ec200d96: field err: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (m *Message) Decode(b *bin.Buffer) error {
|
||||
if m == nil {
|
||||
return fmt.Errorf("can't decode message#ec200d96 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(MessageTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode message#ec200d96: %w", err)
|
||||
}
|
||||
return m.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (m *Message) DecodeBare(b *bin.Buffer) error {
|
||||
if m == nil {
|
||||
return fmt.Errorf("can't decode message#ec200d96 to nil")
|
||||
}
|
||||
{
|
||||
if err := m.Err.Decode(b); err != nil {
|
||||
return fmt.Errorf("unable to decode message#ec200d96: field err: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetErr returns value of Err field.
|
||||
func (m *Message) GetErr() (value Error) {
|
||||
if m == nil {
|
||||
return
|
||||
}
|
||||
return m.Err
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// Ok represents TL type `ok#d4edbe69`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/ok for reference.
|
||||
type Ok struct {
|
||||
}
|
||||
|
||||
// OkTypeID is TL type id of Ok.
|
||||
const OkTypeID = 0xd4edbe69
|
||||
|
||||
// Ensuring interfaces in compile-time for Ok.
|
||||
var (
|
||||
_ bin.Encoder = &Ok{}
|
||||
_ bin.Decoder = &Ok{}
|
||||
_ bin.BareEncoder = &Ok{}
|
||||
_ bin.BareDecoder = &Ok{}
|
||||
)
|
||||
|
||||
func (o *Ok) Zero() bool {
|
||||
if o == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (o *Ok) String() string {
|
||||
if o == nil {
|
||||
return "Ok(nil)"
|
||||
}
|
||||
type Alias Ok
|
||||
return fmt.Sprintf("Ok%+v", Alias(*o))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*Ok) TypeID() uint32 {
|
||||
return OkTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*Ok) TypeName() string {
|
||||
return "ok"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (o *Ok) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "ok",
|
||||
ID: OkTypeID,
|
||||
}
|
||||
if o == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (o *Ok) Encode(b *bin.Buffer) error {
|
||||
if o == nil {
|
||||
return fmt.Errorf("can't encode ok#d4edbe69 as nil")
|
||||
}
|
||||
b.PutID(OkTypeID)
|
||||
return o.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (o *Ok) EncodeBare(b *bin.Buffer) error {
|
||||
if o == nil {
|
||||
return fmt.Errorf("can't encode ok#d4edbe69 as nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (o *Ok) Decode(b *bin.Buffer) error {
|
||||
if o == nil {
|
||||
return fmt.Errorf("can't decode ok#d4edbe69 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(OkTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode ok#d4edbe69: %w", err)
|
||||
}
|
||||
return o.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (o *Ok) DecodeBare(b *bin.Buffer) error {
|
||||
if o == nil {
|
||||
return fmt.Errorf("can't decode ok#d4edbe69 to nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// PingRequest represents TL type `ping#ce73048f`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/ping for reference.
|
||||
type PingRequest struct {
|
||||
// ID field of PingRequest.
|
||||
ID int32
|
||||
}
|
||||
|
||||
// PingRequestTypeID is TL type id of PingRequest.
|
||||
const PingRequestTypeID = 0xce73048f
|
||||
|
||||
// Ensuring interfaces in compile-time for PingRequest.
|
||||
var (
|
||||
_ bin.Encoder = &PingRequest{}
|
||||
_ bin.Decoder = &PingRequest{}
|
||||
_ bin.BareEncoder = &PingRequest{}
|
||||
_ bin.BareDecoder = &PingRequest{}
|
||||
)
|
||||
|
||||
func (p *PingRequest) Zero() bool {
|
||||
if p == nil {
|
||||
return true
|
||||
}
|
||||
if !(p.ID == 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (p *PingRequest) String() string {
|
||||
if p == nil {
|
||||
return "PingRequest(nil)"
|
||||
}
|
||||
type Alias PingRequest
|
||||
return fmt.Sprintf("PingRequest%+v", Alias(*p))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*PingRequest) TypeID() uint32 {
|
||||
return PingRequestTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*PingRequest) TypeName() string {
|
||||
return "ping"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (p *PingRequest) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "ping",
|
||||
ID: PingRequestTypeID,
|
||||
}
|
||||
if p == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "ID",
|
||||
SchemaName: "id",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (p *PingRequest) Encode(b *bin.Buffer) error {
|
||||
if p == nil {
|
||||
return fmt.Errorf("can't encode ping#ce73048f as nil")
|
||||
}
|
||||
b.PutID(PingRequestTypeID)
|
||||
return p.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (p *PingRequest) EncodeBare(b *bin.Buffer) error {
|
||||
if p == nil {
|
||||
return fmt.Errorf("can't encode ping#ce73048f as nil")
|
||||
}
|
||||
b.PutInt32(p.ID)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (p *PingRequest) Decode(b *bin.Buffer) error {
|
||||
if p == nil {
|
||||
return fmt.Errorf("can't decode ping#ce73048f to nil")
|
||||
}
|
||||
if err := b.ConsumeID(PingRequestTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode ping#ce73048f: %w", err)
|
||||
}
|
||||
return p.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (p *PingRequest) DecodeBare(b *bin.Buffer) error {
|
||||
if p == nil {
|
||||
return fmt.Errorf("can't decode ping#ce73048f to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.Int32()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode ping#ce73048f: field id: %w", err)
|
||||
}
|
||||
p.ID = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetID returns value of ID field.
|
||||
func (p *PingRequest) GetID() (value int32) {
|
||||
if p == nil {
|
||||
return
|
||||
}
|
||||
return p.ID
|
||||
}
|
||||
|
||||
// Ping invokes method ping#ce73048f returning error if any.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/ping for reference.
|
||||
func (c *Client) Ping(ctx context.Context, id int32) error {
|
||||
var ok Ok
|
||||
|
||||
request := &PingRequest{
|
||||
ID: id,
|
||||
}
|
||||
if err := c.rpc.Invoke(ctx, request, &ok); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,288 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// TypesMap returns mapping from type ids to TL type names.
|
||||
func TypesMap() map[uint32]string {
|
||||
return map[uint32]string{
|
||||
Int32TypeID: "int32#5cb934fa",
|
||||
StringTypeID: "string#b5286e24",
|
||||
FalseTypeID: "false#bc799737",
|
||||
TrueTypeID: "true#997275b5",
|
||||
BytesTypeID: "bytes#e937bb82",
|
||||
ErrorTypeID: "error#14feebbc",
|
||||
OkTypeID: "ok#d4edbe69",
|
||||
MessageTypeID: "message#ec200d96",
|
||||
SMSTypeID: "sms#ed8bebfe",
|
||||
ResponseIDTypeID: "responseID#85d7fd8b",
|
||||
ResponseTextTypeID: "responseText#cb0244f2",
|
||||
BigMessageTypeID: "bigMessage#7490dcc5",
|
||||
NoMessageTypeID: "noMessage#ee6324c4",
|
||||
TargetsMessageTypeID: "targetsMessage#cc6136f1",
|
||||
UpdateTypeID: "update#b03e2ef8",
|
||||
GetUpdatesRespTypeID: "getUpdatesResp#300bb5e1",
|
||||
FieldsMessageTypeID: "fieldsMessage#947225b5",
|
||||
BytesMessageTypeID: "bytesMessage#f990a67d",
|
||||
TextEntityTypeMentionTypeID: "textEntityTypeMention#37b3df65",
|
||||
TextEntityTypeHashtagTypeID: "textEntityTypeHashtag#c2f7a2dd",
|
||||
TextEntityTypeCashtagTypeID: "textEntityTypeCashtag#48e4374b",
|
||||
TextEntityTypeBotCommandTypeID: "textEntityTypeBotCommand#bb652bb3",
|
||||
TextEntityTypeURLTypeID: "textEntityTypeUrl#b1c0d47c",
|
||||
TextEntityTypeEmailAddressTypeID: "textEntityTypeEmailAddress#54f81821",
|
||||
TextEntityTypePhoneNumberTypeID: "textEntityTypePhoneNumber#bad9aa2a",
|
||||
TextEntityTypeBankCardNumberTypeID: "textEntityTypeBankCardNumber#6513910",
|
||||
TextEntityTypeBoldTypeID: "textEntityTypeBold#bcc0e1b0",
|
||||
TextEntityTypeItalicTypeID: "textEntityTypeItalic#f8f3965d",
|
||||
TextEntityTypeUnderlineTypeID: "textEntityTypeUnderline#2f39cf92",
|
||||
TextEntityTypeStrikethroughTypeID: "textEntityTypeStrikethrough#394fc4fa",
|
||||
TextEntityTypeCodeTypeID: "textEntityTypeCode#c5e9c94a",
|
||||
TextEntityTypePreTypeID: "textEntityTypePre#62491c8e",
|
||||
TextEntityTypePreCodeTypeID: "textEntityTypePreCode#c7a77aab",
|
||||
TextEntityTypeTextURLTypeID: "textEntityTypeTextUrl#1a912463",
|
||||
TextEntityTypeMentionNameTypeID: "textEntityTypeMentionName#d0d2685d",
|
||||
TextEntityTypeID: "textEntity#8bab99a8",
|
||||
TextEntitiesTypeID: "textEntities#cf89c258",
|
||||
TestIntTypeID: "testInt#ddbd2c09",
|
||||
TestStringTypeID: "testString#fe56688c",
|
||||
TestBytesTypeID: "testBytes#a422c4de",
|
||||
TestVectorIntTypeID: "testVectorInt#df9eb113",
|
||||
TestVectorIntObjectTypeID: "testVectorIntObject#f152999b",
|
||||
TestVectorStringTypeID: "testVectorString#5d6f85bc",
|
||||
TestVectorStringObjectTypeID: "testVectorStringObject#e5ecc0d",
|
||||
TestVectorBytesTypeID: "testVectorBytes#a590fb25",
|
||||
TestVectorVectorTypeID: "testVectorVector#69e8846c",
|
||||
ClientDHInnerDataTypeID: "client_DH_inner_data#6643b654",
|
||||
DCOptionTypeID: "dcOption#18b7a10d",
|
||||
ConfigTypeID: "config#330b4067",
|
||||
InvokeWithLayerTypeID: "invokeWithLayer#da9b0d0d",
|
||||
AuthTypeID: "auth#f8bb4a38",
|
||||
AuthPasswordTypeID: "authPassword#29bacabb",
|
||||
UserAuthTypeID: "user.auth#f4815592",
|
||||
UserAuthPasswordTypeID: "user.authPassword#5981e317",
|
||||
ThemeTypeID: "theme#28f1114",
|
||||
AccountThemesNotModifiedTypeID: "account.themesNotModified#f41eb622",
|
||||
AccountThemesTypeID: "account.themes#7f676421",
|
||||
PingRequestTypeID: "ping#ce73048f",
|
||||
SendRequestTypeID: "send#f74488a",
|
||||
SendMultipleSMSRequestTypeID: "sendMultipleSMS#df18e5ca",
|
||||
DoAuthRequestTypeID: "doAuth#fd2f6687",
|
||||
EchoVectorRequestTypeID: "echoVector#d4785939",
|
||||
}
|
||||
}
|
||||
|
||||
// NamesMap returns mapping from type names to TL type ids.
|
||||
func NamesMap() map[string]uint32 {
|
||||
return map[string]uint32{
|
||||
"int32": Int32TypeID,
|
||||
"string": StringTypeID,
|
||||
"false": FalseTypeID,
|
||||
"true": TrueTypeID,
|
||||
"bytes": BytesTypeID,
|
||||
"error": ErrorTypeID,
|
||||
"ok": OkTypeID,
|
||||
"message": MessageTypeID,
|
||||
"sms": SMSTypeID,
|
||||
"responseID": ResponseIDTypeID,
|
||||
"responseText": ResponseTextTypeID,
|
||||
"bigMessage": BigMessageTypeID,
|
||||
"noMessage": NoMessageTypeID,
|
||||
"targetsMessage": TargetsMessageTypeID,
|
||||
"update": UpdateTypeID,
|
||||
"getUpdatesResp": GetUpdatesRespTypeID,
|
||||
"fieldsMessage": FieldsMessageTypeID,
|
||||
"bytesMessage": BytesMessageTypeID,
|
||||
"textEntityTypeMention": TextEntityTypeMentionTypeID,
|
||||
"textEntityTypeHashtag": TextEntityTypeHashtagTypeID,
|
||||
"textEntityTypeCashtag": TextEntityTypeCashtagTypeID,
|
||||
"textEntityTypeBotCommand": TextEntityTypeBotCommandTypeID,
|
||||
"textEntityTypeUrl": TextEntityTypeURLTypeID,
|
||||
"textEntityTypeEmailAddress": TextEntityTypeEmailAddressTypeID,
|
||||
"textEntityTypePhoneNumber": TextEntityTypePhoneNumberTypeID,
|
||||
"textEntityTypeBankCardNumber": TextEntityTypeBankCardNumberTypeID,
|
||||
"textEntityTypeBold": TextEntityTypeBoldTypeID,
|
||||
"textEntityTypeItalic": TextEntityTypeItalicTypeID,
|
||||
"textEntityTypeUnderline": TextEntityTypeUnderlineTypeID,
|
||||
"textEntityTypeStrikethrough": TextEntityTypeStrikethroughTypeID,
|
||||
"textEntityTypeCode": TextEntityTypeCodeTypeID,
|
||||
"textEntityTypePre": TextEntityTypePreTypeID,
|
||||
"textEntityTypePreCode": TextEntityTypePreCodeTypeID,
|
||||
"textEntityTypeTextUrl": TextEntityTypeTextURLTypeID,
|
||||
"textEntityTypeMentionName": TextEntityTypeMentionNameTypeID,
|
||||
"textEntity": TextEntityTypeID,
|
||||
"textEntities": TextEntitiesTypeID,
|
||||
"testInt": TestIntTypeID,
|
||||
"testString": TestStringTypeID,
|
||||
"testBytes": TestBytesTypeID,
|
||||
"testVectorInt": TestVectorIntTypeID,
|
||||
"testVectorIntObject": TestVectorIntObjectTypeID,
|
||||
"testVectorString": TestVectorStringTypeID,
|
||||
"testVectorStringObject": TestVectorStringObjectTypeID,
|
||||
"testVectorBytes": TestVectorBytesTypeID,
|
||||
"testVectorVector": TestVectorVectorTypeID,
|
||||
"client_DH_inner_data": ClientDHInnerDataTypeID,
|
||||
"dcOption": DCOptionTypeID,
|
||||
"config": ConfigTypeID,
|
||||
"invokeWithLayer": InvokeWithLayerTypeID,
|
||||
"auth": AuthTypeID,
|
||||
"authPassword": AuthPasswordTypeID,
|
||||
"user.auth": UserAuthTypeID,
|
||||
"user.authPassword": UserAuthPasswordTypeID,
|
||||
"theme": ThemeTypeID,
|
||||
"account.themesNotModified": AccountThemesNotModifiedTypeID,
|
||||
"account.themes": AccountThemesTypeID,
|
||||
"ping": PingRequestTypeID,
|
||||
"send": SendRequestTypeID,
|
||||
"sendMultipleSMS": SendMultipleSMSRequestTypeID,
|
||||
"doAuth": DoAuthRequestTypeID,
|
||||
"echoVector": EchoVectorRequestTypeID,
|
||||
}
|
||||
}
|
||||
|
||||
// TypesConstructorMap maps type ids to constructors.
|
||||
func TypesConstructorMap() map[uint32]func() bin.Object {
|
||||
return map[uint32]func() bin.Object{
|
||||
Int32TypeID: func() bin.Object { return &Int32{} },
|
||||
StringTypeID: func() bin.Object { return &String{} },
|
||||
FalseTypeID: func() bin.Object { return &False{} },
|
||||
TrueTypeID: func() bin.Object { return &True{} },
|
||||
BytesTypeID: func() bin.Object { return &Bytes{} },
|
||||
ErrorTypeID: func() bin.Object { return &Error{} },
|
||||
OkTypeID: func() bin.Object { return &Ok{} },
|
||||
MessageTypeID: func() bin.Object { return &Message{} },
|
||||
SMSTypeID: func() bin.Object { return &SMS{} },
|
||||
ResponseIDTypeID: func() bin.Object { return &ResponseID{} },
|
||||
ResponseTextTypeID: func() bin.Object { return &ResponseText{} },
|
||||
BigMessageTypeID: func() bin.Object { return &BigMessage{} },
|
||||
NoMessageTypeID: func() bin.Object { return &NoMessage{} },
|
||||
TargetsMessageTypeID: func() bin.Object { return &TargetsMessage{} },
|
||||
UpdateTypeID: func() bin.Object { return &Update{} },
|
||||
GetUpdatesRespTypeID: func() bin.Object { return &GetUpdatesResp{} },
|
||||
FieldsMessageTypeID: func() bin.Object { return &FieldsMessage{} },
|
||||
BytesMessageTypeID: func() bin.Object { return &BytesMessage{} },
|
||||
TextEntityTypeMentionTypeID: func() bin.Object { return &TextEntityTypeMention{} },
|
||||
TextEntityTypeHashtagTypeID: func() bin.Object { return &TextEntityTypeHashtag{} },
|
||||
TextEntityTypeCashtagTypeID: func() bin.Object { return &TextEntityTypeCashtag{} },
|
||||
TextEntityTypeBotCommandTypeID: func() bin.Object { return &TextEntityTypeBotCommand{} },
|
||||
TextEntityTypeURLTypeID: func() bin.Object { return &TextEntityTypeURL{} },
|
||||
TextEntityTypeEmailAddressTypeID: func() bin.Object { return &TextEntityTypeEmailAddress{} },
|
||||
TextEntityTypePhoneNumberTypeID: func() bin.Object { return &TextEntityTypePhoneNumber{} },
|
||||
TextEntityTypeBankCardNumberTypeID: func() bin.Object { return &TextEntityTypeBankCardNumber{} },
|
||||
TextEntityTypeBoldTypeID: func() bin.Object { return &TextEntityTypeBold{} },
|
||||
TextEntityTypeItalicTypeID: func() bin.Object { return &TextEntityTypeItalic{} },
|
||||
TextEntityTypeUnderlineTypeID: func() bin.Object { return &TextEntityTypeUnderline{} },
|
||||
TextEntityTypeStrikethroughTypeID: func() bin.Object { return &TextEntityTypeStrikethrough{} },
|
||||
TextEntityTypeCodeTypeID: func() bin.Object { return &TextEntityTypeCode{} },
|
||||
TextEntityTypePreTypeID: func() bin.Object { return &TextEntityTypePre{} },
|
||||
TextEntityTypePreCodeTypeID: func() bin.Object { return &TextEntityTypePreCode{} },
|
||||
TextEntityTypeTextURLTypeID: func() bin.Object { return &TextEntityTypeTextURL{} },
|
||||
TextEntityTypeMentionNameTypeID: func() bin.Object { return &TextEntityTypeMentionName{} },
|
||||
TextEntityTypeID: func() bin.Object { return &TextEntity{} },
|
||||
TextEntitiesTypeID: func() bin.Object { return &TextEntities{} },
|
||||
TestIntTypeID: func() bin.Object { return &TestInt{} },
|
||||
TestStringTypeID: func() bin.Object { return &TestString{} },
|
||||
TestBytesTypeID: func() bin.Object { return &TestBytes{} },
|
||||
TestVectorIntTypeID: func() bin.Object { return &TestVectorInt{} },
|
||||
TestVectorIntObjectTypeID: func() bin.Object { return &TestVectorIntObject{} },
|
||||
TestVectorStringTypeID: func() bin.Object { return &TestVectorString{} },
|
||||
TestVectorStringObjectTypeID: func() bin.Object { return &TestVectorStringObject{} },
|
||||
TestVectorBytesTypeID: func() bin.Object { return &TestVectorBytes{} },
|
||||
TestVectorVectorTypeID: func() bin.Object { return &TestVectorVector{} },
|
||||
ClientDHInnerDataTypeID: func() bin.Object { return &ClientDHInnerData{} },
|
||||
DCOptionTypeID: func() bin.Object { return &DCOption{} },
|
||||
ConfigTypeID: func() bin.Object { return &Config{} },
|
||||
InvokeWithLayerTypeID: func() bin.Object { return &InvokeWithLayer{} },
|
||||
AuthTypeID: func() bin.Object { return &Auth{} },
|
||||
AuthPasswordTypeID: func() bin.Object { return &AuthPassword{} },
|
||||
UserAuthTypeID: func() bin.Object { return &UserAuth{} },
|
||||
UserAuthPasswordTypeID: func() bin.Object { return &UserAuthPassword{} },
|
||||
ThemeTypeID: func() bin.Object { return &Theme{} },
|
||||
AccountThemesNotModifiedTypeID: func() bin.Object { return &AccountThemesNotModified{} },
|
||||
AccountThemesTypeID: func() bin.Object { return &AccountThemes{} },
|
||||
PingRequestTypeID: func() bin.Object { return &PingRequest{} },
|
||||
SendRequestTypeID: func() bin.Object { return &SendRequest{} },
|
||||
SendMultipleSMSRequestTypeID: func() bin.Object { return &SendMultipleSMSRequest{} },
|
||||
DoAuthRequestTypeID: func() bin.Object { return &DoAuthRequest{} },
|
||||
EchoVectorRequestTypeID: func() bin.Object { return &EchoVectorRequest{} },
|
||||
}
|
||||
}
|
||||
|
||||
// ClassConstructorsMap maps class schema name to constructors type ids.
|
||||
func ClassConstructorsMap() map[string][]uint32 {
|
||||
return map[string][]uint32{
|
||||
AbstractMessageClassName: {
|
||||
BigMessageTypeID,
|
||||
NoMessageTypeID,
|
||||
TargetsMessageTypeID,
|
||||
FieldsMessageTypeID,
|
||||
BytesMessageTypeID,
|
||||
},
|
||||
AccountThemesClassName: {
|
||||
AccountThemesNotModifiedTypeID,
|
||||
AccountThemesTypeID,
|
||||
},
|
||||
AuthClassName: {
|
||||
AuthTypeID,
|
||||
AuthPasswordTypeID,
|
||||
},
|
||||
BoolClassName: {
|
||||
FalseTypeID,
|
||||
TrueTypeID,
|
||||
},
|
||||
ResponseClassName: {
|
||||
ResponseIDTypeID,
|
||||
ResponseTextTypeID,
|
||||
},
|
||||
TextEntityTypeClassName: {
|
||||
TextEntityTypeMentionTypeID,
|
||||
TextEntityTypeHashtagTypeID,
|
||||
TextEntityTypeCashtagTypeID,
|
||||
TextEntityTypeBotCommandTypeID,
|
||||
TextEntityTypeURLTypeID,
|
||||
TextEntityTypeEmailAddressTypeID,
|
||||
TextEntityTypePhoneNumberTypeID,
|
||||
TextEntityTypeBankCardNumberTypeID,
|
||||
TextEntityTypeBoldTypeID,
|
||||
TextEntityTypeItalicTypeID,
|
||||
TextEntityTypeUnderlineTypeID,
|
||||
TextEntityTypeStrikethroughTypeID,
|
||||
TextEntityTypeCodeTypeID,
|
||||
TextEntityTypePreTypeID,
|
||||
TextEntityTypePreCodeTypeID,
|
||||
TextEntityTypeTextURLTypeID,
|
||||
TextEntityTypeMentionNameTypeID,
|
||||
},
|
||||
UserAuthClassName: {
|
||||
UserAuthTypeID,
|
||||
UserAuthPasswordTypeID,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,375 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// ResponseID represents TL type `responseID#85d7fd8b`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/responseID for reference.
|
||||
type ResponseID struct {
|
||||
// ID field of ResponseID.
|
||||
ID int32
|
||||
}
|
||||
|
||||
// ResponseIDTypeID is TL type id of ResponseID.
|
||||
const ResponseIDTypeID = 0x85d7fd8b
|
||||
|
||||
// construct implements constructor of ResponseClass.
|
||||
func (r ResponseID) construct() ResponseClass { return &r }
|
||||
|
||||
// Ensuring interfaces in compile-time for ResponseID.
|
||||
var (
|
||||
_ bin.Encoder = &ResponseID{}
|
||||
_ bin.Decoder = &ResponseID{}
|
||||
_ bin.BareEncoder = &ResponseID{}
|
||||
_ bin.BareDecoder = &ResponseID{}
|
||||
|
||||
_ ResponseClass = &ResponseID{}
|
||||
)
|
||||
|
||||
func (r *ResponseID) Zero() bool {
|
||||
if r == nil {
|
||||
return true
|
||||
}
|
||||
if !(r.ID == 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (r *ResponseID) String() string {
|
||||
if r == nil {
|
||||
return "ResponseID(nil)"
|
||||
}
|
||||
type Alias ResponseID
|
||||
return fmt.Sprintf("ResponseID%+v", Alias(*r))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*ResponseID) TypeID() uint32 {
|
||||
return ResponseIDTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*ResponseID) TypeName() string {
|
||||
return "responseID"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (r *ResponseID) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "responseID",
|
||||
ID: ResponseIDTypeID,
|
||||
}
|
||||
if r == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "ID",
|
||||
SchemaName: "id",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (r *ResponseID) Encode(b *bin.Buffer) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("can't encode responseID#85d7fd8b as nil")
|
||||
}
|
||||
b.PutID(ResponseIDTypeID)
|
||||
return r.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (r *ResponseID) EncodeBare(b *bin.Buffer) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("can't encode responseID#85d7fd8b as nil")
|
||||
}
|
||||
b.PutInt32(r.ID)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (r *ResponseID) Decode(b *bin.Buffer) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("can't decode responseID#85d7fd8b to nil")
|
||||
}
|
||||
if err := b.ConsumeID(ResponseIDTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode responseID#85d7fd8b: %w", err)
|
||||
}
|
||||
return r.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (r *ResponseID) DecodeBare(b *bin.Buffer) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("can't decode responseID#85d7fd8b to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.Int32()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode responseID#85d7fd8b: field id: %w", err)
|
||||
}
|
||||
r.ID = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetID returns value of ID field.
|
||||
func (r *ResponseID) GetID() (value int32) {
|
||||
if r == nil {
|
||||
return
|
||||
}
|
||||
return r.ID
|
||||
}
|
||||
|
||||
// ResponseText represents TL type `responseText#cb0244f2`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/responseText for reference.
|
||||
type ResponseText struct {
|
||||
// Text field of ResponseText.
|
||||
Text string
|
||||
}
|
||||
|
||||
// ResponseTextTypeID is TL type id of ResponseText.
|
||||
const ResponseTextTypeID = 0xcb0244f2
|
||||
|
||||
// construct implements constructor of ResponseClass.
|
||||
func (r ResponseText) construct() ResponseClass { return &r }
|
||||
|
||||
// Ensuring interfaces in compile-time for ResponseText.
|
||||
var (
|
||||
_ bin.Encoder = &ResponseText{}
|
||||
_ bin.Decoder = &ResponseText{}
|
||||
_ bin.BareEncoder = &ResponseText{}
|
||||
_ bin.BareDecoder = &ResponseText{}
|
||||
|
||||
_ ResponseClass = &ResponseText{}
|
||||
)
|
||||
|
||||
func (r *ResponseText) Zero() bool {
|
||||
if r == nil {
|
||||
return true
|
||||
}
|
||||
if !(r.Text == "") {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (r *ResponseText) String() string {
|
||||
if r == nil {
|
||||
return "ResponseText(nil)"
|
||||
}
|
||||
type Alias ResponseText
|
||||
return fmt.Sprintf("ResponseText%+v", Alias(*r))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*ResponseText) TypeID() uint32 {
|
||||
return ResponseTextTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*ResponseText) TypeName() string {
|
||||
return "responseText"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (r *ResponseText) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "responseText",
|
||||
ID: ResponseTextTypeID,
|
||||
}
|
||||
if r == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Text",
|
||||
SchemaName: "text",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (r *ResponseText) Encode(b *bin.Buffer) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("can't encode responseText#cb0244f2 as nil")
|
||||
}
|
||||
b.PutID(ResponseTextTypeID)
|
||||
return r.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (r *ResponseText) EncodeBare(b *bin.Buffer) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("can't encode responseText#cb0244f2 as nil")
|
||||
}
|
||||
b.PutString(r.Text)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (r *ResponseText) Decode(b *bin.Buffer) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("can't decode responseText#cb0244f2 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(ResponseTextTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode responseText#cb0244f2: %w", err)
|
||||
}
|
||||
return r.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (r *ResponseText) DecodeBare(b *bin.Buffer) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("can't decode responseText#cb0244f2 to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode responseText#cb0244f2: field text: %w", err)
|
||||
}
|
||||
r.Text = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetText returns value of Text field.
|
||||
func (r *ResponseText) GetText() (value string) {
|
||||
if r == nil {
|
||||
return
|
||||
}
|
||||
return r.Text
|
||||
}
|
||||
|
||||
// ResponseClassName is schema name of ResponseClass.
|
||||
const ResponseClassName = "Response"
|
||||
|
||||
// ResponseClass represents Response generic type.
|
||||
//
|
||||
// See https://localhost:80/doc/type/Response for reference.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// g, err := td.DecodeResponse(buf)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// switch v := g.(type) {
|
||||
// case *td.ResponseID: // responseID#85d7fd8b
|
||||
// case *td.ResponseText: // responseText#cb0244f2
|
||||
// default: panic(v)
|
||||
// }
|
||||
type ResponseClass interface {
|
||||
bin.Encoder
|
||||
bin.Decoder
|
||||
bin.BareEncoder
|
||||
bin.BareDecoder
|
||||
construct() ResponseClass
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
TypeID() uint32
|
||||
// TypeName returns name of type in TL schema.
|
||||
TypeName() string
|
||||
// String implements fmt.Stringer.
|
||||
String() string
|
||||
// Zero returns true if current object has a zero value.
|
||||
Zero() bool
|
||||
}
|
||||
|
||||
// DecodeResponse implements binary de-serialization for ResponseClass.
|
||||
func DecodeResponse(buf *bin.Buffer) (ResponseClass, error) {
|
||||
id, err := buf.PeekID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch id {
|
||||
case ResponseIDTypeID:
|
||||
// Decoding responseID#85d7fd8b.
|
||||
v := ResponseID{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode ResponseClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
case ResponseTextTypeID:
|
||||
// Decoding responseText#cb0244f2.
|
||||
v := ResponseText{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode ResponseClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unable to decode ResponseClass: %w", bin.NewUnexpectedID(id))
|
||||
}
|
||||
}
|
||||
|
||||
// Response boxes the ResponseClass providing a helper.
|
||||
type ResponseBox struct {
|
||||
Response ResponseClass
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder for ResponseBox.
|
||||
func (b *ResponseBox) Decode(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("unable to decode ResponseBox to nil")
|
||||
}
|
||||
v, err := DecodeResponse(buf)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode boxed value: %w", err)
|
||||
}
|
||||
b.Response = v
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode implements bin.Encode for ResponseBox.
|
||||
func (b *ResponseBox) Encode(buf *bin.Buffer) error {
|
||||
if b == nil || b.Response == nil {
|
||||
return fmt.Errorf("unable to encode ResponseClass as nil")
|
||||
}
|
||||
return b.Response.Encode(buf)
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// SendRequest represents TL type `send#f74488a`.
|
||||
//
|
||||
// See https://localhost:80/doc/method/send for reference.
|
||||
type SendRequest struct {
|
||||
// Msg field of SendRequest.
|
||||
Msg SMS
|
||||
}
|
||||
|
||||
// SendRequestTypeID is TL type id of SendRequest.
|
||||
const SendRequestTypeID = 0xf74488a
|
||||
|
||||
// Ensuring interfaces in compile-time for SendRequest.
|
||||
var (
|
||||
_ bin.Encoder = &SendRequest{}
|
||||
_ bin.Decoder = &SendRequest{}
|
||||
_ bin.BareEncoder = &SendRequest{}
|
||||
_ bin.BareDecoder = &SendRequest{}
|
||||
)
|
||||
|
||||
func (s *SendRequest) Zero() bool {
|
||||
if s == nil {
|
||||
return true
|
||||
}
|
||||
if !(s.Msg.Zero()) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (s *SendRequest) String() string {
|
||||
if s == nil {
|
||||
return "SendRequest(nil)"
|
||||
}
|
||||
type Alias SendRequest
|
||||
return fmt.Sprintf("SendRequest%+v", Alias(*s))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*SendRequest) TypeID() uint32 {
|
||||
return SendRequestTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*SendRequest) TypeName() string {
|
||||
return "send"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (s *SendRequest) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "send",
|
||||
ID: SendRequestTypeID,
|
||||
}
|
||||
if s == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Msg",
|
||||
SchemaName: "msg",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (s *SendRequest) Encode(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode send#f74488a as nil")
|
||||
}
|
||||
b.PutID(SendRequestTypeID)
|
||||
return s.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (s *SendRequest) EncodeBare(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode send#f74488a as nil")
|
||||
}
|
||||
if err := s.Msg.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode send#f74488a: field msg: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (s *SendRequest) Decode(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode send#f74488a to nil")
|
||||
}
|
||||
if err := b.ConsumeID(SendRequestTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode send#f74488a: %w", err)
|
||||
}
|
||||
return s.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (s *SendRequest) DecodeBare(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode send#f74488a to nil")
|
||||
}
|
||||
{
|
||||
if err := s.Msg.Decode(b); err != nil {
|
||||
return fmt.Errorf("unable to decode send#f74488a: field msg: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetMsg returns value of Msg field.
|
||||
func (s *SendRequest) GetMsg() (value SMS) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
return s.Msg
|
||||
}
|
||||
|
||||
// Send invokes method send#f74488a returning error if any.
|
||||
//
|
||||
// See https://localhost:80/doc/method/send for reference.
|
||||
func (c *Client) Send(ctx context.Context, msg SMS) (*SMS, error) {
|
||||
var result SMS
|
||||
|
||||
request := &SendRequest{
|
||||
Msg: msg,
|
||||
}
|
||||
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &result, nil
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// SendMultipleSMSRequest represents TL type `sendMultipleSMS#df18e5ca`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/sendMultipleSMS for reference.
|
||||
type SendMultipleSMSRequest struct {
|
||||
// Messages field of SendMultipleSMSRequest.
|
||||
Messages []SMS
|
||||
}
|
||||
|
||||
// SendMultipleSMSRequestTypeID is TL type id of SendMultipleSMSRequest.
|
||||
const SendMultipleSMSRequestTypeID = 0xdf18e5ca
|
||||
|
||||
// Ensuring interfaces in compile-time for SendMultipleSMSRequest.
|
||||
var (
|
||||
_ bin.Encoder = &SendMultipleSMSRequest{}
|
||||
_ bin.Decoder = &SendMultipleSMSRequest{}
|
||||
_ bin.BareEncoder = &SendMultipleSMSRequest{}
|
||||
_ bin.BareDecoder = &SendMultipleSMSRequest{}
|
||||
)
|
||||
|
||||
func (s *SendMultipleSMSRequest) Zero() bool {
|
||||
if s == nil {
|
||||
return true
|
||||
}
|
||||
if !(s.Messages == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (s *SendMultipleSMSRequest) String() string {
|
||||
if s == nil {
|
||||
return "SendMultipleSMSRequest(nil)"
|
||||
}
|
||||
type Alias SendMultipleSMSRequest
|
||||
return fmt.Sprintf("SendMultipleSMSRequest%+v", Alias(*s))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*SendMultipleSMSRequest) TypeID() uint32 {
|
||||
return SendMultipleSMSRequestTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*SendMultipleSMSRequest) TypeName() string {
|
||||
return "sendMultipleSMS"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (s *SendMultipleSMSRequest) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "sendMultipleSMS",
|
||||
ID: SendMultipleSMSRequestTypeID,
|
||||
}
|
||||
if s == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Messages",
|
||||
SchemaName: "messages",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (s *SendMultipleSMSRequest) Encode(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode sendMultipleSMS#df18e5ca as nil")
|
||||
}
|
||||
b.PutID(SendMultipleSMSRequestTypeID)
|
||||
return s.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (s *SendMultipleSMSRequest) EncodeBare(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode sendMultipleSMS#df18e5ca as nil")
|
||||
}
|
||||
b.PutInt(len(s.Messages))
|
||||
for idx, v := range s.Messages {
|
||||
if err := v.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode sendMultipleSMS#df18e5ca: field messages element with index %d: %w", idx, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (s *SendMultipleSMSRequest) Decode(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode sendMultipleSMS#df18e5ca to nil")
|
||||
}
|
||||
if err := b.ConsumeID(SendMultipleSMSRequestTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode sendMultipleSMS#df18e5ca: %w", err)
|
||||
}
|
||||
return s.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (s *SendMultipleSMSRequest) DecodeBare(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode sendMultipleSMS#df18e5ca to nil")
|
||||
}
|
||||
{
|
||||
headerLen, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode sendMultipleSMS#df18e5ca: field messages: %w", err)
|
||||
}
|
||||
|
||||
if headerLen > 0 {
|
||||
s.Messages = make([]SMS, 0, headerLen%bin.PreallocateLimit)
|
||||
}
|
||||
for idx := 0; idx < headerLen; idx++ {
|
||||
var value SMS
|
||||
if err := value.Decode(b); err != nil {
|
||||
return fmt.Errorf("unable to decode sendMultipleSMS#df18e5ca: field messages: %w", err)
|
||||
}
|
||||
s.Messages = append(s.Messages, value)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetMessages returns value of Messages field.
|
||||
func (s *SendMultipleSMSRequest) GetMessages() (value []SMS) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
return s.Messages
|
||||
}
|
||||
|
||||
// SendMultipleSMS invokes method sendMultipleSMS#df18e5ca returning error if any.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/sendMultipleSMS for reference.
|
||||
func (c *Client) SendMultipleSMS(ctx context.Context, messages []SMS) error {
|
||||
var ok Ok
|
||||
|
||||
request := &SendMultipleSMSRequest{
|
||||
Messages: messages,
|
||||
}
|
||||
if err := c.rpc.Invoke(ctx, request, &ok); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
type ServerDispatcher struct {
|
||||
fallback func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error)
|
||||
handlers map[uint32]func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error)
|
||||
}
|
||||
|
||||
func NewServerDispatcher(fallback func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error)) *ServerDispatcher {
|
||||
return &ServerDispatcher{
|
||||
fallback: fallback,
|
||||
handlers: map[uint32]func(context.Context, *bin.Buffer) (bin.Encoder, error){},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ServerDispatcher) Handle(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) {
|
||||
id, err := b.PeekID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
f, ok := s.handlers[id]
|
||||
if !ok {
|
||||
return s.fallback(ctx, b)
|
||||
}
|
||||
|
||||
return f(ctx, b)
|
||||
}
|
||||
|
||||
func (s *ServerDispatcher) OnPing(f func(ctx context.Context, id int32) error) {
|
||||
handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) {
|
||||
var request PingRequest
|
||||
if err := request.Decode(b); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := f(ctx, request.ID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Ok{}, nil
|
||||
}
|
||||
|
||||
s.handlers[PingRequestTypeID] = handler
|
||||
}
|
||||
|
||||
func (s *ServerDispatcher) OnSend(f func(ctx context.Context, msg SMS) (*SMS, error)) {
|
||||
handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) {
|
||||
var request SendRequest
|
||||
if err := request.Decode(b); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := f(ctx, request.Msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return response, nil
|
||||
}
|
||||
|
||||
s.handlers[SendRequestTypeID] = handler
|
||||
}
|
||||
|
||||
func (s *ServerDispatcher) OnSendMultipleSMS(f func(ctx context.Context, messages []SMS) error) {
|
||||
handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) {
|
||||
var request SendMultipleSMSRequest
|
||||
if err := request.Decode(b); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := f(ctx, request.Messages); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Ok{}, nil
|
||||
}
|
||||
|
||||
s.handlers[SendMultipleSMSRequestTypeID] = handler
|
||||
}
|
||||
|
||||
func (s *ServerDispatcher) OnDoAuth(f func(ctx context.Context) (AuthClass, error)) {
|
||||
handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) {
|
||||
var request DoAuthRequest
|
||||
if err := request.Decode(b); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := f(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &AuthBox{Auth: response}, nil
|
||||
}
|
||||
|
||||
s.handlers[DoAuthRequestTypeID] = handler
|
||||
}
|
||||
|
||||
func (s *ServerDispatcher) OnEchoVector(f func(ctx context.Context, ids []int) ([]int, error)) {
|
||||
handler := func(ctx context.Context, b *bin.Buffer) (bin.Encoder, error) {
|
||||
var request EchoVectorRequest
|
||||
if err := request.Decode(b); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response, err := f(ctx, request.IDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &IntVector{Elems: response}, nil
|
||||
}
|
||||
|
||||
s.handlers[EchoVectorRequestTypeID] = handler
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// SMS represents TL type `sms#ed8bebfe`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/sms for reference.
|
||||
type SMS struct {
|
||||
// Text field of SMS.
|
||||
Text string
|
||||
}
|
||||
|
||||
// SMSTypeID is TL type id of SMS.
|
||||
const SMSTypeID = 0xed8bebfe
|
||||
|
||||
// Ensuring interfaces in compile-time for SMS.
|
||||
var (
|
||||
_ bin.Encoder = &SMS{}
|
||||
_ bin.Decoder = &SMS{}
|
||||
_ bin.BareEncoder = &SMS{}
|
||||
_ bin.BareDecoder = &SMS{}
|
||||
)
|
||||
|
||||
func (s *SMS) Zero() bool {
|
||||
if s == nil {
|
||||
return true
|
||||
}
|
||||
if !(s.Text == "") {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (s *SMS) String() string {
|
||||
if s == nil {
|
||||
return "SMS(nil)"
|
||||
}
|
||||
type Alias SMS
|
||||
return fmt.Sprintf("SMS%+v", Alias(*s))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*SMS) TypeID() uint32 {
|
||||
return SMSTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*SMS) TypeName() string {
|
||||
return "sms"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (s *SMS) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "sms",
|
||||
ID: SMSTypeID,
|
||||
}
|
||||
if s == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Text",
|
||||
SchemaName: "text",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (s *SMS) Encode(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode sms#ed8bebfe as nil")
|
||||
}
|
||||
b.PutID(SMSTypeID)
|
||||
return s.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (s *SMS) EncodeBare(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode sms#ed8bebfe as nil")
|
||||
}
|
||||
b.PutString(s.Text)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (s *SMS) Decode(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode sms#ed8bebfe to nil")
|
||||
}
|
||||
if err := b.ConsumeID(SMSTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode sms#ed8bebfe: %w", err)
|
||||
}
|
||||
return s.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (s *SMS) DecodeBare(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode sms#ed8bebfe to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode sms#ed8bebfe: field text: %w", err)
|
||||
}
|
||||
s.Text = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetText returns value of Text field.
|
||||
func (s *SMS) GetText() (value string) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
return s.Text
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// String represents TL type `string#b5286e24`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/string for reference.
|
||||
type String struct {
|
||||
}
|
||||
|
||||
// StringTypeID is TL type id of String.
|
||||
const StringTypeID = 0xb5286e24
|
||||
|
||||
// Ensuring interfaces in compile-time for String.
|
||||
var (
|
||||
_ bin.Encoder = &String{}
|
||||
_ bin.Decoder = &String{}
|
||||
_ bin.BareEncoder = &String{}
|
||||
_ bin.BareDecoder = &String{}
|
||||
)
|
||||
|
||||
func (s *String) Zero() bool {
|
||||
if s == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (s *String) String() string {
|
||||
if s == nil {
|
||||
return "String(nil)"
|
||||
}
|
||||
type Alias String
|
||||
return fmt.Sprintf("String%+v", Alias(*s))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*String) TypeID() uint32 {
|
||||
return StringTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*String) TypeName() string {
|
||||
return "string"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (s *String) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "string",
|
||||
ID: StringTypeID,
|
||||
}
|
||||
if s == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (s *String) Encode(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode string#b5286e24 as nil")
|
||||
}
|
||||
b.PutID(StringTypeID)
|
||||
return s.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (s *String) EncodeBare(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode string#b5286e24 as nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (s *String) Decode(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode string#b5286e24 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(StringTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode string#b5286e24: %w", err)
|
||||
}
|
||||
return s.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (s *String) DecodeBare(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode string#b5286e24 to nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// TestBytes represents TL type `testBytes#a422c4de`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/testBytes for reference.
|
||||
type TestBytes struct {
|
||||
// Bytes
|
||||
Value []byte
|
||||
}
|
||||
|
||||
// TestBytesTypeID is TL type id of TestBytes.
|
||||
const TestBytesTypeID = 0xa422c4de
|
||||
|
||||
// Ensuring interfaces in compile-time for TestBytes.
|
||||
var (
|
||||
_ bin.Encoder = &TestBytes{}
|
||||
_ bin.Decoder = &TestBytes{}
|
||||
_ bin.BareEncoder = &TestBytes{}
|
||||
_ bin.BareDecoder = &TestBytes{}
|
||||
)
|
||||
|
||||
func (t *TestBytes) Zero() bool {
|
||||
if t == nil {
|
||||
return true
|
||||
}
|
||||
if !(t.Value == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (t *TestBytes) String() string {
|
||||
if t == nil {
|
||||
return "TestBytes(nil)"
|
||||
}
|
||||
type Alias TestBytes
|
||||
return fmt.Sprintf("TestBytes%+v", Alias(*t))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*TestBytes) TypeID() uint32 {
|
||||
return TestBytesTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*TestBytes) TypeName() string {
|
||||
return "testBytes"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (t *TestBytes) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "testBytes",
|
||||
ID: TestBytesTypeID,
|
||||
}
|
||||
if t == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Value",
|
||||
SchemaName: "value",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (t *TestBytes) Encode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode testBytes#a422c4de as nil")
|
||||
}
|
||||
b.PutID(TestBytesTypeID)
|
||||
return t.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (t *TestBytes) EncodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode testBytes#a422c4de as nil")
|
||||
}
|
||||
b.PutBytes(t.Value)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (t *TestBytes) Decode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode testBytes#a422c4de to nil")
|
||||
}
|
||||
if err := b.ConsumeID(TestBytesTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode testBytes#a422c4de: %w", err)
|
||||
}
|
||||
return t.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (t *TestBytes) DecodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode testBytes#a422c4de to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.Bytes()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode testBytes#a422c4de: field value: %w", err)
|
||||
}
|
||||
t.Value = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetValue returns value of Value field.
|
||||
func (t *TestBytes) GetValue() (value []byte) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.Value
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// TestInt represents TL type `testInt#ddbd2c09`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/testInt for reference.
|
||||
type TestInt struct {
|
||||
// Number
|
||||
Value int32
|
||||
}
|
||||
|
||||
// TestIntTypeID is TL type id of TestInt.
|
||||
const TestIntTypeID = 0xddbd2c09
|
||||
|
||||
// Ensuring interfaces in compile-time for TestInt.
|
||||
var (
|
||||
_ bin.Encoder = &TestInt{}
|
||||
_ bin.Decoder = &TestInt{}
|
||||
_ bin.BareEncoder = &TestInt{}
|
||||
_ bin.BareDecoder = &TestInt{}
|
||||
)
|
||||
|
||||
func (t *TestInt) Zero() bool {
|
||||
if t == nil {
|
||||
return true
|
||||
}
|
||||
if !(t.Value == 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (t *TestInt) String() string {
|
||||
if t == nil {
|
||||
return "TestInt(nil)"
|
||||
}
|
||||
type Alias TestInt
|
||||
return fmt.Sprintf("TestInt%+v", Alias(*t))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*TestInt) TypeID() uint32 {
|
||||
return TestIntTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*TestInt) TypeName() string {
|
||||
return "testInt"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (t *TestInt) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "testInt",
|
||||
ID: TestIntTypeID,
|
||||
}
|
||||
if t == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Value",
|
||||
SchemaName: "value",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (t *TestInt) Encode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode testInt#ddbd2c09 as nil")
|
||||
}
|
||||
b.PutID(TestIntTypeID)
|
||||
return t.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (t *TestInt) EncodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode testInt#ddbd2c09 as nil")
|
||||
}
|
||||
b.PutInt32(t.Value)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (t *TestInt) Decode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode testInt#ddbd2c09 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(TestIntTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode testInt#ddbd2c09: %w", err)
|
||||
}
|
||||
return t.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (t *TestInt) DecodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode testInt#ddbd2c09 to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.Int32()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode testInt#ddbd2c09: field value: %w", err)
|
||||
}
|
||||
t.Value = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetValue returns value of Value field.
|
||||
func (t *TestInt) GetValue() (value int32) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.Value
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// TestString represents TL type `testString#fe56688c`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/testString for reference.
|
||||
type TestString struct {
|
||||
// String
|
||||
Value string
|
||||
}
|
||||
|
||||
// TestStringTypeID is TL type id of TestString.
|
||||
const TestStringTypeID = 0xfe56688c
|
||||
|
||||
// Ensuring interfaces in compile-time for TestString.
|
||||
var (
|
||||
_ bin.Encoder = &TestString{}
|
||||
_ bin.Decoder = &TestString{}
|
||||
_ bin.BareEncoder = &TestString{}
|
||||
_ bin.BareDecoder = &TestString{}
|
||||
)
|
||||
|
||||
func (t *TestString) Zero() bool {
|
||||
if t == nil {
|
||||
return true
|
||||
}
|
||||
if !(t.Value == "") {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (t *TestString) String() string {
|
||||
if t == nil {
|
||||
return "TestString(nil)"
|
||||
}
|
||||
type Alias TestString
|
||||
return fmt.Sprintf("TestString%+v", Alias(*t))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*TestString) TypeID() uint32 {
|
||||
return TestStringTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*TestString) TypeName() string {
|
||||
return "testString"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (t *TestString) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "testString",
|
||||
ID: TestStringTypeID,
|
||||
}
|
||||
if t == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Value",
|
||||
SchemaName: "value",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (t *TestString) Encode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode testString#fe56688c as nil")
|
||||
}
|
||||
b.PutID(TestStringTypeID)
|
||||
return t.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (t *TestString) EncodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode testString#fe56688c as nil")
|
||||
}
|
||||
b.PutString(t.Value)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (t *TestString) Decode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode testString#fe56688c to nil")
|
||||
}
|
||||
if err := b.ConsumeID(TestStringTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode testString#fe56688c: %w", err)
|
||||
}
|
||||
return t.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (t *TestString) DecodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode testString#fe56688c to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode testString#fe56688c: field value: %w", err)
|
||||
}
|
||||
t.Value = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetValue returns value of Value field.
|
||||
func (t *TestString) GetValue() (value string) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.Value
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// TestVectorBytes represents TL type `testVectorBytes#a590fb25`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/testVectorBytes for reference.
|
||||
type TestVectorBytes struct {
|
||||
// Value field of TestVectorBytes.
|
||||
Value [][]byte
|
||||
}
|
||||
|
||||
// TestVectorBytesTypeID is TL type id of TestVectorBytes.
|
||||
const TestVectorBytesTypeID = 0xa590fb25
|
||||
|
||||
// Ensuring interfaces in compile-time for TestVectorBytes.
|
||||
var (
|
||||
_ bin.Encoder = &TestVectorBytes{}
|
||||
_ bin.Decoder = &TestVectorBytes{}
|
||||
_ bin.BareEncoder = &TestVectorBytes{}
|
||||
_ bin.BareDecoder = &TestVectorBytes{}
|
||||
)
|
||||
|
||||
func (t *TestVectorBytes) Zero() bool {
|
||||
if t == nil {
|
||||
return true
|
||||
}
|
||||
if !(t.Value == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (t *TestVectorBytes) String() string {
|
||||
if t == nil {
|
||||
return "TestVectorBytes(nil)"
|
||||
}
|
||||
type Alias TestVectorBytes
|
||||
return fmt.Sprintf("TestVectorBytes%+v", Alias(*t))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*TestVectorBytes) TypeID() uint32 {
|
||||
return TestVectorBytesTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*TestVectorBytes) TypeName() string {
|
||||
return "testVectorBytes"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (t *TestVectorBytes) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "testVectorBytes",
|
||||
ID: TestVectorBytesTypeID,
|
||||
}
|
||||
if t == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Value",
|
||||
SchemaName: "value",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (t *TestVectorBytes) Encode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode testVectorBytes#a590fb25 as nil")
|
||||
}
|
||||
b.PutID(TestVectorBytesTypeID)
|
||||
return t.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (t *TestVectorBytes) EncodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode testVectorBytes#a590fb25 as nil")
|
||||
}
|
||||
b.PutInt(len(t.Value))
|
||||
for _, v := range t.Value {
|
||||
b.PutBytes(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (t *TestVectorBytes) Decode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode testVectorBytes#a590fb25 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(TestVectorBytesTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode testVectorBytes#a590fb25: %w", err)
|
||||
}
|
||||
return t.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (t *TestVectorBytes) DecodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode testVectorBytes#a590fb25 to nil")
|
||||
}
|
||||
{
|
||||
headerLen, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode testVectorBytes#a590fb25: field value: %w", err)
|
||||
}
|
||||
|
||||
if headerLen > 0 {
|
||||
t.Value = make([][]byte, 0, headerLen%bin.PreallocateLimit)
|
||||
}
|
||||
for idx := 0; idx < headerLen; idx++ {
|
||||
value, err := b.Bytes()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode testVectorBytes#a590fb25: field value: %w", err)
|
||||
}
|
||||
t.Value = append(t.Value, value)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetValue returns value of Value field.
|
||||
func (t *TestVectorBytes) GetValue() (value [][]byte) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.Value
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// TestVectorInt represents TL type `testVectorInt#df9eb113`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/testVectorInt for reference.
|
||||
type TestVectorInt struct {
|
||||
// Vector of numbers
|
||||
Value []int32
|
||||
}
|
||||
|
||||
// TestVectorIntTypeID is TL type id of TestVectorInt.
|
||||
const TestVectorIntTypeID = 0xdf9eb113
|
||||
|
||||
// Ensuring interfaces in compile-time for TestVectorInt.
|
||||
var (
|
||||
_ bin.Encoder = &TestVectorInt{}
|
||||
_ bin.Decoder = &TestVectorInt{}
|
||||
_ bin.BareEncoder = &TestVectorInt{}
|
||||
_ bin.BareDecoder = &TestVectorInt{}
|
||||
)
|
||||
|
||||
func (t *TestVectorInt) Zero() bool {
|
||||
if t == nil {
|
||||
return true
|
||||
}
|
||||
if !(t.Value == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (t *TestVectorInt) String() string {
|
||||
if t == nil {
|
||||
return "TestVectorInt(nil)"
|
||||
}
|
||||
type Alias TestVectorInt
|
||||
return fmt.Sprintf("TestVectorInt%+v", Alias(*t))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*TestVectorInt) TypeID() uint32 {
|
||||
return TestVectorIntTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*TestVectorInt) TypeName() string {
|
||||
return "testVectorInt"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (t *TestVectorInt) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "testVectorInt",
|
||||
ID: TestVectorIntTypeID,
|
||||
}
|
||||
if t == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Value",
|
||||
SchemaName: "value",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (t *TestVectorInt) Encode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode testVectorInt#df9eb113 as nil")
|
||||
}
|
||||
b.PutID(TestVectorIntTypeID)
|
||||
return t.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (t *TestVectorInt) EncodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode testVectorInt#df9eb113 as nil")
|
||||
}
|
||||
b.PutInt(len(t.Value))
|
||||
for _, v := range t.Value {
|
||||
b.PutInt32(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (t *TestVectorInt) Decode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode testVectorInt#df9eb113 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(TestVectorIntTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode testVectorInt#df9eb113: %w", err)
|
||||
}
|
||||
return t.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (t *TestVectorInt) DecodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode testVectorInt#df9eb113 to nil")
|
||||
}
|
||||
{
|
||||
headerLen, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode testVectorInt#df9eb113: field value: %w", err)
|
||||
}
|
||||
|
||||
if headerLen > 0 {
|
||||
t.Value = make([]int32, 0, headerLen%bin.PreallocateLimit)
|
||||
}
|
||||
for idx := 0; idx < headerLen; idx++ {
|
||||
value, err := b.Int32()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode testVectorInt#df9eb113: field value: %w", err)
|
||||
}
|
||||
t.Value = append(t.Value, value)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetValue returns value of Value field.
|
||||
func (t *TestVectorInt) GetValue() (value []int32) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.Value
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// TestVectorIntObject represents TL type `testVectorIntObject#f152999b`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/testVectorIntObject for reference.
|
||||
type TestVectorIntObject struct {
|
||||
// Vector of objects
|
||||
Value []TestInt
|
||||
}
|
||||
|
||||
// TestVectorIntObjectTypeID is TL type id of TestVectorIntObject.
|
||||
const TestVectorIntObjectTypeID = 0xf152999b
|
||||
|
||||
// Ensuring interfaces in compile-time for TestVectorIntObject.
|
||||
var (
|
||||
_ bin.Encoder = &TestVectorIntObject{}
|
||||
_ bin.Decoder = &TestVectorIntObject{}
|
||||
_ bin.BareEncoder = &TestVectorIntObject{}
|
||||
_ bin.BareDecoder = &TestVectorIntObject{}
|
||||
)
|
||||
|
||||
func (t *TestVectorIntObject) Zero() bool {
|
||||
if t == nil {
|
||||
return true
|
||||
}
|
||||
if !(t.Value == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (t *TestVectorIntObject) String() string {
|
||||
if t == nil {
|
||||
return "TestVectorIntObject(nil)"
|
||||
}
|
||||
type Alias TestVectorIntObject
|
||||
return fmt.Sprintf("TestVectorIntObject%+v", Alias(*t))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*TestVectorIntObject) TypeID() uint32 {
|
||||
return TestVectorIntObjectTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*TestVectorIntObject) TypeName() string {
|
||||
return "testVectorIntObject"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (t *TestVectorIntObject) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "testVectorIntObject",
|
||||
ID: TestVectorIntObjectTypeID,
|
||||
}
|
||||
if t == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Value",
|
||||
SchemaName: "value",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (t *TestVectorIntObject) Encode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode testVectorIntObject#f152999b as nil")
|
||||
}
|
||||
b.PutID(TestVectorIntObjectTypeID)
|
||||
return t.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (t *TestVectorIntObject) EncodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode testVectorIntObject#f152999b as nil")
|
||||
}
|
||||
b.PutInt(len(t.Value))
|
||||
for idx, v := range t.Value {
|
||||
if err := v.EncodeBare(b); err != nil {
|
||||
return fmt.Errorf("unable to encode bare testVectorIntObject#f152999b: field value element with index %d: %w", idx, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (t *TestVectorIntObject) Decode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode testVectorIntObject#f152999b to nil")
|
||||
}
|
||||
if err := b.ConsumeID(TestVectorIntObjectTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode testVectorIntObject#f152999b: %w", err)
|
||||
}
|
||||
return t.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (t *TestVectorIntObject) DecodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode testVectorIntObject#f152999b to nil")
|
||||
}
|
||||
{
|
||||
headerLen, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode testVectorIntObject#f152999b: field value: %w", err)
|
||||
}
|
||||
|
||||
if headerLen > 0 {
|
||||
t.Value = make([]TestInt, 0, headerLen%bin.PreallocateLimit)
|
||||
}
|
||||
for idx := 0; idx < headerLen; idx++ {
|
||||
var value TestInt
|
||||
if err := value.DecodeBare(b); err != nil {
|
||||
return fmt.Errorf("unable to decode bare testVectorIntObject#f152999b: field value: %w", err)
|
||||
}
|
||||
t.Value = append(t.Value, value)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetValue returns value of Value field.
|
||||
func (t *TestVectorIntObject) GetValue() (value []TestInt) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.Value
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// TestVectorString represents TL type `testVectorString#5d6f85bc`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/testVectorString for reference.
|
||||
type TestVectorString struct {
|
||||
// Vector of strings
|
||||
Value []string
|
||||
}
|
||||
|
||||
// TestVectorStringTypeID is TL type id of TestVectorString.
|
||||
const TestVectorStringTypeID = 0x5d6f85bc
|
||||
|
||||
// Ensuring interfaces in compile-time for TestVectorString.
|
||||
var (
|
||||
_ bin.Encoder = &TestVectorString{}
|
||||
_ bin.Decoder = &TestVectorString{}
|
||||
_ bin.BareEncoder = &TestVectorString{}
|
||||
_ bin.BareDecoder = &TestVectorString{}
|
||||
)
|
||||
|
||||
func (t *TestVectorString) Zero() bool {
|
||||
if t == nil {
|
||||
return true
|
||||
}
|
||||
if !(t.Value == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (t *TestVectorString) String() string {
|
||||
if t == nil {
|
||||
return "TestVectorString(nil)"
|
||||
}
|
||||
type Alias TestVectorString
|
||||
return fmt.Sprintf("TestVectorString%+v", Alias(*t))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*TestVectorString) TypeID() uint32 {
|
||||
return TestVectorStringTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*TestVectorString) TypeName() string {
|
||||
return "testVectorString"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (t *TestVectorString) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "testVectorString",
|
||||
ID: TestVectorStringTypeID,
|
||||
}
|
||||
if t == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Value",
|
||||
SchemaName: "value",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (t *TestVectorString) Encode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode testVectorString#5d6f85bc as nil")
|
||||
}
|
||||
b.PutID(TestVectorStringTypeID)
|
||||
return t.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (t *TestVectorString) EncodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode testVectorString#5d6f85bc as nil")
|
||||
}
|
||||
b.PutInt(len(t.Value))
|
||||
for _, v := range t.Value {
|
||||
b.PutString(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (t *TestVectorString) Decode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode testVectorString#5d6f85bc to nil")
|
||||
}
|
||||
if err := b.ConsumeID(TestVectorStringTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode testVectorString#5d6f85bc: %w", err)
|
||||
}
|
||||
return t.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (t *TestVectorString) DecodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode testVectorString#5d6f85bc to nil")
|
||||
}
|
||||
{
|
||||
headerLen, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode testVectorString#5d6f85bc: field value: %w", err)
|
||||
}
|
||||
|
||||
if headerLen > 0 {
|
||||
t.Value = 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 testVectorString#5d6f85bc: field value: %w", err)
|
||||
}
|
||||
t.Value = append(t.Value, value)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetValue returns value of Value field.
|
||||
func (t *TestVectorString) GetValue() (value []string) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.Value
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// TestVectorStringObject represents TL type `testVectorStringObject#e5ecc0d`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/testVectorStringObject for reference.
|
||||
type TestVectorStringObject struct {
|
||||
// Vector of objects
|
||||
Value []TestString
|
||||
}
|
||||
|
||||
// TestVectorStringObjectTypeID is TL type id of TestVectorStringObject.
|
||||
const TestVectorStringObjectTypeID = 0xe5ecc0d
|
||||
|
||||
// Ensuring interfaces in compile-time for TestVectorStringObject.
|
||||
var (
|
||||
_ bin.Encoder = &TestVectorStringObject{}
|
||||
_ bin.Decoder = &TestVectorStringObject{}
|
||||
_ bin.BareEncoder = &TestVectorStringObject{}
|
||||
_ bin.BareDecoder = &TestVectorStringObject{}
|
||||
)
|
||||
|
||||
func (t *TestVectorStringObject) Zero() bool {
|
||||
if t == nil {
|
||||
return true
|
||||
}
|
||||
if !(t.Value == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (t *TestVectorStringObject) String() string {
|
||||
if t == nil {
|
||||
return "TestVectorStringObject(nil)"
|
||||
}
|
||||
type Alias TestVectorStringObject
|
||||
return fmt.Sprintf("TestVectorStringObject%+v", Alias(*t))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*TestVectorStringObject) TypeID() uint32 {
|
||||
return TestVectorStringObjectTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*TestVectorStringObject) TypeName() string {
|
||||
return "testVectorStringObject"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (t *TestVectorStringObject) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "testVectorStringObject",
|
||||
ID: TestVectorStringObjectTypeID,
|
||||
}
|
||||
if t == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Value",
|
||||
SchemaName: "value",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (t *TestVectorStringObject) Encode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode testVectorStringObject#e5ecc0d as nil")
|
||||
}
|
||||
b.PutID(TestVectorStringObjectTypeID)
|
||||
return t.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (t *TestVectorStringObject) EncodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode testVectorStringObject#e5ecc0d as nil")
|
||||
}
|
||||
b.PutInt(len(t.Value))
|
||||
for idx, v := range t.Value {
|
||||
if err := v.EncodeBare(b); err != nil {
|
||||
return fmt.Errorf("unable to encode bare testVectorStringObject#e5ecc0d: field value element with index %d: %w", idx, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (t *TestVectorStringObject) Decode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode testVectorStringObject#e5ecc0d to nil")
|
||||
}
|
||||
if err := b.ConsumeID(TestVectorStringObjectTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode testVectorStringObject#e5ecc0d: %w", err)
|
||||
}
|
||||
return t.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (t *TestVectorStringObject) DecodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode testVectorStringObject#e5ecc0d to nil")
|
||||
}
|
||||
{
|
||||
headerLen, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode testVectorStringObject#e5ecc0d: field value: %w", err)
|
||||
}
|
||||
|
||||
if headerLen > 0 {
|
||||
t.Value = make([]TestString, 0, headerLen%bin.PreallocateLimit)
|
||||
}
|
||||
for idx := 0; idx < headerLen; idx++ {
|
||||
var value TestString
|
||||
if err := value.DecodeBare(b); err != nil {
|
||||
return fmt.Errorf("unable to decode bare testVectorStringObject#e5ecc0d: field value: %w", err)
|
||||
}
|
||||
t.Value = append(t.Value, value)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetValue returns value of Value field.
|
||||
func (t *TestVectorStringObject) GetValue() (value []TestString) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.Value
|
||||
}
|
||||
@@ -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{}
|
||||
)
|
||||
|
||||
// TestVectorVector represents TL type `testVectorVector#69e8846c`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/testVectorVector for reference.
|
||||
type TestVectorVector struct {
|
||||
// Value field of TestVectorVector.
|
||||
Value [][]string
|
||||
}
|
||||
|
||||
// TestVectorVectorTypeID is TL type id of TestVectorVector.
|
||||
const TestVectorVectorTypeID = 0x69e8846c
|
||||
|
||||
// Ensuring interfaces in compile-time for TestVectorVector.
|
||||
var (
|
||||
_ bin.Encoder = &TestVectorVector{}
|
||||
_ bin.Decoder = &TestVectorVector{}
|
||||
_ bin.BareEncoder = &TestVectorVector{}
|
||||
_ bin.BareDecoder = &TestVectorVector{}
|
||||
)
|
||||
|
||||
func (t *TestVectorVector) Zero() bool {
|
||||
if t == nil {
|
||||
return true
|
||||
}
|
||||
if !(t.Value == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (t *TestVectorVector) String() string {
|
||||
if t == nil {
|
||||
return "TestVectorVector(nil)"
|
||||
}
|
||||
type Alias TestVectorVector
|
||||
return fmt.Sprintf("TestVectorVector%+v", Alias(*t))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*TestVectorVector) TypeID() uint32 {
|
||||
return TestVectorVectorTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*TestVectorVector) TypeName() string {
|
||||
return "testVectorVector"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (t *TestVectorVector) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "testVectorVector",
|
||||
ID: TestVectorVectorTypeID,
|
||||
}
|
||||
if t == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Value",
|
||||
SchemaName: "value",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (t *TestVectorVector) Encode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode testVectorVector#69e8846c as nil")
|
||||
}
|
||||
b.PutID(TestVectorVectorTypeID)
|
||||
return t.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (t *TestVectorVector) EncodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode testVectorVector#69e8846c as nil")
|
||||
}
|
||||
b.PutInt(len(t.Value))
|
||||
for _, row := range t.Value {
|
||||
b.PutVectorHeader(len(row))
|
||||
for _, v := range row {
|
||||
b.PutString(v)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (t *TestVectorVector) Decode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode testVectorVector#69e8846c to nil")
|
||||
}
|
||||
if err := b.ConsumeID(TestVectorVectorTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode testVectorVector#69e8846c: %w", err)
|
||||
}
|
||||
return t.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (t *TestVectorVector) DecodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode testVectorVector#69e8846c to nil")
|
||||
}
|
||||
{
|
||||
headerLen, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode testVectorVector#69e8846c: field value: %w", err)
|
||||
}
|
||||
|
||||
if headerLen > 0 {
|
||||
t.Value = make([][]string, 0, headerLen%bin.PreallocateLimit)
|
||||
}
|
||||
for idx := 0; idx < headerLen; idx++ {
|
||||
innerLen, err := b.VectorHeader()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode testVectorVector#69e8846c: field value: %w", err)
|
||||
}
|
||||
|
||||
var row []string
|
||||
if innerLen > 0 {
|
||||
row = make([]string, 0, innerLen%bin.PreallocateLimit)
|
||||
}
|
||||
for innerIndex := 0; innerIndex < innerLen; innerLen++ {
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode testVectorVector#69e8846c: field value: %w", err)
|
||||
}
|
||||
row = append(row, value)
|
||||
}
|
||||
t.Value = append(t.Value, row)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetValue returns value of Value field.
|
||||
func (t *TestVectorVector) GetValue() (value [][]string) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.Value
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// TextEntities represents TL type `textEntities#cf89c258`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/textEntities for reference.
|
||||
type TextEntities struct {
|
||||
// List of text entities
|
||||
Entities []TextEntity
|
||||
}
|
||||
|
||||
// TextEntitiesTypeID is TL type id of TextEntities.
|
||||
const TextEntitiesTypeID = 0xcf89c258
|
||||
|
||||
// Ensuring interfaces in compile-time for TextEntities.
|
||||
var (
|
||||
_ bin.Encoder = &TextEntities{}
|
||||
_ bin.Decoder = &TextEntities{}
|
||||
_ bin.BareEncoder = &TextEntities{}
|
||||
_ bin.BareDecoder = &TextEntities{}
|
||||
)
|
||||
|
||||
func (t *TextEntities) Zero() bool {
|
||||
if t == nil {
|
||||
return true
|
||||
}
|
||||
if !(t.Entities == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (t *TextEntities) String() string {
|
||||
if t == nil {
|
||||
return "TextEntities(nil)"
|
||||
}
|
||||
type Alias TextEntities
|
||||
return fmt.Sprintf("TextEntities%+v", Alias(*t))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*TextEntities) TypeID() uint32 {
|
||||
return TextEntitiesTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*TextEntities) TypeName() string {
|
||||
return "textEntities"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (t *TextEntities) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "textEntities",
|
||||
ID: TextEntitiesTypeID,
|
||||
}
|
||||
if t == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Entities",
|
||||
SchemaName: "entities",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (t *TextEntities) Encode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode textEntities#cf89c258 as nil")
|
||||
}
|
||||
b.PutID(TextEntitiesTypeID)
|
||||
return t.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (t *TextEntities) EncodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode textEntities#cf89c258 as nil")
|
||||
}
|
||||
b.PutInt(len(t.Entities))
|
||||
for idx, v := range t.Entities {
|
||||
if err := v.EncodeBare(b); err != nil {
|
||||
return fmt.Errorf("unable to encode bare textEntities#cf89c258: field entities element with index %d: %w", idx, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (t *TextEntities) Decode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode textEntities#cf89c258 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(TextEntitiesTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode textEntities#cf89c258: %w", err)
|
||||
}
|
||||
return t.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (t *TextEntities) DecodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode textEntities#cf89c258 to nil")
|
||||
}
|
||||
{
|
||||
headerLen, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode textEntities#cf89c258: field entities: %w", err)
|
||||
}
|
||||
|
||||
if headerLen > 0 {
|
||||
t.Entities = make([]TextEntity, 0, headerLen%bin.PreallocateLimit)
|
||||
}
|
||||
for idx := 0; idx < headerLen; idx++ {
|
||||
var value TextEntity
|
||||
if err := value.DecodeBare(b); err != nil {
|
||||
return fmt.Errorf("unable to decode bare textEntities#cf89c258: field entities: %w", err)
|
||||
}
|
||||
t.Entities = append(t.Entities, value)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetEntities returns value of Entities field.
|
||||
func (t *TextEntities) GetEntities() (value []TextEntity) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.Entities
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// TextEntity represents TL type `textEntity#8bab99a8`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/textEntity for reference.
|
||||
type TextEntity struct {
|
||||
// Offset of the entity, in UTF-16 code units
|
||||
Offset int32
|
||||
// Length of the entity, in UTF-16 code units
|
||||
Length int32
|
||||
// Type of the entity
|
||||
Type TextEntityTypeClass
|
||||
}
|
||||
|
||||
// TextEntityTypeID is TL type id of TextEntity.
|
||||
const TextEntityTypeID = 0x8bab99a8
|
||||
|
||||
// Ensuring interfaces in compile-time for TextEntity.
|
||||
var (
|
||||
_ bin.Encoder = &TextEntity{}
|
||||
_ bin.Decoder = &TextEntity{}
|
||||
_ bin.BareEncoder = &TextEntity{}
|
||||
_ bin.BareDecoder = &TextEntity{}
|
||||
)
|
||||
|
||||
func (t *TextEntity) Zero() bool {
|
||||
if t == nil {
|
||||
return true
|
||||
}
|
||||
if !(t.Offset == 0) {
|
||||
return false
|
||||
}
|
||||
if !(t.Length == 0) {
|
||||
return false
|
||||
}
|
||||
if !(t.Type == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (t *TextEntity) String() string {
|
||||
if t == nil {
|
||||
return "TextEntity(nil)"
|
||||
}
|
||||
type Alias TextEntity
|
||||
return fmt.Sprintf("TextEntity%+v", Alias(*t))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*TextEntity) TypeID() uint32 {
|
||||
return TextEntityTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*TextEntity) TypeName() string {
|
||||
return "textEntity"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (t *TextEntity) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "textEntity",
|
||||
ID: TextEntityTypeID,
|
||||
}
|
||||
if t == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Offset",
|
||||
SchemaName: "offset",
|
||||
},
|
||||
{
|
||||
Name: "Length",
|
||||
SchemaName: "length",
|
||||
},
|
||||
{
|
||||
Name: "Type",
|
||||
SchemaName: "type",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (t *TextEntity) Encode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode textEntity#8bab99a8 as nil")
|
||||
}
|
||||
b.PutID(TextEntityTypeID)
|
||||
return t.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (t *TextEntity) EncodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode textEntity#8bab99a8 as nil")
|
||||
}
|
||||
b.PutInt32(t.Offset)
|
||||
b.PutInt32(t.Length)
|
||||
if t.Type == nil {
|
||||
return fmt.Errorf("unable to encode textEntity#8bab99a8: field type is nil")
|
||||
}
|
||||
if err := t.Type.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode textEntity#8bab99a8: field type: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (t *TextEntity) Decode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode textEntity#8bab99a8 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(TextEntityTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode textEntity#8bab99a8: %w", err)
|
||||
}
|
||||
return t.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (t *TextEntity) DecodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode textEntity#8bab99a8 to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.Int32()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode textEntity#8bab99a8: field offset: %w", err)
|
||||
}
|
||||
t.Offset = value
|
||||
}
|
||||
{
|
||||
value, err := b.Int32()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode textEntity#8bab99a8: field length: %w", err)
|
||||
}
|
||||
t.Length = value
|
||||
}
|
||||
{
|
||||
value, err := DecodeTextEntityType(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode textEntity#8bab99a8: field type: %w", err)
|
||||
}
|
||||
t.Type = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetOffset returns value of Offset field.
|
||||
func (t *TextEntity) GetOffset() (value int32) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.Offset
|
||||
}
|
||||
|
||||
// GetLength returns value of Length field.
|
||||
func (t *TextEntity) GetLength() (value int32) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.Length
|
||||
}
|
||||
|
||||
// GetType returns value of Type field.
|
||||
func (t *TextEntity) GetType() (value TextEntityTypeClass) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.Type
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,154 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// Theme represents TL type `theme#28f1114`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/theme for reference.
|
||||
type Theme struct {
|
||||
// Name field of Theme.
|
||||
Name string
|
||||
}
|
||||
|
||||
// ThemeTypeID is TL type id of Theme.
|
||||
const ThemeTypeID = 0x28f1114
|
||||
|
||||
// Ensuring interfaces in compile-time for Theme.
|
||||
var (
|
||||
_ bin.Encoder = &Theme{}
|
||||
_ bin.Decoder = &Theme{}
|
||||
_ bin.BareEncoder = &Theme{}
|
||||
_ bin.BareDecoder = &Theme{}
|
||||
)
|
||||
|
||||
func (t *Theme) Zero() bool {
|
||||
if t == nil {
|
||||
return true
|
||||
}
|
||||
if !(t.Name == "") {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (t *Theme) String() string {
|
||||
if t == nil {
|
||||
return "Theme(nil)"
|
||||
}
|
||||
type Alias Theme
|
||||
return fmt.Sprintf("Theme%+v", Alias(*t))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*Theme) TypeID() uint32 {
|
||||
return ThemeTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*Theme) TypeName() string {
|
||||
return "theme"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (t *Theme) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "theme",
|
||||
ID: ThemeTypeID,
|
||||
}
|
||||
if t == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Name",
|
||||
SchemaName: "name",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (t *Theme) Encode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode theme#28f1114 as nil")
|
||||
}
|
||||
b.PutID(ThemeTypeID)
|
||||
return t.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (t *Theme) EncodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode theme#28f1114 as nil")
|
||||
}
|
||||
b.PutString(t.Name)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (t *Theme) Decode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode theme#28f1114 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(ThemeTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode theme#28f1114: %w", err)
|
||||
}
|
||||
return t.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (t *Theme) DecodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode theme#28f1114 to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode theme#28f1114: field name: %w", err)
|
||||
}
|
||||
t.Name = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetName returns value of Name field.
|
||||
func (t *Theme) GetName() (value string) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.Name
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// Update represents TL type `update#b03e2ef8`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/update for reference.
|
||||
type Update struct {
|
||||
// Msg field of Update.
|
||||
Msg AbstractMessageClass
|
||||
// Delay field of Update.
|
||||
Delay int32
|
||||
}
|
||||
|
||||
// UpdateTypeID is TL type id of Update.
|
||||
const UpdateTypeID = 0xb03e2ef8
|
||||
|
||||
// Ensuring interfaces in compile-time for Update.
|
||||
var (
|
||||
_ bin.Encoder = &Update{}
|
||||
_ bin.Decoder = &Update{}
|
||||
_ bin.BareEncoder = &Update{}
|
||||
_ bin.BareDecoder = &Update{}
|
||||
)
|
||||
|
||||
func (u *Update) Zero() bool {
|
||||
if u == nil {
|
||||
return true
|
||||
}
|
||||
if !(u.Msg == nil) {
|
||||
return false
|
||||
}
|
||||
if !(u.Delay == 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (u *Update) String() string {
|
||||
if u == nil {
|
||||
return "Update(nil)"
|
||||
}
|
||||
type Alias Update
|
||||
return fmt.Sprintf("Update%+v", Alias(*u))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*Update) TypeID() uint32 {
|
||||
return UpdateTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*Update) TypeName() string {
|
||||
return "update"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (u *Update) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "update",
|
||||
ID: UpdateTypeID,
|
||||
}
|
||||
if u == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Msg",
|
||||
SchemaName: "msg",
|
||||
},
|
||||
{
|
||||
Name: "Delay",
|
||||
SchemaName: "delay",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (u *Update) Encode(b *bin.Buffer) error {
|
||||
if u == nil {
|
||||
return fmt.Errorf("can't encode update#b03e2ef8 as nil")
|
||||
}
|
||||
b.PutID(UpdateTypeID)
|
||||
return u.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (u *Update) EncodeBare(b *bin.Buffer) error {
|
||||
if u == nil {
|
||||
return fmt.Errorf("can't encode update#b03e2ef8 as nil")
|
||||
}
|
||||
if u.Msg == nil {
|
||||
return fmt.Errorf("unable to encode update#b03e2ef8: field msg is nil")
|
||||
}
|
||||
if err := u.Msg.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode update#b03e2ef8: field msg: %w", err)
|
||||
}
|
||||
b.PutInt32(u.Delay)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (u *Update) Decode(b *bin.Buffer) error {
|
||||
if u == nil {
|
||||
return fmt.Errorf("can't decode update#b03e2ef8 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(UpdateTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode update#b03e2ef8: %w", err)
|
||||
}
|
||||
return u.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (u *Update) DecodeBare(b *bin.Buffer) error {
|
||||
if u == nil {
|
||||
return fmt.Errorf("can't decode update#b03e2ef8 to nil")
|
||||
}
|
||||
{
|
||||
value, err := DecodeAbstractMessage(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode update#b03e2ef8: field msg: %w", err)
|
||||
}
|
||||
u.Msg = value
|
||||
}
|
||||
{
|
||||
value, err := b.Int32()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode update#b03e2ef8: field delay: %w", err)
|
||||
}
|
||||
u.Delay = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetMsg returns value of Msg field.
|
||||
func (u *Update) GetMsg() (value AbstractMessageClass) {
|
||||
if u == nil {
|
||||
return
|
||||
}
|
||||
return u.Msg
|
||||
}
|
||||
|
||||
// GetDelay returns value of Delay field.
|
||||
func (u *Update) GetDelay() (value int32) {
|
||||
if u == nil {
|
||||
return
|
||||
}
|
||||
return u.Delay
|
||||
}
|
||||
@@ -0,0 +1,375 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// UserAuth represents TL type `user.auth#f4815592`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/user.auth for reference.
|
||||
type UserAuth struct {
|
||||
// Foo field of UserAuth.
|
||||
Foo string
|
||||
}
|
||||
|
||||
// UserAuthTypeID is TL type id of UserAuth.
|
||||
const UserAuthTypeID = 0xf4815592
|
||||
|
||||
// construct implements constructor of UserAuthClass.
|
||||
func (a UserAuth) construct() UserAuthClass { return &a }
|
||||
|
||||
// Ensuring interfaces in compile-time for UserAuth.
|
||||
var (
|
||||
_ bin.Encoder = &UserAuth{}
|
||||
_ bin.Decoder = &UserAuth{}
|
||||
_ bin.BareEncoder = &UserAuth{}
|
||||
_ bin.BareDecoder = &UserAuth{}
|
||||
|
||||
_ UserAuthClass = &UserAuth{}
|
||||
)
|
||||
|
||||
func (a *UserAuth) Zero() bool {
|
||||
if a == nil {
|
||||
return true
|
||||
}
|
||||
if !(a.Foo == "") {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (a *UserAuth) String() string {
|
||||
if a == nil {
|
||||
return "UserAuth(nil)"
|
||||
}
|
||||
type Alias UserAuth
|
||||
return fmt.Sprintf("UserAuth%+v", Alias(*a))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*UserAuth) TypeID() uint32 {
|
||||
return UserAuthTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*UserAuth) TypeName() string {
|
||||
return "user.auth"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (a *UserAuth) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "user.auth",
|
||||
ID: UserAuthTypeID,
|
||||
}
|
||||
if a == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Foo",
|
||||
SchemaName: "foo",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (a *UserAuth) Encode(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't encode user.auth#f4815592 as nil")
|
||||
}
|
||||
b.PutID(UserAuthTypeID)
|
||||
return a.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (a *UserAuth) EncodeBare(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't encode user.auth#f4815592 as nil")
|
||||
}
|
||||
b.PutString(a.Foo)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (a *UserAuth) Decode(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't decode user.auth#f4815592 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(UserAuthTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode user.auth#f4815592: %w", err)
|
||||
}
|
||||
return a.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (a *UserAuth) DecodeBare(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't decode user.auth#f4815592 to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode user.auth#f4815592: field foo: %w", err)
|
||||
}
|
||||
a.Foo = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetFoo returns value of Foo field.
|
||||
func (a *UserAuth) GetFoo() (value string) {
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
return a.Foo
|
||||
}
|
||||
|
||||
// UserAuthPassword represents TL type `user.authPassword#5981e317`.
|
||||
//
|
||||
// See https://localhost:80/doc/constructor/user.authPassword for reference.
|
||||
type UserAuthPassword struct {
|
||||
// Pwd field of UserAuthPassword.
|
||||
Pwd string
|
||||
}
|
||||
|
||||
// UserAuthPasswordTypeID is TL type id of UserAuthPassword.
|
||||
const UserAuthPasswordTypeID = 0x5981e317
|
||||
|
||||
// construct implements constructor of UserAuthClass.
|
||||
func (a UserAuthPassword) construct() UserAuthClass { return &a }
|
||||
|
||||
// Ensuring interfaces in compile-time for UserAuthPassword.
|
||||
var (
|
||||
_ bin.Encoder = &UserAuthPassword{}
|
||||
_ bin.Decoder = &UserAuthPassword{}
|
||||
_ bin.BareEncoder = &UserAuthPassword{}
|
||||
_ bin.BareDecoder = &UserAuthPassword{}
|
||||
|
||||
_ UserAuthClass = &UserAuthPassword{}
|
||||
)
|
||||
|
||||
func (a *UserAuthPassword) Zero() bool {
|
||||
if a == nil {
|
||||
return true
|
||||
}
|
||||
if !(a.Pwd == "") {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (a *UserAuthPassword) String() string {
|
||||
if a == nil {
|
||||
return "UserAuthPassword(nil)"
|
||||
}
|
||||
type Alias UserAuthPassword
|
||||
return fmt.Sprintf("UserAuthPassword%+v", Alias(*a))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*UserAuthPassword) TypeID() uint32 {
|
||||
return UserAuthPasswordTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*UserAuthPassword) TypeName() string {
|
||||
return "user.authPassword"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (a *UserAuthPassword) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "user.authPassword",
|
||||
ID: UserAuthPasswordTypeID,
|
||||
}
|
||||
if a == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Pwd",
|
||||
SchemaName: "pwd",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (a *UserAuthPassword) Encode(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't encode user.authPassword#5981e317 as nil")
|
||||
}
|
||||
b.PutID(UserAuthPasswordTypeID)
|
||||
return a.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (a *UserAuthPassword) EncodeBare(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't encode user.authPassword#5981e317 as nil")
|
||||
}
|
||||
b.PutString(a.Pwd)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (a *UserAuthPassword) Decode(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't decode user.authPassword#5981e317 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(UserAuthPasswordTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode user.authPassword#5981e317: %w", err)
|
||||
}
|
||||
return a.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (a *UserAuthPassword) DecodeBare(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't decode user.authPassword#5981e317 to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode user.authPassword#5981e317: field pwd: %w", err)
|
||||
}
|
||||
a.Pwd = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetPwd returns value of Pwd field.
|
||||
func (a *UserAuthPassword) GetPwd() (value string) {
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
return a.Pwd
|
||||
}
|
||||
|
||||
// UserAuthClassName is schema name of UserAuthClass.
|
||||
const UserAuthClassName = "user.Auth"
|
||||
|
||||
// UserAuthClass represents user.Auth generic type.
|
||||
//
|
||||
// See https://localhost:80/doc/type/user.Auth for reference.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// g, err := td.DecodeUserAuth(buf)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// switch v := g.(type) {
|
||||
// case *td.UserAuth: // user.auth#f4815592
|
||||
// case *td.UserAuthPassword: // user.authPassword#5981e317
|
||||
// default: panic(v)
|
||||
// }
|
||||
type UserAuthClass interface {
|
||||
bin.Encoder
|
||||
bin.Decoder
|
||||
bin.BareEncoder
|
||||
bin.BareDecoder
|
||||
construct() UserAuthClass
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
TypeID() uint32
|
||||
// TypeName returns name of type in TL schema.
|
||||
TypeName() string
|
||||
// String implements fmt.Stringer.
|
||||
String() string
|
||||
// Zero returns true if current object has a zero value.
|
||||
Zero() bool
|
||||
}
|
||||
|
||||
// DecodeUserAuth implements binary de-serialization for UserAuthClass.
|
||||
func DecodeUserAuth(buf *bin.Buffer) (UserAuthClass, error) {
|
||||
id, err := buf.PeekID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch id {
|
||||
case UserAuthTypeID:
|
||||
// Decoding user.auth#f4815592.
|
||||
v := UserAuth{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode UserAuthClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
case UserAuthPasswordTypeID:
|
||||
// Decoding user.authPassword#5981e317.
|
||||
v := UserAuthPassword{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode UserAuthClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unable to decode UserAuthClass: %w", bin.NewUnexpectedID(id))
|
||||
}
|
||||
}
|
||||
|
||||
// UserAuth boxes the UserAuthClass providing a helper.
|
||||
type UserAuthBox struct {
|
||||
Auth UserAuthClass
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder for UserAuthBox.
|
||||
func (b *UserAuthBox) Decode(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("unable to decode UserAuthBox to nil")
|
||||
}
|
||||
v, err := DecodeUserAuth(buf)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode boxed value: %w", err)
|
||||
}
|
||||
b.Auth = v
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode implements bin.Encode for UserAuthBox.
|
||||
func (b *UserAuthBox) Encode(buf *bin.Buffer) error {
|
||||
if b == nil || b.Auth == nil {
|
||||
return fmt.Errorf("unable to encode UserAuthClass as nil")
|
||||
}
|
||||
return b.Auth.Encode(buf)
|
||||
}
|
||||
Reference in New Issue
Block a user