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,216 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// ResendPhoneNumberCodeRequest represents TL type `resendPhoneNumberCode#6bcea427`.
|
||||
type ResendPhoneNumberCodeRequest struct {
|
||||
// Reason of code resending; pass null if unknown
|
||||
Reason ResendCodeReasonClass
|
||||
}
|
||||
|
||||
// ResendPhoneNumberCodeRequestTypeID is TL type id of ResendPhoneNumberCodeRequest.
|
||||
const ResendPhoneNumberCodeRequestTypeID = 0x6bcea427
|
||||
|
||||
// Ensuring interfaces in compile-time for ResendPhoneNumberCodeRequest.
|
||||
var (
|
||||
_ bin.Encoder = &ResendPhoneNumberCodeRequest{}
|
||||
_ bin.Decoder = &ResendPhoneNumberCodeRequest{}
|
||||
_ bin.BareEncoder = &ResendPhoneNumberCodeRequest{}
|
||||
_ bin.BareDecoder = &ResendPhoneNumberCodeRequest{}
|
||||
)
|
||||
|
||||
func (r *ResendPhoneNumberCodeRequest) Zero() bool {
|
||||
if r == nil {
|
||||
return true
|
||||
}
|
||||
if !(r.Reason == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (r *ResendPhoneNumberCodeRequest) String() string {
|
||||
if r == nil {
|
||||
return "ResendPhoneNumberCodeRequest(nil)"
|
||||
}
|
||||
type Alias ResendPhoneNumberCodeRequest
|
||||
return fmt.Sprintf("ResendPhoneNumberCodeRequest%+v", Alias(*r))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*ResendPhoneNumberCodeRequest) TypeID() uint32 {
|
||||
return ResendPhoneNumberCodeRequestTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*ResendPhoneNumberCodeRequest) TypeName() string {
|
||||
return "resendPhoneNumberCode"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (r *ResendPhoneNumberCodeRequest) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "resendPhoneNumberCode",
|
||||
ID: ResendPhoneNumberCodeRequestTypeID,
|
||||
}
|
||||
if r == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Reason",
|
||||
SchemaName: "reason",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (r *ResendPhoneNumberCodeRequest) Encode(b *bin.Buffer) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("can't encode resendPhoneNumberCode#6bcea427 as nil")
|
||||
}
|
||||
b.PutID(ResendPhoneNumberCodeRequestTypeID)
|
||||
return r.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (r *ResendPhoneNumberCodeRequest) EncodeBare(b *bin.Buffer) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("can't encode resendPhoneNumberCode#6bcea427 as nil")
|
||||
}
|
||||
if r.Reason == nil {
|
||||
return fmt.Errorf("unable to encode resendPhoneNumberCode#6bcea427: field reason is nil")
|
||||
}
|
||||
if err := r.Reason.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode resendPhoneNumberCode#6bcea427: field reason: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (r *ResendPhoneNumberCodeRequest) Decode(b *bin.Buffer) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("can't decode resendPhoneNumberCode#6bcea427 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(ResendPhoneNumberCodeRequestTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode resendPhoneNumberCode#6bcea427: %w", err)
|
||||
}
|
||||
return r.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (r *ResendPhoneNumberCodeRequest) DecodeBare(b *bin.Buffer) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("can't decode resendPhoneNumberCode#6bcea427 to nil")
|
||||
}
|
||||
{
|
||||
value, err := DecodeResendCodeReason(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode resendPhoneNumberCode#6bcea427: field reason: %w", err)
|
||||
}
|
||||
r.Reason = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
||||
func (r *ResendPhoneNumberCodeRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("can't encode resendPhoneNumberCode#6bcea427 as nil")
|
||||
}
|
||||
b.ObjStart()
|
||||
b.PutID("resendPhoneNumberCode")
|
||||
b.Comma()
|
||||
b.FieldStart("reason")
|
||||
if r.Reason == nil {
|
||||
return fmt.Errorf("unable to encode resendPhoneNumberCode#6bcea427: field reason is nil")
|
||||
}
|
||||
if err := r.Reason.EncodeTDLibJSON(b); err != nil {
|
||||
return fmt.Errorf("unable to encode resendPhoneNumberCode#6bcea427: field reason: %w", err)
|
||||
}
|
||||
b.Comma()
|
||||
b.StripComma()
|
||||
b.ObjEnd()
|
||||
return nil
|
||||
}
|
||||
|
||||
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
||||
func (r *ResendPhoneNumberCodeRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
|
||||
if r == nil {
|
||||
return fmt.Errorf("can't decode resendPhoneNumberCode#6bcea427 to nil")
|
||||
}
|
||||
|
||||
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
||||
switch string(key) {
|
||||
case tdjson.TypeField:
|
||||
if err := b.ConsumeID("resendPhoneNumberCode"); err != nil {
|
||||
return fmt.Errorf("unable to decode resendPhoneNumberCode#6bcea427: %w", err)
|
||||
}
|
||||
case "reason":
|
||||
value, err := DecodeTDLibJSONResendCodeReason(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode resendPhoneNumberCode#6bcea427: field reason: %w", err)
|
||||
}
|
||||
r.Reason = value
|
||||
default:
|
||||
return b.Skip()
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// GetReason returns value of Reason field.
|
||||
func (r *ResendPhoneNumberCodeRequest) GetReason() (value ResendCodeReasonClass) {
|
||||
if r == nil {
|
||||
return
|
||||
}
|
||||
return r.Reason
|
||||
}
|
||||
|
||||
// ResendPhoneNumberCode invokes method resendPhoneNumberCode#6bcea427 returning error if any.
|
||||
func (c *Client) ResendPhoneNumberCode(ctx context.Context, reason ResendCodeReasonClass) (*AuthenticationCodeInfo, error) {
|
||||
var result AuthenticationCodeInfo
|
||||
|
||||
request := &ResendPhoneNumberCodeRequest{
|
||||
Reason: reason,
|
||||
}
|
||||
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &result, nil
|
||||
}
|
||||
Reference in New Issue
Block a user