579 lines
15 KiB
Go
Generated
579 lines
15 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{}
|
|
)
|
|
|
|
// InputSavedStarGiftUser represents TL type `inputSavedStarGiftUser#69279795`.
|
|
// A gift received in a private chat with another user.
|
|
//
|
|
// See https://core.telegram.org/constructor/inputSavedStarGiftUser for reference.
|
|
type InputSavedStarGiftUser struct {
|
|
// ID of the messageService¹ with the messageActionStarGift² with the gift.
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/constructor/messageService
|
|
// 2) https://core.telegram.org/constructor/messageActionStarGift
|
|
MsgID int
|
|
}
|
|
|
|
// InputSavedStarGiftUserTypeID is TL type id of InputSavedStarGiftUser.
|
|
const InputSavedStarGiftUserTypeID = 0x69279795
|
|
|
|
// construct implements constructor of InputSavedStarGiftClass.
|
|
func (i InputSavedStarGiftUser) construct() InputSavedStarGiftClass { return &i }
|
|
|
|
// Ensuring interfaces in compile-time for InputSavedStarGiftUser.
|
|
var (
|
|
_ bin.Encoder = &InputSavedStarGiftUser{}
|
|
_ bin.Decoder = &InputSavedStarGiftUser{}
|
|
_ bin.BareEncoder = &InputSavedStarGiftUser{}
|
|
_ bin.BareDecoder = &InputSavedStarGiftUser{}
|
|
|
|
_ InputSavedStarGiftClass = &InputSavedStarGiftUser{}
|
|
)
|
|
|
|
func (i *InputSavedStarGiftUser) Zero() bool {
|
|
if i == nil {
|
|
return true
|
|
}
|
|
if !(i.MsgID == 0) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (i *InputSavedStarGiftUser) String() string {
|
|
if i == nil {
|
|
return "InputSavedStarGiftUser(nil)"
|
|
}
|
|
type Alias InputSavedStarGiftUser
|
|
return fmt.Sprintf("InputSavedStarGiftUser%+v", Alias(*i))
|
|
}
|
|
|
|
// FillFrom fills InputSavedStarGiftUser from given interface.
|
|
func (i *InputSavedStarGiftUser) FillFrom(from interface {
|
|
GetMsgID() (value int)
|
|
}) {
|
|
i.MsgID = from.GetMsgID()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*InputSavedStarGiftUser) TypeID() uint32 {
|
|
return InputSavedStarGiftUserTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*InputSavedStarGiftUser) TypeName() string {
|
|
return "inputSavedStarGiftUser"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (i *InputSavedStarGiftUser) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "inputSavedStarGiftUser",
|
|
ID: InputSavedStarGiftUserTypeID,
|
|
}
|
|
if i == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "MsgID",
|
|
SchemaName: "msg_id",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (i *InputSavedStarGiftUser) Encode(b *bin.Buffer) error {
|
|
if i == nil {
|
|
return fmt.Errorf("can't encode inputSavedStarGiftUser#69279795 as nil")
|
|
}
|
|
b.PutID(InputSavedStarGiftUserTypeID)
|
|
return i.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (i *InputSavedStarGiftUser) EncodeBare(b *bin.Buffer) error {
|
|
if i == nil {
|
|
return fmt.Errorf("can't encode inputSavedStarGiftUser#69279795 as nil")
|
|
}
|
|
b.PutInt(i.MsgID)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (i *InputSavedStarGiftUser) Decode(b *bin.Buffer) error {
|
|
if i == nil {
|
|
return fmt.Errorf("can't decode inputSavedStarGiftUser#69279795 to nil")
|
|
}
|
|
if err := b.ConsumeID(InputSavedStarGiftUserTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode inputSavedStarGiftUser#69279795: %w", err)
|
|
}
|
|
return i.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (i *InputSavedStarGiftUser) DecodeBare(b *bin.Buffer) error {
|
|
if i == nil {
|
|
return fmt.Errorf("can't decode inputSavedStarGiftUser#69279795 to nil")
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode inputSavedStarGiftUser#69279795: field msg_id: %w", err)
|
|
}
|
|
i.MsgID = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetMsgID returns value of MsgID field.
|
|
func (i *InputSavedStarGiftUser) GetMsgID() (value int) {
|
|
if i == nil {
|
|
return
|
|
}
|
|
return i.MsgID
|
|
}
|
|
|
|
// InputSavedStarGiftChat represents TL type `inputSavedStarGiftChat#f101aa7f`.
|
|
// A gift received by a channel we own.
|
|
//
|
|
// See https://core.telegram.org/constructor/inputSavedStarGiftChat for reference.
|
|
type InputSavedStarGiftChat struct {
|
|
// The channel.
|
|
Peer InputPeerClass
|
|
// ID of the gift, must be the saved_id of a
|
|
// messageActionStarGift¹/messageActionStarGiftUnique² constructor.
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/constructor/messageActionStarGift
|
|
// 2) https://core.telegram.org/constructor/messageActionStarGiftUnique
|
|
SavedID int64
|
|
}
|
|
|
|
// InputSavedStarGiftChatTypeID is TL type id of InputSavedStarGiftChat.
|
|
const InputSavedStarGiftChatTypeID = 0xf101aa7f
|
|
|
|
// construct implements constructor of InputSavedStarGiftClass.
|
|
func (i InputSavedStarGiftChat) construct() InputSavedStarGiftClass { return &i }
|
|
|
|
// Ensuring interfaces in compile-time for InputSavedStarGiftChat.
|
|
var (
|
|
_ bin.Encoder = &InputSavedStarGiftChat{}
|
|
_ bin.Decoder = &InputSavedStarGiftChat{}
|
|
_ bin.BareEncoder = &InputSavedStarGiftChat{}
|
|
_ bin.BareDecoder = &InputSavedStarGiftChat{}
|
|
|
|
_ InputSavedStarGiftClass = &InputSavedStarGiftChat{}
|
|
)
|
|
|
|
func (i *InputSavedStarGiftChat) Zero() bool {
|
|
if i == nil {
|
|
return true
|
|
}
|
|
if !(i.Peer == nil) {
|
|
return false
|
|
}
|
|
if !(i.SavedID == 0) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (i *InputSavedStarGiftChat) String() string {
|
|
if i == nil {
|
|
return "InputSavedStarGiftChat(nil)"
|
|
}
|
|
type Alias InputSavedStarGiftChat
|
|
return fmt.Sprintf("InputSavedStarGiftChat%+v", Alias(*i))
|
|
}
|
|
|
|
// FillFrom fills InputSavedStarGiftChat from given interface.
|
|
func (i *InputSavedStarGiftChat) FillFrom(from interface {
|
|
GetPeer() (value InputPeerClass)
|
|
GetSavedID() (value int64)
|
|
}) {
|
|
i.Peer = from.GetPeer()
|
|
i.SavedID = from.GetSavedID()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*InputSavedStarGiftChat) TypeID() uint32 {
|
|
return InputSavedStarGiftChatTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*InputSavedStarGiftChat) TypeName() string {
|
|
return "inputSavedStarGiftChat"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (i *InputSavedStarGiftChat) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "inputSavedStarGiftChat",
|
|
ID: InputSavedStarGiftChatTypeID,
|
|
}
|
|
if i == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Peer",
|
|
SchemaName: "peer",
|
|
},
|
|
{
|
|
Name: "SavedID",
|
|
SchemaName: "saved_id",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (i *InputSavedStarGiftChat) Encode(b *bin.Buffer) error {
|
|
if i == nil {
|
|
return fmt.Errorf("can't encode inputSavedStarGiftChat#f101aa7f as nil")
|
|
}
|
|
b.PutID(InputSavedStarGiftChatTypeID)
|
|
return i.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (i *InputSavedStarGiftChat) EncodeBare(b *bin.Buffer) error {
|
|
if i == nil {
|
|
return fmt.Errorf("can't encode inputSavedStarGiftChat#f101aa7f as nil")
|
|
}
|
|
if i.Peer == nil {
|
|
return fmt.Errorf("unable to encode inputSavedStarGiftChat#f101aa7f: field peer is nil")
|
|
}
|
|
if err := i.Peer.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode inputSavedStarGiftChat#f101aa7f: field peer: %w", err)
|
|
}
|
|
b.PutLong(i.SavedID)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (i *InputSavedStarGiftChat) Decode(b *bin.Buffer) error {
|
|
if i == nil {
|
|
return fmt.Errorf("can't decode inputSavedStarGiftChat#f101aa7f to nil")
|
|
}
|
|
if err := b.ConsumeID(InputSavedStarGiftChatTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode inputSavedStarGiftChat#f101aa7f: %w", err)
|
|
}
|
|
return i.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (i *InputSavedStarGiftChat) DecodeBare(b *bin.Buffer) error {
|
|
if i == nil {
|
|
return fmt.Errorf("can't decode inputSavedStarGiftChat#f101aa7f to nil")
|
|
}
|
|
{
|
|
value, err := DecodeInputPeer(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode inputSavedStarGiftChat#f101aa7f: field peer: %w", err)
|
|
}
|
|
i.Peer = value
|
|
}
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode inputSavedStarGiftChat#f101aa7f: field saved_id: %w", err)
|
|
}
|
|
i.SavedID = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetPeer returns value of Peer field.
|
|
func (i *InputSavedStarGiftChat) GetPeer() (value InputPeerClass) {
|
|
if i == nil {
|
|
return
|
|
}
|
|
return i.Peer
|
|
}
|
|
|
|
// GetSavedID returns value of SavedID field.
|
|
func (i *InputSavedStarGiftChat) GetSavedID() (value int64) {
|
|
if i == nil {
|
|
return
|
|
}
|
|
return i.SavedID
|
|
}
|
|
|
|
// InputSavedStarGiftSlug represents TL type `inputSavedStarGiftSlug#2085c238`.
|
|
// Points to a collectible gift obtained from a collectible gift link »¹.
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/links#collectible-gift-link
|
|
//
|
|
// See https://core.telegram.org/constructor/inputSavedStarGiftSlug for reference.
|
|
type InputSavedStarGiftSlug struct {
|
|
// Slug from the link.
|
|
Slug string
|
|
}
|
|
|
|
// InputSavedStarGiftSlugTypeID is TL type id of InputSavedStarGiftSlug.
|
|
const InputSavedStarGiftSlugTypeID = 0x2085c238
|
|
|
|
// construct implements constructor of InputSavedStarGiftClass.
|
|
func (i InputSavedStarGiftSlug) construct() InputSavedStarGiftClass { return &i }
|
|
|
|
// Ensuring interfaces in compile-time for InputSavedStarGiftSlug.
|
|
var (
|
|
_ bin.Encoder = &InputSavedStarGiftSlug{}
|
|
_ bin.Decoder = &InputSavedStarGiftSlug{}
|
|
_ bin.BareEncoder = &InputSavedStarGiftSlug{}
|
|
_ bin.BareDecoder = &InputSavedStarGiftSlug{}
|
|
|
|
_ InputSavedStarGiftClass = &InputSavedStarGiftSlug{}
|
|
)
|
|
|
|
func (i *InputSavedStarGiftSlug) Zero() bool {
|
|
if i == nil {
|
|
return true
|
|
}
|
|
if !(i.Slug == "") {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (i *InputSavedStarGiftSlug) String() string {
|
|
if i == nil {
|
|
return "InputSavedStarGiftSlug(nil)"
|
|
}
|
|
type Alias InputSavedStarGiftSlug
|
|
return fmt.Sprintf("InputSavedStarGiftSlug%+v", Alias(*i))
|
|
}
|
|
|
|
// FillFrom fills InputSavedStarGiftSlug from given interface.
|
|
func (i *InputSavedStarGiftSlug) FillFrom(from interface {
|
|
GetSlug() (value string)
|
|
}) {
|
|
i.Slug = from.GetSlug()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*InputSavedStarGiftSlug) TypeID() uint32 {
|
|
return InputSavedStarGiftSlugTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*InputSavedStarGiftSlug) TypeName() string {
|
|
return "inputSavedStarGiftSlug"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (i *InputSavedStarGiftSlug) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "inputSavedStarGiftSlug",
|
|
ID: InputSavedStarGiftSlugTypeID,
|
|
}
|
|
if i == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Slug",
|
|
SchemaName: "slug",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (i *InputSavedStarGiftSlug) Encode(b *bin.Buffer) error {
|
|
if i == nil {
|
|
return fmt.Errorf("can't encode inputSavedStarGiftSlug#2085c238 as nil")
|
|
}
|
|
b.PutID(InputSavedStarGiftSlugTypeID)
|
|
return i.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (i *InputSavedStarGiftSlug) EncodeBare(b *bin.Buffer) error {
|
|
if i == nil {
|
|
return fmt.Errorf("can't encode inputSavedStarGiftSlug#2085c238 as nil")
|
|
}
|
|
b.PutString(i.Slug)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (i *InputSavedStarGiftSlug) Decode(b *bin.Buffer) error {
|
|
if i == nil {
|
|
return fmt.Errorf("can't decode inputSavedStarGiftSlug#2085c238 to nil")
|
|
}
|
|
if err := b.ConsumeID(InputSavedStarGiftSlugTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode inputSavedStarGiftSlug#2085c238: %w", err)
|
|
}
|
|
return i.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (i *InputSavedStarGiftSlug) DecodeBare(b *bin.Buffer) error {
|
|
if i == nil {
|
|
return fmt.Errorf("can't decode inputSavedStarGiftSlug#2085c238 to nil")
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode inputSavedStarGiftSlug#2085c238: field slug: %w", err)
|
|
}
|
|
i.Slug = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetSlug returns value of Slug field.
|
|
func (i *InputSavedStarGiftSlug) GetSlug() (value string) {
|
|
if i == nil {
|
|
return
|
|
}
|
|
return i.Slug
|
|
}
|
|
|
|
// InputSavedStarGiftClassName is schema name of InputSavedStarGiftClass.
|
|
const InputSavedStarGiftClassName = "InputSavedStarGift"
|
|
|
|
// InputSavedStarGiftClass represents InputSavedStarGift generic type.
|
|
//
|
|
// See https://core.telegram.org/type/InputSavedStarGift for reference.
|
|
//
|
|
// Example:
|
|
//
|
|
// g, err := tg.DecodeInputSavedStarGift(buf)
|
|
// if err != nil {
|
|
// panic(err)
|
|
// }
|
|
// switch v := g.(type) {
|
|
// case *tg.InputSavedStarGiftUser: // inputSavedStarGiftUser#69279795
|
|
// case *tg.InputSavedStarGiftChat: // inputSavedStarGiftChat#f101aa7f
|
|
// case *tg.InputSavedStarGiftSlug: // inputSavedStarGiftSlug#2085c238
|
|
// default: panic(v)
|
|
// }
|
|
type InputSavedStarGiftClass interface {
|
|
bin.Encoder
|
|
bin.Decoder
|
|
bin.BareEncoder
|
|
bin.BareDecoder
|
|
construct() InputSavedStarGiftClass
|
|
|
|
// 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
|
|
}
|
|
|
|
// DecodeInputSavedStarGift implements binary de-serialization for InputSavedStarGiftClass.
|
|
func DecodeInputSavedStarGift(buf *bin.Buffer) (InputSavedStarGiftClass, error) {
|
|
id, err := buf.PeekID()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
switch id {
|
|
case InputSavedStarGiftUserTypeID:
|
|
// Decoding inputSavedStarGiftUser#69279795.
|
|
v := InputSavedStarGiftUser{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode InputSavedStarGiftClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case InputSavedStarGiftChatTypeID:
|
|
// Decoding inputSavedStarGiftChat#f101aa7f.
|
|
v := InputSavedStarGiftChat{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode InputSavedStarGiftClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case InputSavedStarGiftSlugTypeID:
|
|
// Decoding inputSavedStarGiftSlug#2085c238.
|
|
v := InputSavedStarGiftSlug{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode InputSavedStarGiftClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
default:
|
|
return nil, fmt.Errorf("unable to decode InputSavedStarGiftClass: %w", bin.NewUnexpectedID(id))
|
|
}
|
|
}
|
|
|
|
// InputSavedStarGift boxes the InputSavedStarGiftClass providing a helper.
|
|
type InputSavedStarGiftBox struct {
|
|
InputSavedStarGift InputSavedStarGiftClass
|
|
}
|
|
|
|
// Decode implements bin.Decoder for InputSavedStarGiftBox.
|
|
func (b *InputSavedStarGiftBox) Decode(buf *bin.Buffer) error {
|
|
if b == nil {
|
|
return fmt.Errorf("unable to decode InputSavedStarGiftBox to nil")
|
|
}
|
|
v, err := DecodeInputSavedStarGift(buf)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode boxed value: %w", err)
|
|
}
|
|
b.InputSavedStarGift = v
|
|
return nil
|
|
}
|
|
|
|
// Encode implements bin.Encode for InputSavedStarGiftBox.
|
|
func (b *InputSavedStarGiftBox) Encode(buf *bin.Buffer) error {
|
|
if b == nil || b.InputSavedStarGift == nil {
|
|
return fmt.Errorf("unable to encode InputSavedStarGiftClass as nil")
|
|
}
|
|
return b.InputSavedStarGift.Encode(buf)
|
|
}
|