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,211 @@
|
||||
// Code generated by gotdgen, DO NOT EDIT.
|
||||
|
||||
package tg
|
||||
|
||||
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{}
|
||||
)
|
||||
|
||||
// AuthCancelCodeRequest represents TL type `auth.cancelCode#1f040578`.
|
||||
// Cancel the login verification code
|
||||
//
|
||||
// See https://core.telegram.org/method/auth.cancelCode for reference.
|
||||
type AuthCancelCodeRequest struct {
|
||||
// Phone number
|
||||
PhoneNumber string
|
||||
// Phone code hash from auth.sendCode¹
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/method/auth.sendCode
|
||||
PhoneCodeHash string
|
||||
}
|
||||
|
||||
// AuthCancelCodeRequestTypeID is TL type id of AuthCancelCodeRequest.
|
||||
const AuthCancelCodeRequestTypeID = 0x1f040578
|
||||
|
||||
// Ensuring interfaces in compile-time for AuthCancelCodeRequest.
|
||||
var (
|
||||
_ bin.Encoder = &AuthCancelCodeRequest{}
|
||||
_ bin.Decoder = &AuthCancelCodeRequest{}
|
||||
_ bin.BareEncoder = &AuthCancelCodeRequest{}
|
||||
_ bin.BareDecoder = &AuthCancelCodeRequest{}
|
||||
)
|
||||
|
||||
func (c *AuthCancelCodeRequest) Zero() bool {
|
||||
if c == nil {
|
||||
return true
|
||||
}
|
||||
if !(c.PhoneNumber == "") {
|
||||
return false
|
||||
}
|
||||
if !(c.PhoneCodeHash == "") {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (c *AuthCancelCodeRequest) String() string {
|
||||
if c == nil {
|
||||
return "AuthCancelCodeRequest(nil)"
|
||||
}
|
||||
type Alias AuthCancelCodeRequest
|
||||
return fmt.Sprintf("AuthCancelCodeRequest%+v", Alias(*c))
|
||||
}
|
||||
|
||||
// FillFrom fills AuthCancelCodeRequest from given interface.
|
||||
func (c *AuthCancelCodeRequest) FillFrom(from interface {
|
||||
GetPhoneNumber() (value string)
|
||||
GetPhoneCodeHash() (value string)
|
||||
}) {
|
||||
c.PhoneNumber = from.GetPhoneNumber()
|
||||
c.PhoneCodeHash = from.GetPhoneCodeHash()
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*AuthCancelCodeRequest) TypeID() uint32 {
|
||||
return AuthCancelCodeRequestTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*AuthCancelCodeRequest) TypeName() string {
|
||||
return "auth.cancelCode"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (c *AuthCancelCodeRequest) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "auth.cancelCode",
|
||||
ID: AuthCancelCodeRequestTypeID,
|
||||
}
|
||||
if c == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "PhoneNumber",
|
||||
SchemaName: "phone_number",
|
||||
},
|
||||
{
|
||||
Name: "PhoneCodeHash",
|
||||
SchemaName: "phone_code_hash",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (c *AuthCancelCodeRequest) Encode(b *bin.Buffer) error {
|
||||
if c == nil {
|
||||
return fmt.Errorf("can't encode auth.cancelCode#1f040578 as nil")
|
||||
}
|
||||
b.PutID(AuthCancelCodeRequestTypeID)
|
||||
return c.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (c *AuthCancelCodeRequest) EncodeBare(b *bin.Buffer) error {
|
||||
if c == nil {
|
||||
return fmt.Errorf("can't encode auth.cancelCode#1f040578 as nil")
|
||||
}
|
||||
b.PutString(c.PhoneNumber)
|
||||
b.PutString(c.PhoneCodeHash)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (c *AuthCancelCodeRequest) Decode(b *bin.Buffer) error {
|
||||
if c == nil {
|
||||
return fmt.Errorf("can't decode auth.cancelCode#1f040578 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(AuthCancelCodeRequestTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode auth.cancelCode#1f040578: %w", err)
|
||||
}
|
||||
return c.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (c *AuthCancelCodeRequest) DecodeBare(b *bin.Buffer) error {
|
||||
if c == nil {
|
||||
return fmt.Errorf("can't decode auth.cancelCode#1f040578 to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode auth.cancelCode#1f040578: field phone_number: %w", err)
|
||||
}
|
||||
c.PhoneNumber = value
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode auth.cancelCode#1f040578: field phone_code_hash: %w", err)
|
||||
}
|
||||
c.PhoneCodeHash = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetPhoneNumber returns value of PhoneNumber field.
|
||||
func (c *AuthCancelCodeRequest) GetPhoneNumber() (value string) {
|
||||
if c == nil {
|
||||
return
|
||||
}
|
||||
return c.PhoneNumber
|
||||
}
|
||||
|
||||
// GetPhoneCodeHash returns value of PhoneCodeHash field.
|
||||
func (c *AuthCancelCodeRequest) GetPhoneCodeHash() (value string) {
|
||||
if c == nil {
|
||||
return
|
||||
}
|
||||
return c.PhoneCodeHash
|
||||
}
|
||||
|
||||
// AuthCancelCode invokes method auth.cancelCode#1f040578 returning error if any.
|
||||
// Cancel the login verification code
|
||||
//
|
||||
// Possible errors:
|
||||
//
|
||||
// 400 PHONE_CODE_EXPIRED: The phone code you provided has expired.
|
||||
// 406 PHONE_NUMBER_INVALID: The phone number is invalid.
|
||||
//
|
||||
// See https://core.telegram.org/method/auth.cancelCode for reference.
|
||||
func (c *Client) AuthCancelCode(ctx context.Context, request *AuthCancelCodeRequest) (bool, error) {
|
||||
var result BoolBox
|
||||
|
||||
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
||||
return false, err
|
||||
}
|
||||
_, ok := result.Bool.(*BoolTrue)
|
||||
return ok, nil
|
||||
}
|
||||
Reference in New Issue
Block a user