424 lines
11 KiB
Go
Generated
424 lines
11 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{}
|
|
)
|
|
|
|
// StoriesAlbumsNotModified represents TL type `stories.albumsNotModified#564edaeb`.
|
|
// The story album list »¹ hasn't changed.
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/stories#story-albums
|
|
//
|
|
// See https://core.telegram.org/constructor/stories.albumsNotModified for reference.
|
|
type StoriesAlbumsNotModified struct {
|
|
}
|
|
|
|
// StoriesAlbumsNotModifiedTypeID is TL type id of StoriesAlbumsNotModified.
|
|
const StoriesAlbumsNotModifiedTypeID = 0x564edaeb
|
|
|
|
// construct implements constructor of StoriesAlbumsClass.
|
|
func (a StoriesAlbumsNotModified) construct() StoriesAlbumsClass { return &a }
|
|
|
|
// Ensuring interfaces in compile-time for StoriesAlbumsNotModified.
|
|
var (
|
|
_ bin.Encoder = &StoriesAlbumsNotModified{}
|
|
_ bin.Decoder = &StoriesAlbumsNotModified{}
|
|
_ bin.BareEncoder = &StoriesAlbumsNotModified{}
|
|
_ bin.BareDecoder = &StoriesAlbumsNotModified{}
|
|
|
|
_ StoriesAlbumsClass = &StoriesAlbumsNotModified{}
|
|
)
|
|
|
|
func (a *StoriesAlbumsNotModified) Zero() bool {
|
|
if a == nil {
|
|
return true
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (a *StoriesAlbumsNotModified) String() string {
|
|
if a == nil {
|
|
return "StoriesAlbumsNotModified(nil)"
|
|
}
|
|
type Alias StoriesAlbumsNotModified
|
|
return fmt.Sprintf("StoriesAlbumsNotModified%+v", Alias(*a))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*StoriesAlbumsNotModified) TypeID() uint32 {
|
|
return StoriesAlbumsNotModifiedTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*StoriesAlbumsNotModified) TypeName() string {
|
|
return "stories.albumsNotModified"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (a *StoriesAlbumsNotModified) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "stories.albumsNotModified",
|
|
ID: StoriesAlbumsNotModifiedTypeID,
|
|
}
|
|
if a == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (a *StoriesAlbumsNotModified) Encode(b *bin.Buffer) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't encode stories.albumsNotModified#564edaeb as nil")
|
|
}
|
|
b.PutID(StoriesAlbumsNotModifiedTypeID)
|
|
return a.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (a *StoriesAlbumsNotModified) EncodeBare(b *bin.Buffer) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't encode stories.albumsNotModified#564edaeb as nil")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (a *StoriesAlbumsNotModified) Decode(b *bin.Buffer) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't decode stories.albumsNotModified#564edaeb to nil")
|
|
}
|
|
if err := b.ConsumeID(StoriesAlbumsNotModifiedTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode stories.albumsNotModified#564edaeb: %w", err)
|
|
}
|
|
return a.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (a *StoriesAlbumsNotModified) DecodeBare(b *bin.Buffer) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't decode stories.albumsNotModified#564edaeb to nil")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// StoriesAlbums represents TL type `stories.albums#c3987a3a`.
|
|
// Story albums »¹.
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/stories#story-albums
|
|
//
|
|
// See https://core.telegram.org/constructor/stories.albums for reference.
|
|
type StoriesAlbums struct {
|
|
// Hash to pass to stories.getAlbums¹ to avoid returning any results if they haven't
|
|
// changed.
|
|
//
|
|
// Links:
|
|
// 1) https://core.telegram.org/method/stories.getAlbums
|
|
Hash int64
|
|
// The albums.
|
|
Albums []StoryAlbum
|
|
}
|
|
|
|
// StoriesAlbumsTypeID is TL type id of StoriesAlbums.
|
|
const StoriesAlbumsTypeID = 0xc3987a3a
|
|
|
|
// construct implements constructor of StoriesAlbumsClass.
|
|
func (a StoriesAlbums) construct() StoriesAlbumsClass { return &a }
|
|
|
|
// Ensuring interfaces in compile-time for StoriesAlbums.
|
|
var (
|
|
_ bin.Encoder = &StoriesAlbums{}
|
|
_ bin.Decoder = &StoriesAlbums{}
|
|
_ bin.BareEncoder = &StoriesAlbums{}
|
|
_ bin.BareDecoder = &StoriesAlbums{}
|
|
|
|
_ StoriesAlbumsClass = &StoriesAlbums{}
|
|
)
|
|
|
|
func (a *StoriesAlbums) Zero() bool {
|
|
if a == nil {
|
|
return true
|
|
}
|
|
if !(a.Hash == 0) {
|
|
return false
|
|
}
|
|
if !(a.Albums == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (a *StoriesAlbums) String() string {
|
|
if a == nil {
|
|
return "StoriesAlbums(nil)"
|
|
}
|
|
type Alias StoriesAlbums
|
|
return fmt.Sprintf("StoriesAlbums%+v", Alias(*a))
|
|
}
|
|
|
|
// FillFrom fills StoriesAlbums from given interface.
|
|
func (a *StoriesAlbums) FillFrom(from interface {
|
|
GetHash() (value int64)
|
|
GetAlbums() (value []StoryAlbum)
|
|
}) {
|
|
a.Hash = from.GetHash()
|
|
a.Albums = from.GetAlbums()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*StoriesAlbums) TypeID() uint32 {
|
|
return StoriesAlbumsTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*StoriesAlbums) TypeName() string {
|
|
return "stories.albums"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (a *StoriesAlbums) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "stories.albums",
|
|
ID: StoriesAlbumsTypeID,
|
|
}
|
|
if a == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Hash",
|
|
SchemaName: "hash",
|
|
},
|
|
{
|
|
Name: "Albums",
|
|
SchemaName: "albums",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (a *StoriesAlbums) Encode(b *bin.Buffer) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't encode stories.albums#c3987a3a as nil")
|
|
}
|
|
b.PutID(StoriesAlbumsTypeID)
|
|
return a.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (a *StoriesAlbums) EncodeBare(b *bin.Buffer) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't encode stories.albums#c3987a3a as nil")
|
|
}
|
|
b.PutLong(a.Hash)
|
|
b.PutVectorHeader(len(a.Albums))
|
|
for idx, v := range a.Albums {
|
|
if err := v.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode stories.albums#c3987a3a: field albums element with index %d: %w", idx, err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (a *StoriesAlbums) Decode(b *bin.Buffer) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't decode stories.albums#c3987a3a to nil")
|
|
}
|
|
if err := b.ConsumeID(StoriesAlbumsTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode stories.albums#c3987a3a: %w", err)
|
|
}
|
|
return a.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (a *StoriesAlbums) DecodeBare(b *bin.Buffer) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't decode stories.albums#c3987a3a to nil")
|
|
}
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode stories.albums#c3987a3a: field hash: %w", err)
|
|
}
|
|
a.Hash = value
|
|
}
|
|
{
|
|
headerLen, err := b.VectorHeader()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode stories.albums#c3987a3a: field albums: %w", err)
|
|
}
|
|
|
|
if headerLen > 0 {
|
|
a.Albums = make([]StoryAlbum, 0, headerLen%bin.PreallocateLimit)
|
|
}
|
|
for idx := 0; idx < headerLen; idx++ {
|
|
var value StoryAlbum
|
|
if err := value.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode stories.albums#c3987a3a: field albums: %w", err)
|
|
}
|
|
a.Albums = append(a.Albums, value)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetHash returns value of Hash field.
|
|
func (a *StoriesAlbums) GetHash() (value int64) {
|
|
if a == nil {
|
|
return
|
|
}
|
|
return a.Hash
|
|
}
|
|
|
|
// GetAlbums returns value of Albums field.
|
|
func (a *StoriesAlbums) GetAlbums() (value []StoryAlbum) {
|
|
if a == nil {
|
|
return
|
|
}
|
|
return a.Albums
|
|
}
|
|
|
|
// StoriesAlbumsClassName is schema name of StoriesAlbumsClass.
|
|
const StoriesAlbumsClassName = "stories.Albums"
|
|
|
|
// StoriesAlbumsClass represents stories.Albums generic type.
|
|
//
|
|
// See https://core.telegram.org/type/stories.Albums for reference.
|
|
//
|
|
// Example:
|
|
//
|
|
// g, err := tg.DecodeStoriesAlbums(buf)
|
|
// if err != nil {
|
|
// panic(err)
|
|
// }
|
|
// switch v := g.(type) {
|
|
// case *tg.StoriesAlbumsNotModified: // stories.albumsNotModified#564edaeb
|
|
// case *tg.StoriesAlbums: // stories.albums#c3987a3a
|
|
// default: panic(v)
|
|
// }
|
|
type StoriesAlbumsClass interface {
|
|
bin.Encoder
|
|
bin.Decoder
|
|
bin.BareEncoder
|
|
bin.BareDecoder
|
|
construct() StoriesAlbumsClass
|
|
|
|
// 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 StoriesAlbumsClass to StoriesAlbums.
|
|
AsModified() (*StoriesAlbums, bool)
|
|
}
|
|
|
|
// AsModified tries to map StoriesAlbumsNotModified to StoriesAlbums.
|
|
func (a *StoriesAlbumsNotModified) AsModified() (*StoriesAlbums, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
// AsModified tries to map StoriesAlbums to StoriesAlbums.
|
|
func (a *StoriesAlbums) AsModified() (*StoriesAlbums, bool) {
|
|
return a, true
|
|
}
|
|
|
|
// DecodeStoriesAlbums implements binary de-serialization for StoriesAlbumsClass.
|
|
func DecodeStoriesAlbums(buf *bin.Buffer) (StoriesAlbumsClass, error) {
|
|
id, err := buf.PeekID()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
switch id {
|
|
case StoriesAlbumsNotModifiedTypeID:
|
|
// Decoding stories.albumsNotModified#564edaeb.
|
|
v := StoriesAlbumsNotModified{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode StoriesAlbumsClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case StoriesAlbumsTypeID:
|
|
// Decoding stories.albums#c3987a3a.
|
|
v := StoriesAlbums{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode StoriesAlbumsClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
default:
|
|
return nil, fmt.Errorf("unable to decode StoriesAlbumsClass: %w", bin.NewUnexpectedID(id))
|
|
}
|
|
}
|
|
|
|
// StoriesAlbums boxes the StoriesAlbumsClass providing a helper.
|
|
type StoriesAlbumsBox struct {
|
|
Albums StoriesAlbumsClass
|
|
}
|
|
|
|
// Decode implements bin.Decoder for StoriesAlbumsBox.
|
|
func (b *StoriesAlbumsBox) Decode(buf *bin.Buffer) error {
|
|
if b == nil {
|
|
return fmt.Errorf("unable to decode StoriesAlbumsBox to nil")
|
|
}
|
|
v, err := DecodeStoriesAlbums(buf)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode boxed value: %w", err)
|
|
}
|
|
b.Albums = v
|
|
return nil
|
|
}
|
|
|
|
// Encode implements bin.Encode for StoriesAlbumsBox.
|
|
func (b *StoriesAlbumsBox) Encode(buf *bin.Buffer) error {
|
|
if b == nil || b.Albums == nil {
|
|
return fmt.Errorf("unable to encode StoriesAlbumsClass as nil")
|
|
}
|
|
return b.Albums.Encode(buf)
|
|
}
|