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,465 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// InputBotAppID represents TL type `inputBotAppID#a920bd7a`.
|
||||
// Used to fetch information about a direct link Mini App¹ by its ID
|
||||
//
|
||||
// Links:
|
||||
// 1. https://core.telegram.org/api/bots/webapps#direct-link-mini-apps
|
||||
//
|
||||
// See https://core.telegram.org/constructor/inputBotAppID for reference.
|
||||
type InputBotAppID struct {
|
||||
// direct link Mini App¹ ID.
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/api/bots/webapps#direct-link-mini-apps
|
||||
ID int64
|
||||
// Access hash, obtained from the botApp¹ constructor.
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/constructor/botApp
|
||||
AccessHash int64
|
||||
}
|
||||
|
||||
// InputBotAppIDTypeID is TL type id of InputBotAppID.
|
||||
const InputBotAppIDTypeID = 0xa920bd7a
|
||||
|
||||
// construct implements constructor of InputBotAppClass.
|
||||
func (i InputBotAppID) construct() InputBotAppClass { return &i }
|
||||
|
||||
// Ensuring interfaces in compile-time for InputBotAppID.
|
||||
var (
|
||||
_ bin.Encoder = &InputBotAppID{}
|
||||
_ bin.Decoder = &InputBotAppID{}
|
||||
_ bin.BareEncoder = &InputBotAppID{}
|
||||
_ bin.BareDecoder = &InputBotAppID{}
|
||||
|
||||
_ InputBotAppClass = &InputBotAppID{}
|
||||
)
|
||||
|
||||
func (i *InputBotAppID) Zero() bool {
|
||||
if i == nil {
|
||||
return true
|
||||
}
|
||||
if !(i.ID == 0) {
|
||||
return false
|
||||
}
|
||||
if !(i.AccessHash == 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (i *InputBotAppID) String() string {
|
||||
if i == nil {
|
||||
return "InputBotAppID(nil)"
|
||||
}
|
||||
type Alias InputBotAppID
|
||||
return fmt.Sprintf("InputBotAppID%+v", Alias(*i))
|
||||
}
|
||||
|
||||
// FillFrom fills InputBotAppID from given interface.
|
||||
func (i *InputBotAppID) FillFrom(from interface {
|
||||
GetID() (value int64)
|
||||
GetAccessHash() (value int64)
|
||||
}) {
|
||||
i.ID = from.GetID()
|
||||
i.AccessHash = from.GetAccessHash()
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*InputBotAppID) TypeID() uint32 {
|
||||
return InputBotAppIDTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*InputBotAppID) TypeName() string {
|
||||
return "inputBotAppID"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (i *InputBotAppID) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "inputBotAppID",
|
||||
ID: InputBotAppIDTypeID,
|
||||
}
|
||||
if i == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "ID",
|
||||
SchemaName: "id",
|
||||
},
|
||||
{
|
||||
Name: "AccessHash",
|
||||
SchemaName: "access_hash",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (i *InputBotAppID) Encode(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode inputBotAppID#a920bd7a as nil")
|
||||
}
|
||||
b.PutID(InputBotAppIDTypeID)
|
||||
return i.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (i *InputBotAppID) EncodeBare(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode inputBotAppID#a920bd7a as nil")
|
||||
}
|
||||
b.PutLong(i.ID)
|
||||
b.PutLong(i.AccessHash)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (i *InputBotAppID) Decode(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode inputBotAppID#a920bd7a to nil")
|
||||
}
|
||||
if err := b.ConsumeID(InputBotAppIDTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode inputBotAppID#a920bd7a: %w", err)
|
||||
}
|
||||
return i.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (i *InputBotAppID) DecodeBare(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode inputBotAppID#a920bd7a to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.Long()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode inputBotAppID#a920bd7a: field id: %w", err)
|
||||
}
|
||||
i.ID = value
|
||||
}
|
||||
{
|
||||
value, err := b.Long()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode inputBotAppID#a920bd7a: field access_hash: %w", err)
|
||||
}
|
||||
i.AccessHash = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetID returns value of ID field.
|
||||
func (i *InputBotAppID) GetID() (value int64) {
|
||||
if i == nil {
|
||||
return
|
||||
}
|
||||
return i.ID
|
||||
}
|
||||
|
||||
// GetAccessHash returns value of AccessHash field.
|
||||
func (i *InputBotAppID) GetAccessHash() (value int64) {
|
||||
if i == nil {
|
||||
return
|
||||
}
|
||||
return i.AccessHash
|
||||
}
|
||||
|
||||
// InputBotAppShortName represents TL type `inputBotAppShortName#908c0407`.
|
||||
// Used to fetch information about a direct link Mini App¹ by its short name
|
||||
//
|
||||
// Links:
|
||||
// 1. https://core.telegram.org/api/bots/webapps#direct-link-mini-apps
|
||||
//
|
||||
// See https://core.telegram.org/constructor/inputBotAppShortName for reference.
|
||||
type InputBotAppShortName struct {
|
||||
// ID of the bot that owns the bot mini app
|
||||
BotID InputUserClass
|
||||
// Short name, obtained from a Direct Mini App deep link¹
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/api/links#direct-mini-app-links
|
||||
ShortName string
|
||||
}
|
||||
|
||||
// InputBotAppShortNameTypeID is TL type id of InputBotAppShortName.
|
||||
const InputBotAppShortNameTypeID = 0x908c0407
|
||||
|
||||
// construct implements constructor of InputBotAppClass.
|
||||
func (i InputBotAppShortName) construct() InputBotAppClass { return &i }
|
||||
|
||||
// Ensuring interfaces in compile-time for InputBotAppShortName.
|
||||
var (
|
||||
_ bin.Encoder = &InputBotAppShortName{}
|
||||
_ bin.Decoder = &InputBotAppShortName{}
|
||||
_ bin.BareEncoder = &InputBotAppShortName{}
|
||||
_ bin.BareDecoder = &InputBotAppShortName{}
|
||||
|
||||
_ InputBotAppClass = &InputBotAppShortName{}
|
||||
)
|
||||
|
||||
func (i *InputBotAppShortName) Zero() bool {
|
||||
if i == nil {
|
||||
return true
|
||||
}
|
||||
if !(i.BotID == nil) {
|
||||
return false
|
||||
}
|
||||
if !(i.ShortName == "") {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (i *InputBotAppShortName) String() string {
|
||||
if i == nil {
|
||||
return "InputBotAppShortName(nil)"
|
||||
}
|
||||
type Alias InputBotAppShortName
|
||||
return fmt.Sprintf("InputBotAppShortName%+v", Alias(*i))
|
||||
}
|
||||
|
||||
// FillFrom fills InputBotAppShortName from given interface.
|
||||
func (i *InputBotAppShortName) FillFrom(from interface {
|
||||
GetBotID() (value InputUserClass)
|
||||
GetShortName() (value string)
|
||||
}) {
|
||||
i.BotID = from.GetBotID()
|
||||
i.ShortName = from.GetShortName()
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*InputBotAppShortName) TypeID() uint32 {
|
||||
return InputBotAppShortNameTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*InputBotAppShortName) TypeName() string {
|
||||
return "inputBotAppShortName"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (i *InputBotAppShortName) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "inputBotAppShortName",
|
||||
ID: InputBotAppShortNameTypeID,
|
||||
}
|
||||
if i == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "BotID",
|
||||
SchemaName: "bot_id",
|
||||
},
|
||||
{
|
||||
Name: "ShortName",
|
||||
SchemaName: "short_name",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (i *InputBotAppShortName) Encode(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode inputBotAppShortName#908c0407 as nil")
|
||||
}
|
||||
b.PutID(InputBotAppShortNameTypeID)
|
||||
return i.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (i *InputBotAppShortName) EncodeBare(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode inputBotAppShortName#908c0407 as nil")
|
||||
}
|
||||
if i.BotID == nil {
|
||||
return fmt.Errorf("unable to encode inputBotAppShortName#908c0407: field bot_id is nil")
|
||||
}
|
||||
if err := i.BotID.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode inputBotAppShortName#908c0407: field bot_id: %w", err)
|
||||
}
|
||||
b.PutString(i.ShortName)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (i *InputBotAppShortName) Decode(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode inputBotAppShortName#908c0407 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(InputBotAppShortNameTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode inputBotAppShortName#908c0407: %w", err)
|
||||
}
|
||||
return i.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (i *InputBotAppShortName) DecodeBare(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode inputBotAppShortName#908c0407 to nil")
|
||||
}
|
||||
{
|
||||
value, err := DecodeInputUser(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode inputBotAppShortName#908c0407: field bot_id: %w", err)
|
||||
}
|
||||
i.BotID = value
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode inputBotAppShortName#908c0407: field short_name: %w", err)
|
||||
}
|
||||
i.ShortName = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetBotID returns value of BotID field.
|
||||
func (i *InputBotAppShortName) GetBotID() (value InputUserClass) {
|
||||
if i == nil {
|
||||
return
|
||||
}
|
||||
return i.BotID
|
||||
}
|
||||
|
||||
// GetShortName returns value of ShortName field.
|
||||
func (i *InputBotAppShortName) GetShortName() (value string) {
|
||||
if i == nil {
|
||||
return
|
||||
}
|
||||
return i.ShortName
|
||||
}
|
||||
|
||||
// InputBotAppClassName is schema name of InputBotAppClass.
|
||||
const InputBotAppClassName = "InputBotApp"
|
||||
|
||||
// InputBotAppClass represents InputBotApp generic type.
|
||||
//
|
||||
// See https://core.telegram.org/type/InputBotApp for reference.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// g, err := tg.DecodeInputBotApp(buf)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// switch v := g.(type) {
|
||||
// case *tg.InputBotAppID: // inputBotAppID#a920bd7a
|
||||
// case *tg.InputBotAppShortName: // inputBotAppShortName#908c0407
|
||||
// default: panic(v)
|
||||
// }
|
||||
type InputBotAppClass interface {
|
||||
bin.Encoder
|
||||
bin.Decoder
|
||||
bin.BareEncoder
|
||||
bin.BareDecoder
|
||||
construct() InputBotAppClass
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// DecodeInputBotApp implements binary de-serialization for InputBotAppClass.
|
||||
func DecodeInputBotApp(buf *bin.Buffer) (InputBotAppClass, error) {
|
||||
id, err := buf.PeekID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch id {
|
||||
case InputBotAppIDTypeID:
|
||||
// Decoding inputBotAppID#a920bd7a.
|
||||
v := InputBotAppID{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode InputBotAppClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
case InputBotAppShortNameTypeID:
|
||||
// Decoding inputBotAppShortName#908c0407.
|
||||
v := InputBotAppShortName{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode InputBotAppClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unable to decode InputBotAppClass: %w", bin.NewUnexpectedID(id))
|
||||
}
|
||||
}
|
||||
|
||||
// InputBotApp boxes the InputBotAppClass providing a helper.
|
||||
type InputBotAppBox struct {
|
||||
InputBotApp InputBotAppClass
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder for InputBotAppBox.
|
||||
func (b *InputBotAppBox) Decode(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("unable to decode InputBotAppBox to nil")
|
||||
}
|
||||
v, err := DecodeInputBotApp(buf)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode boxed value: %w", err)
|
||||
}
|
||||
b.InputBotApp = v
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode implements bin.Encode for InputBotAppBox.
|
||||
func (b *InputBotAppBox) Encode(buf *bin.Buffer) error {
|
||||
if b == nil || b.InputBotApp == nil {
|
||||
return fmt.Errorf("unable to encode InputBotAppClass as nil")
|
||||
}
|
||||
return b.InputBotApp.Encode(buf)
|
||||
}
|
||||
Reference in New Issue
Block a user