7a04f298d2
- 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
535 lines
14 KiB
Go
Generated
535 lines
14 KiB
Go
Generated
// 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{}
|
|
)
|
|
|
|
// EmailVerificationCode represents TL type `emailVerificationCode#922e55a9`.
|
|
// Email verification code
|
|
//
|
|
// See https://core.telegram.org/constructor/emailVerificationCode for reference.
|
|
type EmailVerificationCode struct {
|
|
// Received verification code
|
|
Code string
|
|
}
|
|
|
|
// EmailVerificationCodeTypeID is TL type id of EmailVerificationCode.
|
|
const EmailVerificationCodeTypeID = 0x922e55a9
|
|
|
|
// construct implements constructor of EmailVerificationClass.
|
|
func (e EmailVerificationCode) construct() EmailVerificationClass { return &e }
|
|
|
|
// Ensuring interfaces in compile-time for EmailVerificationCode.
|
|
var (
|
|
_ bin.Encoder = &EmailVerificationCode{}
|
|
_ bin.Decoder = &EmailVerificationCode{}
|
|
_ bin.BareEncoder = &EmailVerificationCode{}
|
|
_ bin.BareDecoder = &EmailVerificationCode{}
|
|
|
|
_ EmailVerificationClass = &EmailVerificationCode{}
|
|
)
|
|
|
|
func (e *EmailVerificationCode) Zero() bool {
|
|
if e == nil {
|
|
return true
|
|
}
|
|
if !(e.Code == "") {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (e *EmailVerificationCode) String() string {
|
|
if e == nil {
|
|
return "EmailVerificationCode(nil)"
|
|
}
|
|
type Alias EmailVerificationCode
|
|
return fmt.Sprintf("EmailVerificationCode%+v", Alias(*e))
|
|
}
|
|
|
|
// FillFrom fills EmailVerificationCode from given interface.
|
|
func (e *EmailVerificationCode) FillFrom(from interface {
|
|
GetCode() (value string)
|
|
}) {
|
|
e.Code = from.GetCode()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*EmailVerificationCode) TypeID() uint32 {
|
|
return EmailVerificationCodeTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*EmailVerificationCode) TypeName() string {
|
|
return "emailVerificationCode"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (e *EmailVerificationCode) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "emailVerificationCode",
|
|
ID: EmailVerificationCodeTypeID,
|
|
}
|
|
if e == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Code",
|
|
SchemaName: "code",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (e *EmailVerificationCode) Encode(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't encode emailVerificationCode#922e55a9 as nil")
|
|
}
|
|
b.PutID(EmailVerificationCodeTypeID)
|
|
return e.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (e *EmailVerificationCode) EncodeBare(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't encode emailVerificationCode#922e55a9 as nil")
|
|
}
|
|
b.PutString(e.Code)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (e *EmailVerificationCode) Decode(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't decode emailVerificationCode#922e55a9 to nil")
|
|
}
|
|
if err := b.ConsumeID(EmailVerificationCodeTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode emailVerificationCode#922e55a9: %w", err)
|
|
}
|
|
return e.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (e *EmailVerificationCode) DecodeBare(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't decode emailVerificationCode#922e55a9 to nil")
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode emailVerificationCode#922e55a9: field code: %w", err)
|
|
}
|
|
e.Code = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetCode returns value of Code field.
|
|
func (e *EmailVerificationCode) GetCode() (value string) {
|
|
if e == nil {
|
|
return
|
|
}
|
|
return e.Code
|
|
}
|
|
|
|
// EmailVerificationGoogle represents TL type `emailVerificationGoogle#db909ec2`.
|
|
// Google ID email verification token
|
|
//
|
|
// See https://core.telegram.org/constructor/emailVerificationGoogle for reference.
|
|
type EmailVerificationGoogle struct {
|
|
// Token
|
|
Token string
|
|
}
|
|
|
|
// EmailVerificationGoogleTypeID is TL type id of EmailVerificationGoogle.
|
|
const EmailVerificationGoogleTypeID = 0xdb909ec2
|
|
|
|
// construct implements constructor of EmailVerificationClass.
|
|
func (e EmailVerificationGoogle) construct() EmailVerificationClass { return &e }
|
|
|
|
// Ensuring interfaces in compile-time for EmailVerificationGoogle.
|
|
var (
|
|
_ bin.Encoder = &EmailVerificationGoogle{}
|
|
_ bin.Decoder = &EmailVerificationGoogle{}
|
|
_ bin.BareEncoder = &EmailVerificationGoogle{}
|
|
_ bin.BareDecoder = &EmailVerificationGoogle{}
|
|
|
|
_ EmailVerificationClass = &EmailVerificationGoogle{}
|
|
)
|
|
|
|
func (e *EmailVerificationGoogle) Zero() bool {
|
|
if e == nil {
|
|
return true
|
|
}
|
|
if !(e.Token == "") {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (e *EmailVerificationGoogle) String() string {
|
|
if e == nil {
|
|
return "EmailVerificationGoogle(nil)"
|
|
}
|
|
type Alias EmailVerificationGoogle
|
|
return fmt.Sprintf("EmailVerificationGoogle%+v", Alias(*e))
|
|
}
|
|
|
|
// FillFrom fills EmailVerificationGoogle from given interface.
|
|
func (e *EmailVerificationGoogle) FillFrom(from interface {
|
|
GetToken() (value string)
|
|
}) {
|
|
e.Token = from.GetToken()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*EmailVerificationGoogle) TypeID() uint32 {
|
|
return EmailVerificationGoogleTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*EmailVerificationGoogle) TypeName() string {
|
|
return "emailVerificationGoogle"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (e *EmailVerificationGoogle) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "emailVerificationGoogle",
|
|
ID: EmailVerificationGoogleTypeID,
|
|
}
|
|
if e == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Token",
|
|
SchemaName: "token",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (e *EmailVerificationGoogle) Encode(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't encode emailVerificationGoogle#db909ec2 as nil")
|
|
}
|
|
b.PutID(EmailVerificationGoogleTypeID)
|
|
return e.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (e *EmailVerificationGoogle) EncodeBare(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't encode emailVerificationGoogle#db909ec2 as nil")
|
|
}
|
|
b.PutString(e.Token)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (e *EmailVerificationGoogle) Decode(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't decode emailVerificationGoogle#db909ec2 to nil")
|
|
}
|
|
if err := b.ConsumeID(EmailVerificationGoogleTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode emailVerificationGoogle#db909ec2: %w", err)
|
|
}
|
|
return e.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (e *EmailVerificationGoogle) DecodeBare(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't decode emailVerificationGoogle#db909ec2 to nil")
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode emailVerificationGoogle#db909ec2: field token: %w", err)
|
|
}
|
|
e.Token = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetToken returns value of Token field.
|
|
func (e *EmailVerificationGoogle) GetToken() (value string) {
|
|
if e == nil {
|
|
return
|
|
}
|
|
return e.Token
|
|
}
|
|
|
|
// EmailVerificationApple represents TL type `emailVerificationApple#96d074fd`.
|
|
// Apple ID email verification token
|
|
//
|
|
// See https://core.telegram.org/constructor/emailVerificationApple for reference.
|
|
type EmailVerificationApple struct {
|
|
// Token
|
|
Token string
|
|
}
|
|
|
|
// EmailVerificationAppleTypeID is TL type id of EmailVerificationApple.
|
|
const EmailVerificationAppleTypeID = 0x96d074fd
|
|
|
|
// construct implements constructor of EmailVerificationClass.
|
|
func (e EmailVerificationApple) construct() EmailVerificationClass { return &e }
|
|
|
|
// Ensuring interfaces in compile-time for EmailVerificationApple.
|
|
var (
|
|
_ bin.Encoder = &EmailVerificationApple{}
|
|
_ bin.Decoder = &EmailVerificationApple{}
|
|
_ bin.BareEncoder = &EmailVerificationApple{}
|
|
_ bin.BareDecoder = &EmailVerificationApple{}
|
|
|
|
_ EmailVerificationClass = &EmailVerificationApple{}
|
|
)
|
|
|
|
func (e *EmailVerificationApple) Zero() bool {
|
|
if e == nil {
|
|
return true
|
|
}
|
|
if !(e.Token == "") {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (e *EmailVerificationApple) String() string {
|
|
if e == nil {
|
|
return "EmailVerificationApple(nil)"
|
|
}
|
|
type Alias EmailVerificationApple
|
|
return fmt.Sprintf("EmailVerificationApple%+v", Alias(*e))
|
|
}
|
|
|
|
// FillFrom fills EmailVerificationApple from given interface.
|
|
func (e *EmailVerificationApple) FillFrom(from interface {
|
|
GetToken() (value string)
|
|
}) {
|
|
e.Token = from.GetToken()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*EmailVerificationApple) TypeID() uint32 {
|
|
return EmailVerificationAppleTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*EmailVerificationApple) TypeName() string {
|
|
return "emailVerificationApple"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (e *EmailVerificationApple) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "emailVerificationApple",
|
|
ID: EmailVerificationAppleTypeID,
|
|
}
|
|
if e == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Token",
|
|
SchemaName: "token",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (e *EmailVerificationApple) Encode(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't encode emailVerificationApple#96d074fd as nil")
|
|
}
|
|
b.PutID(EmailVerificationAppleTypeID)
|
|
return e.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (e *EmailVerificationApple) EncodeBare(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't encode emailVerificationApple#96d074fd as nil")
|
|
}
|
|
b.PutString(e.Token)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (e *EmailVerificationApple) Decode(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't decode emailVerificationApple#96d074fd to nil")
|
|
}
|
|
if err := b.ConsumeID(EmailVerificationAppleTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode emailVerificationApple#96d074fd: %w", err)
|
|
}
|
|
return e.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (e *EmailVerificationApple) DecodeBare(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't decode emailVerificationApple#96d074fd to nil")
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode emailVerificationApple#96d074fd: field token: %w", err)
|
|
}
|
|
e.Token = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetToken returns value of Token field.
|
|
func (e *EmailVerificationApple) GetToken() (value string) {
|
|
if e == nil {
|
|
return
|
|
}
|
|
return e.Token
|
|
}
|
|
|
|
// EmailVerificationClassName is schema name of EmailVerificationClass.
|
|
const EmailVerificationClassName = "EmailVerification"
|
|
|
|
// EmailVerificationClass represents EmailVerification generic type.
|
|
//
|
|
// See https://core.telegram.org/type/EmailVerification for reference.
|
|
//
|
|
// Example:
|
|
//
|
|
// g, err := tg.DecodeEmailVerification(buf)
|
|
// if err != nil {
|
|
// panic(err)
|
|
// }
|
|
// switch v := g.(type) {
|
|
// case *tg.EmailVerificationCode: // emailVerificationCode#922e55a9
|
|
// case *tg.EmailVerificationGoogle: // emailVerificationGoogle#db909ec2
|
|
// case *tg.EmailVerificationApple: // emailVerificationApple#96d074fd
|
|
// default: panic(v)
|
|
// }
|
|
type EmailVerificationClass interface {
|
|
bin.Encoder
|
|
bin.Decoder
|
|
bin.BareEncoder
|
|
bin.BareDecoder
|
|
construct() EmailVerificationClass
|
|
|
|
// 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
|
|
}
|
|
|
|
// DecodeEmailVerification implements binary de-serialization for EmailVerificationClass.
|
|
func DecodeEmailVerification(buf *bin.Buffer) (EmailVerificationClass, error) {
|
|
id, err := buf.PeekID()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
switch id {
|
|
case EmailVerificationCodeTypeID:
|
|
// Decoding emailVerificationCode#922e55a9.
|
|
v := EmailVerificationCode{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode EmailVerificationClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case EmailVerificationGoogleTypeID:
|
|
// Decoding emailVerificationGoogle#db909ec2.
|
|
v := EmailVerificationGoogle{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode EmailVerificationClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case EmailVerificationAppleTypeID:
|
|
// Decoding emailVerificationApple#96d074fd.
|
|
v := EmailVerificationApple{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode EmailVerificationClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
default:
|
|
return nil, fmt.Errorf("unable to decode EmailVerificationClass: %w", bin.NewUnexpectedID(id))
|
|
}
|
|
}
|
|
|
|
// EmailVerification boxes the EmailVerificationClass providing a helper.
|
|
type EmailVerificationBox struct {
|
|
EmailVerification EmailVerificationClass
|
|
}
|
|
|
|
// Decode implements bin.Decoder for EmailVerificationBox.
|
|
func (b *EmailVerificationBox) Decode(buf *bin.Buffer) error {
|
|
if b == nil {
|
|
return fmt.Errorf("unable to decode EmailVerificationBox to nil")
|
|
}
|
|
v, err := DecodeEmailVerification(buf)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode boxed value: %w", err)
|
|
}
|
|
b.EmailVerification = v
|
|
return nil
|
|
}
|
|
|
|
// Encode implements bin.Encode for EmailVerificationBox.
|
|
func (b *EmailVerificationBox) Encode(buf *bin.Buffer) error {
|
|
if b == nil || b.EmailVerification == nil {
|
|
return fmt.Errorf("unable to encode EmailVerificationClass as nil")
|
|
}
|
|
return b.EmailVerification.Encode(buf)
|
|
}
|