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,2 @@
|
||||
dcOption#18b7a10d flags:# ipv6:flags.0?true media_only:flags.1?true tcpo_only:flags.2?true cdn:flags.3?true static:flags.4?true id:int ip_address:string port:int secret:flags.10?bytes = DcOption;
|
||||
config#330b4067 flags:# phonecalls_enabled:flags.1?true default_p2p_contacts:flags.3?true preload_featured_stickers:flags.4?true ignore_phone_entities:flags.5?true revoke_pm_inbox:flags.6?true blocked_mode:flags.8?true pfs_enabled:flags.13?true date:int expires:int test_mode:Bool this_dc:int dc_options:Vector<DcOption> dc_txt_domain_name:string chat_size_max:int megagroup_size_max:int forwarded_count_max:int online_update_period_ms:int offline_blur_timeout_ms:int offline_idle_timeout_ms:int online_cloud_timeout_ms:int notify_cloud_delay_ms:int notify_default_delay_ms:int push_chat_period_ms:int push_chat_limit:int saved_gifs_limit:int edit_time_limit:int revoke_time_limit:int revoke_pm_time_limit:int rating_e_decay:int stickers_recent_limit:int stickers_faved_limit:int channels_read_media_period:int tmp_sessions:flags.0?int pinned_dialogs_count_max:int pinned_infolder_count_max:int call_receive_timeout_ms:int call_ring_timeout_ms:int call_connect_timeout_ms:int call_packet_timeout_ms:int me_url_prefix:string autoupdate_url_prefix:flags.7?string gif_search_username:flags.9?string venue_search_username:flags.10?string img_search_username:flags.11?string static_maps_provider:flags.12?string caption_length_max:int message_length_max:int webfile_dc_id:int suggested_lang_code:flags.2?string lang_pack_version:flags.2?int base_lang_pack_version:flags.2?int = Config;
|
||||
@@ -0,0 +1,4 @@
|
||||
// Package internal wraps internal packages for tdp package.
|
||||
package internal
|
||||
|
||||
//go:generate go run go.mau.fi/mautrix-telegram/pkg/gotd/cmd/gotdgen --format=true --clean --package schema --target schema --schema _testdata/schema.tl
|
||||
@@ -0,0 +1,54 @@
|
||||
// Code generated by gotdgen, DO NOT EDIT.
|
||||
|
||||
package schema
|
||||
|
||||
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,428 @@
|
||||
// Code generated by gotdgen, DO NOT EDIT.
|
||||
|
||||
package schema
|
||||
|
||||
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`.
|
||||
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,61 @@
|
||||
// Code generated by gotdgen, DO NOT EDIT.
|
||||
|
||||
package schema
|
||||
|
||||
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{
|
||||
DCOptionTypeID: "dcOption#18b7a10d",
|
||||
ConfigTypeID: "config#330b4067",
|
||||
}
|
||||
}
|
||||
|
||||
// NamesMap returns mapping from type names to TL type ids.
|
||||
func NamesMap() map[string]uint32 {
|
||||
return map[string]uint32{
|
||||
"dcOption": DCOptionTypeID,
|
||||
"config": ConfigTypeID,
|
||||
}
|
||||
}
|
||||
|
||||
// TypesConstructorMap maps type ids to constructors.
|
||||
func TypesConstructorMap() map[uint32]func() bin.Object {
|
||||
return map[uint32]func() bin.Object{
|
||||
DCOptionTypeID: func() bin.Object { return &DCOption{} },
|
||||
ConfigTypeID: func() bin.Object { return &Config{} },
|
||||
}
|
||||
}
|
||||
|
||||
// ClassConstructorsMap maps class schema name to constructors type ids.
|
||||
func ClassConstructorsMap() map[string][]uint32 {
|
||||
return map[string][]uint32{}
|
||||
}
|
||||
Reference in New Issue
Block a user