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
466 lines
13 KiB
Go
466 lines
13 KiB
Go
// 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{}
|
|
)
|
|
|
|
// RequirementToContactEmpty represents TL type `requirementToContactEmpty#50a9839`.
|
|
//
|
|
// See https://core.telegram.org/constructor/requirementToContactEmpty for reference.
|
|
type RequirementToContactEmpty struct {
|
|
}
|
|
|
|
// RequirementToContactEmptyTypeID is TL type id of RequirementToContactEmpty.
|
|
const RequirementToContactEmptyTypeID = 0x50a9839
|
|
|
|
// construct implements constructor of RequirementToContactClass.
|
|
func (r RequirementToContactEmpty) construct() RequirementToContactClass { return &r }
|
|
|
|
// Ensuring interfaces in compile-time for RequirementToContactEmpty.
|
|
var (
|
|
_ bin.Encoder = &RequirementToContactEmpty{}
|
|
_ bin.Decoder = &RequirementToContactEmpty{}
|
|
_ bin.BareEncoder = &RequirementToContactEmpty{}
|
|
_ bin.BareDecoder = &RequirementToContactEmpty{}
|
|
|
|
_ RequirementToContactClass = &RequirementToContactEmpty{}
|
|
)
|
|
|
|
func (r *RequirementToContactEmpty) Zero() bool {
|
|
if r == nil {
|
|
return true
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (r *RequirementToContactEmpty) String() string {
|
|
if r == nil {
|
|
return "RequirementToContactEmpty(nil)"
|
|
}
|
|
type Alias RequirementToContactEmpty
|
|
return fmt.Sprintf("RequirementToContactEmpty%+v", Alias(*r))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*RequirementToContactEmpty) TypeID() uint32 {
|
|
return RequirementToContactEmptyTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*RequirementToContactEmpty) TypeName() string {
|
|
return "requirementToContactEmpty"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (r *RequirementToContactEmpty) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "requirementToContactEmpty",
|
|
ID: RequirementToContactEmptyTypeID,
|
|
}
|
|
if r == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (r *RequirementToContactEmpty) Encode(b *bin.Buffer) error {
|
|
if r == nil {
|
|
return fmt.Errorf("can't encode requirementToContactEmpty#50a9839 as nil")
|
|
}
|
|
b.PutID(RequirementToContactEmptyTypeID)
|
|
return r.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (r *RequirementToContactEmpty) EncodeBare(b *bin.Buffer) error {
|
|
if r == nil {
|
|
return fmt.Errorf("can't encode requirementToContactEmpty#50a9839 as nil")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (r *RequirementToContactEmpty) Decode(b *bin.Buffer) error {
|
|
if r == nil {
|
|
return fmt.Errorf("can't decode requirementToContactEmpty#50a9839 to nil")
|
|
}
|
|
if err := b.ConsumeID(RequirementToContactEmptyTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode requirementToContactEmpty#50a9839: %w", err)
|
|
}
|
|
return r.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (r *RequirementToContactEmpty) DecodeBare(b *bin.Buffer) error {
|
|
if r == nil {
|
|
return fmt.Errorf("can't decode requirementToContactEmpty#50a9839 to nil")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// RequirementToContactPremium represents TL type `requirementToContactPremium#e581e4e9`.
|
|
//
|
|
// See https://core.telegram.org/constructor/requirementToContactPremium for reference.
|
|
type RequirementToContactPremium struct {
|
|
}
|
|
|
|
// RequirementToContactPremiumTypeID is TL type id of RequirementToContactPremium.
|
|
const RequirementToContactPremiumTypeID = 0xe581e4e9
|
|
|
|
// construct implements constructor of RequirementToContactClass.
|
|
func (r RequirementToContactPremium) construct() RequirementToContactClass { return &r }
|
|
|
|
// Ensuring interfaces in compile-time for RequirementToContactPremium.
|
|
var (
|
|
_ bin.Encoder = &RequirementToContactPremium{}
|
|
_ bin.Decoder = &RequirementToContactPremium{}
|
|
_ bin.BareEncoder = &RequirementToContactPremium{}
|
|
_ bin.BareDecoder = &RequirementToContactPremium{}
|
|
|
|
_ RequirementToContactClass = &RequirementToContactPremium{}
|
|
)
|
|
|
|
func (r *RequirementToContactPremium) Zero() bool {
|
|
if r == nil {
|
|
return true
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (r *RequirementToContactPremium) String() string {
|
|
if r == nil {
|
|
return "RequirementToContactPremium(nil)"
|
|
}
|
|
type Alias RequirementToContactPremium
|
|
return fmt.Sprintf("RequirementToContactPremium%+v", Alias(*r))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*RequirementToContactPremium) TypeID() uint32 {
|
|
return RequirementToContactPremiumTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*RequirementToContactPremium) TypeName() string {
|
|
return "requirementToContactPremium"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (r *RequirementToContactPremium) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "requirementToContactPremium",
|
|
ID: RequirementToContactPremiumTypeID,
|
|
}
|
|
if r == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (r *RequirementToContactPremium) Encode(b *bin.Buffer) error {
|
|
if r == nil {
|
|
return fmt.Errorf("can't encode requirementToContactPremium#e581e4e9 as nil")
|
|
}
|
|
b.PutID(RequirementToContactPremiumTypeID)
|
|
return r.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (r *RequirementToContactPremium) EncodeBare(b *bin.Buffer) error {
|
|
if r == nil {
|
|
return fmt.Errorf("can't encode requirementToContactPremium#e581e4e9 as nil")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (r *RequirementToContactPremium) Decode(b *bin.Buffer) error {
|
|
if r == nil {
|
|
return fmt.Errorf("can't decode requirementToContactPremium#e581e4e9 to nil")
|
|
}
|
|
if err := b.ConsumeID(RequirementToContactPremiumTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode requirementToContactPremium#e581e4e9: %w", err)
|
|
}
|
|
return r.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (r *RequirementToContactPremium) DecodeBare(b *bin.Buffer) error {
|
|
if r == nil {
|
|
return fmt.Errorf("can't decode requirementToContactPremium#e581e4e9 to nil")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// RequirementToContactPaidMessages represents TL type `requirementToContactPaidMessages#b4f67e93`.
|
|
//
|
|
// See https://core.telegram.org/constructor/requirementToContactPaidMessages for reference.
|
|
type RequirementToContactPaidMessages struct {
|
|
// StarsAmount field of RequirementToContactPaidMessages.
|
|
StarsAmount int64
|
|
}
|
|
|
|
// RequirementToContactPaidMessagesTypeID is TL type id of RequirementToContactPaidMessages.
|
|
const RequirementToContactPaidMessagesTypeID = 0xb4f67e93
|
|
|
|
// construct implements constructor of RequirementToContactClass.
|
|
func (r RequirementToContactPaidMessages) construct() RequirementToContactClass { return &r }
|
|
|
|
// Ensuring interfaces in compile-time for RequirementToContactPaidMessages.
|
|
var (
|
|
_ bin.Encoder = &RequirementToContactPaidMessages{}
|
|
_ bin.Decoder = &RequirementToContactPaidMessages{}
|
|
_ bin.BareEncoder = &RequirementToContactPaidMessages{}
|
|
_ bin.BareDecoder = &RequirementToContactPaidMessages{}
|
|
|
|
_ RequirementToContactClass = &RequirementToContactPaidMessages{}
|
|
)
|
|
|
|
func (r *RequirementToContactPaidMessages) Zero() bool {
|
|
if r == nil {
|
|
return true
|
|
}
|
|
if !(r.StarsAmount == 0) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (r *RequirementToContactPaidMessages) String() string {
|
|
if r == nil {
|
|
return "RequirementToContactPaidMessages(nil)"
|
|
}
|
|
type Alias RequirementToContactPaidMessages
|
|
return fmt.Sprintf("RequirementToContactPaidMessages%+v", Alias(*r))
|
|
}
|
|
|
|
// FillFrom fills RequirementToContactPaidMessages from given interface.
|
|
func (r *RequirementToContactPaidMessages) FillFrom(from interface {
|
|
GetStarsAmount() (value int64)
|
|
}) {
|
|
r.StarsAmount = from.GetStarsAmount()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*RequirementToContactPaidMessages) TypeID() uint32 {
|
|
return RequirementToContactPaidMessagesTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*RequirementToContactPaidMessages) TypeName() string {
|
|
return "requirementToContactPaidMessages"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (r *RequirementToContactPaidMessages) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "requirementToContactPaidMessages",
|
|
ID: RequirementToContactPaidMessagesTypeID,
|
|
}
|
|
if r == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "StarsAmount",
|
|
SchemaName: "stars_amount",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (r *RequirementToContactPaidMessages) Encode(b *bin.Buffer) error {
|
|
if r == nil {
|
|
return fmt.Errorf("can't encode requirementToContactPaidMessages#b4f67e93 as nil")
|
|
}
|
|
b.PutID(RequirementToContactPaidMessagesTypeID)
|
|
return r.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (r *RequirementToContactPaidMessages) EncodeBare(b *bin.Buffer) error {
|
|
if r == nil {
|
|
return fmt.Errorf("can't encode requirementToContactPaidMessages#b4f67e93 as nil")
|
|
}
|
|
b.PutLong(r.StarsAmount)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (r *RequirementToContactPaidMessages) Decode(b *bin.Buffer) error {
|
|
if r == nil {
|
|
return fmt.Errorf("can't decode requirementToContactPaidMessages#b4f67e93 to nil")
|
|
}
|
|
if err := b.ConsumeID(RequirementToContactPaidMessagesTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode requirementToContactPaidMessages#b4f67e93: %w", err)
|
|
}
|
|
return r.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (r *RequirementToContactPaidMessages) DecodeBare(b *bin.Buffer) error {
|
|
if r == nil {
|
|
return fmt.Errorf("can't decode requirementToContactPaidMessages#b4f67e93 to nil")
|
|
}
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode requirementToContactPaidMessages#b4f67e93: field stars_amount: %w", err)
|
|
}
|
|
r.StarsAmount = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetStarsAmount returns value of StarsAmount field.
|
|
func (r *RequirementToContactPaidMessages) GetStarsAmount() (value int64) {
|
|
if r == nil {
|
|
return
|
|
}
|
|
return r.StarsAmount
|
|
}
|
|
|
|
// RequirementToContactClassName is schema name of RequirementToContactClass.
|
|
const RequirementToContactClassName = "RequirementToContact"
|
|
|
|
// RequirementToContactClass represents RequirementToContact generic type.
|
|
//
|
|
// See https://core.telegram.org/type/RequirementToContact for reference.
|
|
//
|
|
// Example:
|
|
//
|
|
// g, err := tg.DecodeRequirementToContact(buf)
|
|
// if err != nil {
|
|
// panic(err)
|
|
// }
|
|
// switch v := g.(type) {
|
|
// case *tg.RequirementToContactEmpty: // requirementToContactEmpty#50a9839
|
|
// case *tg.RequirementToContactPremium: // requirementToContactPremium#e581e4e9
|
|
// case *tg.RequirementToContactPaidMessages: // requirementToContactPaidMessages#b4f67e93
|
|
// default: panic(v)
|
|
// }
|
|
type RequirementToContactClass interface {
|
|
bin.Encoder
|
|
bin.Decoder
|
|
bin.BareEncoder
|
|
bin.BareDecoder
|
|
construct() RequirementToContactClass
|
|
|
|
// 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
|
|
}
|
|
|
|
// DecodeRequirementToContact implements binary de-serialization for RequirementToContactClass.
|
|
func DecodeRequirementToContact(buf *bin.Buffer) (RequirementToContactClass, error) {
|
|
id, err := buf.PeekID()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
switch id {
|
|
case RequirementToContactEmptyTypeID:
|
|
// Decoding requirementToContactEmpty#50a9839.
|
|
v := RequirementToContactEmpty{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode RequirementToContactClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case RequirementToContactPremiumTypeID:
|
|
// Decoding requirementToContactPremium#e581e4e9.
|
|
v := RequirementToContactPremium{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode RequirementToContactClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case RequirementToContactPaidMessagesTypeID:
|
|
// Decoding requirementToContactPaidMessages#b4f67e93.
|
|
v := RequirementToContactPaidMessages{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode RequirementToContactClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
default:
|
|
return nil, fmt.Errorf("unable to decode RequirementToContactClass: %w", bin.NewUnexpectedID(id))
|
|
}
|
|
}
|
|
|
|
// RequirementToContact boxes the RequirementToContactClass providing a helper.
|
|
type RequirementToContactBox struct {
|
|
RequirementToContact RequirementToContactClass
|
|
}
|
|
|
|
// Decode implements bin.Decoder for RequirementToContactBox.
|
|
func (b *RequirementToContactBox) Decode(buf *bin.Buffer) error {
|
|
if b == nil {
|
|
return fmt.Errorf("unable to decode RequirementToContactBox to nil")
|
|
}
|
|
v, err := DecodeRequirementToContact(buf)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode boxed value: %w", err)
|
|
}
|
|
b.RequirementToContact = v
|
|
return nil
|
|
}
|
|
|
|
// Encode implements bin.Encode for RequirementToContactBox.
|
|
func (b *RequirementToContactBox) Encode(buf *bin.Buffer) error {
|
|
if b == nil || b.RequirementToContact == nil {
|
|
return fmt.Errorf("unable to encode RequirementToContactClass as nil")
|
|
}
|
|
return b.RequirementToContact.Encode(buf)
|
|
}
|