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
421 lines
9.9 KiB
Go
421 lines
9.9 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{}
|
|
)
|
|
|
|
// EmojiListNotModified represents TL type `emojiListNotModified#481eadfa`.
|
|
// The list of custom emojis¹ hasn't changed.
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/custom-emoji
|
|
//
|
|
// See https://core.telegram.org/constructor/emojiListNotModified for reference.
|
|
type EmojiListNotModified struct {
|
|
}
|
|
|
|
// EmojiListNotModifiedTypeID is TL type id of EmojiListNotModified.
|
|
const EmojiListNotModifiedTypeID = 0x481eadfa
|
|
|
|
// construct implements constructor of EmojiListClass.
|
|
func (e EmojiListNotModified) construct() EmojiListClass { return &e }
|
|
|
|
// Ensuring interfaces in compile-time for EmojiListNotModified.
|
|
var (
|
|
_ bin.Encoder = &EmojiListNotModified{}
|
|
_ bin.Decoder = &EmojiListNotModified{}
|
|
_ bin.BareEncoder = &EmojiListNotModified{}
|
|
_ bin.BareDecoder = &EmojiListNotModified{}
|
|
|
|
_ EmojiListClass = &EmojiListNotModified{}
|
|
)
|
|
|
|
func (e *EmojiListNotModified) Zero() bool {
|
|
if e == nil {
|
|
return true
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (e *EmojiListNotModified) String() string {
|
|
if e == nil {
|
|
return "EmojiListNotModified(nil)"
|
|
}
|
|
type Alias EmojiListNotModified
|
|
return fmt.Sprintf("EmojiListNotModified%+v", Alias(*e))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*EmojiListNotModified) TypeID() uint32 {
|
|
return EmojiListNotModifiedTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*EmojiListNotModified) TypeName() string {
|
|
return "emojiListNotModified"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (e *EmojiListNotModified) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "emojiListNotModified",
|
|
ID: EmojiListNotModifiedTypeID,
|
|
}
|
|
if e == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (e *EmojiListNotModified) Encode(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't encode emojiListNotModified#481eadfa as nil")
|
|
}
|
|
b.PutID(EmojiListNotModifiedTypeID)
|
|
return e.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (e *EmojiListNotModified) EncodeBare(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't encode emojiListNotModified#481eadfa as nil")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (e *EmojiListNotModified) Decode(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't decode emojiListNotModified#481eadfa to nil")
|
|
}
|
|
if err := b.ConsumeID(EmojiListNotModifiedTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode emojiListNotModified#481eadfa: %w", err)
|
|
}
|
|
return e.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (e *EmojiListNotModified) DecodeBare(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't decode emojiListNotModified#481eadfa to nil")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EmojiList represents TL type `emojiList#7a1e11d1`.
|
|
// Represents a list of custom emojis¹.
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/custom-emoji
|
|
//
|
|
// See https://core.telegram.org/constructor/emojiList for reference.
|
|
type EmojiList struct {
|
|
// Hash used for caching, for more info click here¹
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/api/offsets#hash-generation
|
|
Hash int64
|
|
// Custom emoji IDs
|
|
DocumentID []int64
|
|
}
|
|
|
|
// EmojiListTypeID is TL type id of EmojiList.
|
|
const EmojiListTypeID = 0x7a1e11d1
|
|
|
|
// construct implements constructor of EmojiListClass.
|
|
func (e EmojiList) construct() EmojiListClass { return &e }
|
|
|
|
// Ensuring interfaces in compile-time for EmojiList.
|
|
var (
|
|
_ bin.Encoder = &EmojiList{}
|
|
_ bin.Decoder = &EmojiList{}
|
|
_ bin.BareEncoder = &EmojiList{}
|
|
_ bin.BareDecoder = &EmojiList{}
|
|
|
|
_ EmojiListClass = &EmojiList{}
|
|
)
|
|
|
|
func (e *EmojiList) Zero() bool {
|
|
if e == nil {
|
|
return true
|
|
}
|
|
if !(e.Hash == 0) {
|
|
return false
|
|
}
|
|
if !(e.DocumentID == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (e *EmojiList) String() string {
|
|
if e == nil {
|
|
return "EmojiList(nil)"
|
|
}
|
|
type Alias EmojiList
|
|
return fmt.Sprintf("EmojiList%+v", Alias(*e))
|
|
}
|
|
|
|
// FillFrom fills EmojiList from given interface.
|
|
func (e *EmojiList) FillFrom(from interface {
|
|
GetHash() (value int64)
|
|
GetDocumentID() (value []int64)
|
|
}) {
|
|
e.Hash = from.GetHash()
|
|
e.DocumentID = from.GetDocumentID()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*EmojiList) TypeID() uint32 {
|
|
return EmojiListTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*EmojiList) TypeName() string {
|
|
return "emojiList"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (e *EmojiList) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "emojiList",
|
|
ID: EmojiListTypeID,
|
|
}
|
|
if e == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Hash",
|
|
SchemaName: "hash",
|
|
},
|
|
{
|
|
Name: "DocumentID",
|
|
SchemaName: "document_id",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (e *EmojiList) Encode(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't encode emojiList#7a1e11d1 as nil")
|
|
}
|
|
b.PutID(EmojiListTypeID)
|
|
return e.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (e *EmojiList) EncodeBare(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't encode emojiList#7a1e11d1 as nil")
|
|
}
|
|
b.PutLong(e.Hash)
|
|
b.PutVectorHeader(len(e.DocumentID))
|
|
for _, v := range e.DocumentID {
|
|
b.PutLong(v)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (e *EmojiList) Decode(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't decode emojiList#7a1e11d1 to nil")
|
|
}
|
|
if err := b.ConsumeID(EmojiListTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode emojiList#7a1e11d1: %w", err)
|
|
}
|
|
return e.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (e *EmojiList) DecodeBare(b *bin.Buffer) error {
|
|
if e == nil {
|
|
return fmt.Errorf("can't decode emojiList#7a1e11d1 to nil")
|
|
}
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode emojiList#7a1e11d1: field hash: %w", err)
|
|
}
|
|
e.Hash = value
|
|
}
|
|
{
|
|
headerLen, err := b.VectorHeader()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode emojiList#7a1e11d1: field document_id: %w", err)
|
|
}
|
|
|
|
if headerLen > 0 {
|
|
e.DocumentID = make([]int64, 0, headerLen%bin.PreallocateLimit)
|
|
}
|
|
for idx := 0; idx < headerLen; idx++ {
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode emojiList#7a1e11d1: field document_id: %w", err)
|
|
}
|
|
e.DocumentID = append(e.DocumentID, value)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetHash returns value of Hash field.
|
|
func (e *EmojiList) GetHash() (value int64) {
|
|
if e == nil {
|
|
return
|
|
}
|
|
return e.Hash
|
|
}
|
|
|
|
// GetDocumentID returns value of DocumentID field.
|
|
func (e *EmojiList) GetDocumentID() (value []int64) {
|
|
if e == nil {
|
|
return
|
|
}
|
|
return e.DocumentID
|
|
}
|
|
|
|
// EmojiListClassName is schema name of EmojiListClass.
|
|
const EmojiListClassName = "EmojiList"
|
|
|
|
// EmojiListClass represents EmojiList generic type.
|
|
//
|
|
// See https://core.telegram.org/type/EmojiList for reference.
|
|
//
|
|
// Example:
|
|
//
|
|
// g, err := tg.DecodeEmojiList(buf)
|
|
// if err != nil {
|
|
// panic(err)
|
|
// }
|
|
// switch v := g.(type) {
|
|
// case *tg.EmojiListNotModified: // emojiListNotModified#481eadfa
|
|
// case *tg.EmojiList: // emojiList#7a1e11d1
|
|
// default: panic(v)
|
|
// }
|
|
type EmojiListClass interface {
|
|
bin.Encoder
|
|
bin.Decoder
|
|
bin.BareEncoder
|
|
bin.BareDecoder
|
|
construct() EmojiListClass
|
|
|
|
// 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
|
|
|
|
// AsModified tries to map EmojiListClass to EmojiList.
|
|
AsModified() (*EmojiList, bool)
|
|
}
|
|
|
|
// AsModified tries to map EmojiListNotModified to EmojiList.
|
|
func (e *EmojiListNotModified) AsModified() (*EmojiList, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
// AsModified tries to map EmojiList to EmojiList.
|
|
func (e *EmojiList) AsModified() (*EmojiList, bool) {
|
|
return e, true
|
|
}
|
|
|
|
// DecodeEmojiList implements binary de-serialization for EmojiListClass.
|
|
func DecodeEmojiList(buf *bin.Buffer) (EmojiListClass, error) {
|
|
id, err := buf.PeekID()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
switch id {
|
|
case EmojiListNotModifiedTypeID:
|
|
// Decoding emojiListNotModified#481eadfa.
|
|
v := EmojiListNotModified{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode EmojiListClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case EmojiListTypeID:
|
|
// Decoding emojiList#7a1e11d1.
|
|
v := EmojiList{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode EmojiListClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
default:
|
|
return nil, fmt.Errorf("unable to decode EmojiListClass: %w", bin.NewUnexpectedID(id))
|
|
}
|
|
}
|
|
|
|
// EmojiList boxes the EmojiListClass providing a helper.
|
|
type EmojiListBox struct {
|
|
EmojiList EmojiListClass
|
|
}
|
|
|
|
// Decode implements bin.Decoder for EmojiListBox.
|
|
func (b *EmojiListBox) Decode(buf *bin.Buffer) error {
|
|
if b == nil {
|
|
return fmt.Errorf("unable to decode EmojiListBox to nil")
|
|
}
|
|
v, err := DecodeEmojiList(buf)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode boxed value: %w", err)
|
|
}
|
|
b.EmojiList = v
|
|
return nil
|
|
}
|
|
|
|
// Encode implements bin.Encode for EmojiListBox.
|
|
func (b *EmojiListBox) Encode(buf *bin.Buffer) error {
|
|
if b == nil || b.EmojiList == nil {
|
|
return fmt.Errorf("unable to encode EmojiListClass as nil")
|
|
}
|
|
return b.EmojiList.Encode(buf)
|
|
}
|