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,672 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// InputMessageID represents TL type `inputMessageID#a676a322`.
|
||||
// Message by ID
|
||||
//
|
||||
// See https://core.telegram.org/constructor/inputMessageID for reference.
|
||||
type InputMessageID struct {
|
||||
// Message ID
|
||||
ID int
|
||||
}
|
||||
|
||||
// InputMessageIDTypeID is TL type id of InputMessageID.
|
||||
const InputMessageIDTypeID = 0xa676a322
|
||||
|
||||
// construct implements constructor of InputMessageClass.
|
||||
func (i InputMessageID) construct() InputMessageClass { return &i }
|
||||
|
||||
// Ensuring interfaces in compile-time for InputMessageID.
|
||||
var (
|
||||
_ bin.Encoder = &InputMessageID{}
|
||||
_ bin.Decoder = &InputMessageID{}
|
||||
_ bin.BareEncoder = &InputMessageID{}
|
||||
_ bin.BareDecoder = &InputMessageID{}
|
||||
|
||||
_ InputMessageClass = &InputMessageID{}
|
||||
)
|
||||
|
||||
func (i *InputMessageID) Zero() bool {
|
||||
if i == nil {
|
||||
return true
|
||||
}
|
||||
if !(i.ID == 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (i *InputMessageID) String() string {
|
||||
if i == nil {
|
||||
return "InputMessageID(nil)"
|
||||
}
|
||||
type Alias InputMessageID
|
||||
return fmt.Sprintf("InputMessageID%+v", Alias(*i))
|
||||
}
|
||||
|
||||
// FillFrom fills InputMessageID from given interface.
|
||||
func (i *InputMessageID) FillFrom(from interface {
|
||||
GetID() (value int)
|
||||
}) {
|
||||
i.ID = from.GetID()
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*InputMessageID) TypeID() uint32 {
|
||||
return InputMessageIDTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*InputMessageID) TypeName() string {
|
||||
return "inputMessageID"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (i *InputMessageID) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "inputMessageID",
|
||||
ID: InputMessageIDTypeID,
|
||||
}
|
||||
if i == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "ID",
|
||||
SchemaName: "id",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (i *InputMessageID) Encode(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode inputMessageID#a676a322 as nil")
|
||||
}
|
||||
b.PutID(InputMessageIDTypeID)
|
||||
return i.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (i *InputMessageID) EncodeBare(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode inputMessageID#a676a322 as nil")
|
||||
}
|
||||
b.PutInt(i.ID)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (i *InputMessageID) Decode(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode inputMessageID#a676a322 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(InputMessageIDTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode inputMessageID#a676a322: %w", err)
|
||||
}
|
||||
return i.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (i *InputMessageID) DecodeBare(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode inputMessageID#a676a322 to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode inputMessageID#a676a322: field id: %w", err)
|
||||
}
|
||||
i.ID = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetID returns value of ID field.
|
||||
func (i *InputMessageID) GetID() (value int) {
|
||||
if i == nil {
|
||||
return
|
||||
}
|
||||
return i.ID
|
||||
}
|
||||
|
||||
// InputMessageReplyTo represents TL type `inputMessageReplyTo#bad88395`.
|
||||
// Message to which the specified message replies to
|
||||
//
|
||||
// See https://core.telegram.org/constructor/inputMessageReplyTo for reference.
|
||||
type InputMessageReplyTo struct {
|
||||
// ID of the message that replies to the message we need
|
||||
ID int
|
||||
}
|
||||
|
||||
// InputMessageReplyToTypeID is TL type id of InputMessageReplyTo.
|
||||
const InputMessageReplyToTypeID = 0xbad88395
|
||||
|
||||
// construct implements constructor of InputMessageClass.
|
||||
func (i InputMessageReplyTo) construct() InputMessageClass { return &i }
|
||||
|
||||
// Ensuring interfaces in compile-time for InputMessageReplyTo.
|
||||
var (
|
||||
_ bin.Encoder = &InputMessageReplyTo{}
|
||||
_ bin.Decoder = &InputMessageReplyTo{}
|
||||
_ bin.BareEncoder = &InputMessageReplyTo{}
|
||||
_ bin.BareDecoder = &InputMessageReplyTo{}
|
||||
|
||||
_ InputMessageClass = &InputMessageReplyTo{}
|
||||
)
|
||||
|
||||
func (i *InputMessageReplyTo) Zero() bool {
|
||||
if i == nil {
|
||||
return true
|
||||
}
|
||||
if !(i.ID == 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (i *InputMessageReplyTo) String() string {
|
||||
if i == nil {
|
||||
return "InputMessageReplyTo(nil)"
|
||||
}
|
||||
type Alias InputMessageReplyTo
|
||||
return fmt.Sprintf("InputMessageReplyTo%+v", Alias(*i))
|
||||
}
|
||||
|
||||
// FillFrom fills InputMessageReplyTo from given interface.
|
||||
func (i *InputMessageReplyTo) FillFrom(from interface {
|
||||
GetID() (value int)
|
||||
}) {
|
||||
i.ID = from.GetID()
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*InputMessageReplyTo) TypeID() uint32 {
|
||||
return InputMessageReplyToTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*InputMessageReplyTo) TypeName() string {
|
||||
return "inputMessageReplyTo"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (i *InputMessageReplyTo) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "inputMessageReplyTo",
|
||||
ID: InputMessageReplyToTypeID,
|
||||
}
|
||||
if i == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "ID",
|
||||
SchemaName: "id",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (i *InputMessageReplyTo) Encode(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode inputMessageReplyTo#bad88395 as nil")
|
||||
}
|
||||
b.PutID(InputMessageReplyToTypeID)
|
||||
return i.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (i *InputMessageReplyTo) EncodeBare(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode inputMessageReplyTo#bad88395 as nil")
|
||||
}
|
||||
b.PutInt(i.ID)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (i *InputMessageReplyTo) Decode(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode inputMessageReplyTo#bad88395 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(InputMessageReplyToTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode inputMessageReplyTo#bad88395: %w", err)
|
||||
}
|
||||
return i.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (i *InputMessageReplyTo) DecodeBare(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode inputMessageReplyTo#bad88395 to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode inputMessageReplyTo#bad88395: field id: %w", err)
|
||||
}
|
||||
i.ID = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetID returns value of ID field.
|
||||
func (i *InputMessageReplyTo) GetID() (value int) {
|
||||
if i == nil {
|
||||
return
|
||||
}
|
||||
return i.ID
|
||||
}
|
||||
|
||||
// InputMessagePinned represents TL type `inputMessagePinned#86872538`.
|
||||
// Pinned message
|
||||
//
|
||||
// See https://core.telegram.org/constructor/inputMessagePinned for reference.
|
||||
type InputMessagePinned struct {
|
||||
}
|
||||
|
||||
// InputMessagePinnedTypeID is TL type id of InputMessagePinned.
|
||||
const InputMessagePinnedTypeID = 0x86872538
|
||||
|
||||
// construct implements constructor of InputMessageClass.
|
||||
func (i InputMessagePinned) construct() InputMessageClass { return &i }
|
||||
|
||||
// Ensuring interfaces in compile-time for InputMessagePinned.
|
||||
var (
|
||||
_ bin.Encoder = &InputMessagePinned{}
|
||||
_ bin.Decoder = &InputMessagePinned{}
|
||||
_ bin.BareEncoder = &InputMessagePinned{}
|
||||
_ bin.BareDecoder = &InputMessagePinned{}
|
||||
|
||||
_ InputMessageClass = &InputMessagePinned{}
|
||||
)
|
||||
|
||||
func (i *InputMessagePinned) Zero() bool {
|
||||
if i == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (i *InputMessagePinned) String() string {
|
||||
if i == nil {
|
||||
return "InputMessagePinned(nil)"
|
||||
}
|
||||
type Alias InputMessagePinned
|
||||
return fmt.Sprintf("InputMessagePinned%+v", Alias(*i))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*InputMessagePinned) TypeID() uint32 {
|
||||
return InputMessagePinnedTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*InputMessagePinned) TypeName() string {
|
||||
return "inputMessagePinned"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (i *InputMessagePinned) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "inputMessagePinned",
|
||||
ID: InputMessagePinnedTypeID,
|
||||
}
|
||||
if i == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (i *InputMessagePinned) Encode(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode inputMessagePinned#86872538 as nil")
|
||||
}
|
||||
b.PutID(InputMessagePinnedTypeID)
|
||||
return i.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (i *InputMessagePinned) EncodeBare(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode inputMessagePinned#86872538 as nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (i *InputMessagePinned) Decode(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode inputMessagePinned#86872538 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(InputMessagePinnedTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode inputMessagePinned#86872538: %w", err)
|
||||
}
|
||||
return i.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (i *InputMessagePinned) DecodeBare(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode inputMessagePinned#86872538 to nil")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// InputMessageCallbackQuery represents TL type `inputMessageCallbackQuery#acfa1a7e`.
|
||||
// Used by bots for fetching information about the message that originated a callback
|
||||
// query
|
||||
//
|
||||
// See https://core.telegram.org/constructor/inputMessageCallbackQuery for reference.
|
||||
type InputMessageCallbackQuery struct {
|
||||
// Message ID
|
||||
ID int
|
||||
// Callback query ID
|
||||
QueryID int64
|
||||
}
|
||||
|
||||
// InputMessageCallbackQueryTypeID is TL type id of InputMessageCallbackQuery.
|
||||
const InputMessageCallbackQueryTypeID = 0xacfa1a7e
|
||||
|
||||
// construct implements constructor of InputMessageClass.
|
||||
func (i InputMessageCallbackQuery) construct() InputMessageClass { return &i }
|
||||
|
||||
// Ensuring interfaces in compile-time for InputMessageCallbackQuery.
|
||||
var (
|
||||
_ bin.Encoder = &InputMessageCallbackQuery{}
|
||||
_ bin.Decoder = &InputMessageCallbackQuery{}
|
||||
_ bin.BareEncoder = &InputMessageCallbackQuery{}
|
||||
_ bin.BareDecoder = &InputMessageCallbackQuery{}
|
||||
|
||||
_ InputMessageClass = &InputMessageCallbackQuery{}
|
||||
)
|
||||
|
||||
func (i *InputMessageCallbackQuery) Zero() bool {
|
||||
if i == nil {
|
||||
return true
|
||||
}
|
||||
if !(i.ID == 0) {
|
||||
return false
|
||||
}
|
||||
if !(i.QueryID == 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (i *InputMessageCallbackQuery) String() string {
|
||||
if i == nil {
|
||||
return "InputMessageCallbackQuery(nil)"
|
||||
}
|
||||
type Alias InputMessageCallbackQuery
|
||||
return fmt.Sprintf("InputMessageCallbackQuery%+v", Alias(*i))
|
||||
}
|
||||
|
||||
// FillFrom fills InputMessageCallbackQuery from given interface.
|
||||
func (i *InputMessageCallbackQuery) FillFrom(from interface {
|
||||
GetID() (value int)
|
||||
GetQueryID() (value int64)
|
||||
}) {
|
||||
i.ID = from.GetID()
|
||||
i.QueryID = from.GetQueryID()
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*InputMessageCallbackQuery) TypeID() uint32 {
|
||||
return InputMessageCallbackQueryTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*InputMessageCallbackQuery) TypeName() string {
|
||||
return "inputMessageCallbackQuery"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (i *InputMessageCallbackQuery) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "inputMessageCallbackQuery",
|
||||
ID: InputMessageCallbackQueryTypeID,
|
||||
}
|
||||
if i == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "ID",
|
||||
SchemaName: "id",
|
||||
},
|
||||
{
|
||||
Name: "QueryID",
|
||||
SchemaName: "query_id",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (i *InputMessageCallbackQuery) Encode(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode inputMessageCallbackQuery#acfa1a7e as nil")
|
||||
}
|
||||
b.PutID(InputMessageCallbackQueryTypeID)
|
||||
return i.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (i *InputMessageCallbackQuery) EncodeBare(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't encode inputMessageCallbackQuery#acfa1a7e as nil")
|
||||
}
|
||||
b.PutInt(i.ID)
|
||||
b.PutLong(i.QueryID)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (i *InputMessageCallbackQuery) Decode(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode inputMessageCallbackQuery#acfa1a7e to nil")
|
||||
}
|
||||
if err := b.ConsumeID(InputMessageCallbackQueryTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode inputMessageCallbackQuery#acfa1a7e: %w", err)
|
||||
}
|
||||
return i.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (i *InputMessageCallbackQuery) DecodeBare(b *bin.Buffer) error {
|
||||
if i == nil {
|
||||
return fmt.Errorf("can't decode inputMessageCallbackQuery#acfa1a7e to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.Int()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode inputMessageCallbackQuery#acfa1a7e: field id: %w", err)
|
||||
}
|
||||
i.ID = value
|
||||
}
|
||||
{
|
||||
value, err := b.Long()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode inputMessageCallbackQuery#acfa1a7e: field query_id: %w", err)
|
||||
}
|
||||
i.QueryID = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetID returns value of ID field.
|
||||
func (i *InputMessageCallbackQuery) GetID() (value int) {
|
||||
if i == nil {
|
||||
return
|
||||
}
|
||||
return i.ID
|
||||
}
|
||||
|
||||
// GetQueryID returns value of QueryID field.
|
||||
func (i *InputMessageCallbackQuery) GetQueryID() (value int64) {
|
||||
if i == nil {
|
||||
return
|
||||
}
|
||||
return i.QueryID
|
||||
}
|
||||
|
||||
// InputMessageClassName is schema name of InputMessageClass.
|
||||
const InputMessageClassName = "InputMessage"
|
||||
|
||||
// InputMessageClass represents InputMessage generic type.
|
||||
//
|
||||
// See https://core.telegram.org/type/InputMessage for reference.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// g, err := tg.DecodeInputMessage(buf)
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
// switch v := g.(type) {
|
||||
// case *tg.InputMessageID: // inputMessageID#a676a322
|
||||
// case *tg.InputMessageReplyTo: // inputMessageReplyTo#bad88395
|
||||
// case *tg.InputMessagePinned: // inputMessagePinned#86872538
|
||||
// case *tg.InputMessageCallbackQuery: // inputMessageCallbackQuery#acfa1a7e
|
||||
// default: panic(v)
|
||||
// }
|
||||
type InputMessageClass interface {
|
||||
bin.Encoder
|
||||
bin.Decoder
|
||||
bin.BareEncoder
|
||||
bin.BareDecoder
|
||||
construct() InputMessageClass
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// DecodeInputMessage implements binary de-serialization for InputMessageClass.
|
||||
func DecodeInputMessage(buf *bin.Buffer) (InputMessageClass, error) {
|
||||
id, err := buf.PeekID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch id {
|
||||
case InputMessageIDTypeID:
|
||||
// Decoding inputMessageID#a676a322.
|
||||
v := InputMessageID{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode InputMessageClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
case InputMessageReplyToTypeID:
|
||||
// Decoding inputMessageReplyTo#bad88395.
|
||||
v := InputMessageReplyTo{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode InputMessageClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
case InputMessagePinnedTypeID:
|
||||
// Decoding inputMessagePinned#86872538.
|
||||
v := InputMessagePinned{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode InputMessageClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
case InputMessageCallbackQueryTypeID:
|
||||
// Decoding inputMessageCallbackQuery#acfa1a7e.
|
||||
v := InputMessageCallbackQuery{}
|
||||
if err := v.Decode(buf); err != nil {
|
||||
return nil, fmt.Errorf("unable to decode InputMessageClass: %w", err)
|
||||
}
|
||||
return &v, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unable to decode InputMessageClass: %w", bin.NewUnexpectedID(id))
|
||||
}
|
||||
}
|
||||
|
||||
// InputMessage boxes the InputMessageClass providing a helper.
|
||||
type InputMessageBox struct {
|
||||
InputMessage InputMessageClass
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder for InputMessageBox.
|
||||
func (b *InputMessageBox) Decode(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("unable to decode InputMessageBox to nil")
|
||||
}
|
||||
v, err := DecodeInputMessage(buf)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode boxed value: %w", err)
|
||||
}
|
||||
b.InputMessage = v
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode implements bin.Encode for InputMessageBox.
|
||||
func (b *InputMessageBox) Encode(buf *bin.Buffer) error {
|
||||
if b == nil || b.InputMessage == nil {
|
||||
return fmt.Errorf("unable to encode InputMessageClass as nil")
|
||||
}
|
||||
return b.InputMessage.Encode(buf)
|
||||
}
|
||||
Reference in New Issue
Block a user