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,239 @@
|
||||
// Code generated by gotdgen, DO NOT EDIT.
|
||||
|
||||
package tdapi
|
||||
|
||||
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{}
|
||||
)
|
||||
|
||||
// DeleteAccountRequest represents TL type `deleteAccount#533276c6`.
|
||||
type DeleteAccountRequest struct {
|
||||
// The reason why the account was deleted; optional
|
||||
Reason string
|
||||
// The 2-step verification password of the current user. If the current user isn't
|
||||
// authorized, then an empty string can be passed and account deletion can be canceled
|
||||
// within one week
|
||||
Password string
|
||||
}
|
||||
|
||||
// DeleteAccountRequestTypeID is TL type id of DeleteAccountRequest.
|
||||
const DeleteAccountRequestTypeID = 0x533276c6
|
||||
|
||||
// Ensuring interfaces in compile-time for DeleteAccountRequest.
|
||||
var (
|
||||
_ bin.Encoder = &DeleteAccountRequest{}
|
||||
_ bin.Decoder = &DeleteAccountRequest{}
|
||||
_ bin.BareEncoder = &DeleteAccountRequest{}
|
||||
_ bin.BareDecoder = &DeleteAccountRequest{}
|
||||
)
|
||||
|
||||
func (d *DeleteAccountRequest) Zero() bool {
|
||||
if d == nil {
|
||||
return true
|
||||
}
|
||||
if !(d.Reason == "") {
|
||||
return false
|
||||
}
|
||||
if !(d.Password == "") {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (d *DeleteAccountRequest) String() string {
|
||||
if d == nil {
|
||||
return "DeleteAccountRequest(nil)"
|
||||
}
|
||||
type Alias DeleteAccountRequest
|
||||
return fmt.Sprintf("DeleteAccountRequest%+v", Alias(*d))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*DeleteAccountRequest) TypeID() uint32 {
|
||||
return DeleteAccountRequestTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*DeleteAccountRequest) TypeName() string {
|
||||
return "deleteAccount"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (d *DeleteAccountRequest) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "deleteAccount",
|
||||
ID: DeleteAccountRequestTypeID,
|
||||
}
|
||||
if d == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Reason",
|
||||
SchemaName: "reason",
|
||||
},
|
||||
{
|
||||
Name: "Password",
|
||||
SchemaName: "password",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (d *DeleteAccountRequest) Encode(b *bin.Buffer) error {
|
||||
if d == nil {
|
||||
return fmt.Errorf("can't encode deleteAccount#533276c6 as nil")
|
||||
}
|
||||
b.PutID(DeleteAccountRequestTypeID)
|
||||
return d.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (d *DeleteAccountRequest) EncodeBare(b *bin.Buffer) error {
|
||||
if d == nil {
|
||||
return fmt.Errorf("can't encode deleteAccount#533276c6 as nil")
|
||||
}
|
||||
b.PutString(d.Reason)
|
||||
b.PutString(d.Password)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (d *DeleteAccountRequest) Decode(b *bin.Buffer) error {
|
||||
if d == nil {
|
||||
return fmt.Errorf("can't decode deleteAccount#533276c6 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(DeleteAccountRequestTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode deleteAccount#533276c6: %w", err)
|
||||
}
|
||||
return d.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (d *DeleteAccountRequest) DecodeBare(b *bin.Buffer) error {
|
||||
if d == nil {
|
||||
return fmt.Errorf("can't decode deleteAccount#533276c6 to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode deleteAccount#533276c6: field reason: %w", err)
|
||||
}
|
||||
d.Reason = value
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode deleteAccount#533276c6: field password: %w", err)
|
||||
}
|
||||
d.Password = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
||||
func (d *DeleteAccountRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
|
||||
if d == nil {
|
||||
return fmt.Errorf("can't encode deleteAccount#533276c6 as nil")
|
||||
}
|
||||
b.ObjStart()
|
||||
b.PutID("deleteAccount")
|
||||
b.Comma()
|
||||
b.FieldStart("reason")
|
||||
b.PutString(d.Reason)
|
||||
b.Comma()
|
||||
b.FieldStart("password")
|
||||
b.PutString(d.Password)
|
||||
b.Comma()
|
||||
b.StripComma()
|
||||
b.ObjEnd()
|
||||
return nil
|
||||
}
|
||||
|
||||
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
||||
func (d *DeleteAccountRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
|
||||
if d == nil {
|
||||
return fmt.Errorf("can't decode deleteAccount#533276c6 to nil")
|
||||
}
|
||||
|
||||
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
||||
switch string(key) {
|
||||
case tdjson.TypeField:
|
||||
if err := b.ConsumeID("deleteAccount"); err != nil {
|
||||
return fmt.Errorf("unable to decode deleteAccount#533276c6: %w", err)
|
||||
}
|
||||
case "reason":
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode deleteAccount#533276c6: field reason: %w", err)
|
||||
}
|
||||
d.Reason = value
|
||||
case "password":
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode deleteAccount#533276c6: field password: %w", err)
|
||||
}
|
||||
d.Password = value
|
||||
default:
|
||||
return b.Skip()
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// GetReason returns value of Reason field.
|
||||
func (d *DeleteAccountRequest) GetReason() (value string) {
|
||||
if d == nil {
|
||||
return
|
||||
}
|
||||
return d.Reason
|
||||
}
|
||||
|
||||
// GetPassword returns value of Password field.
|
||||
func (d *DeleteAccountRequest) GetPassword() (value string) {
|
||||
if d == nil {
|
||||
return
|
||||
}
|
||||
return d.Password
|
||||
}
|
||||
|
||||
// DeleteAccount invokes method deleteAccount#533276c6 returning error if any.
|
||||
func (c *Client) DeleteAccount(ctx context.Context, request *DeleteAccountRequest) error {
|
||||
var ok Ok
|
||||
|
||||
if err := c.rpc.Invoke(ctx, request, &ok); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user