258 lines
6.1 KiB
Go
Generated
258 lines
6.1 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{}
|
|
)
|
|
|
|
// StoriesCreateAlbumRequest represents TL type `stories.createAlbum#a36396e5`.
|
|
// Creates a story album¹.
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/stories#story-albums
|
|
//
|
|
// See https://core.telegram.org/method/stories.createAlbum for reference.
|
|
type StoriesCreateAlbumRequest struct {
|
|
// The owned peer where to create the album.
|
|
Peer InputPeerClass
|
|
// Album name.
|
|
Title string
|
|
// Stories to add to the album.
|
|
Stories []int
|
|
}
|
|
|
|
// StoriesCreateAlbumRequestTypeID is TL type id of StoriesCreateAlbumRequest.
|
|
const StoriesCreateAlbumRequestTypeID = 0xa36396e5
|
|
|
|
// Ensuring interfaces in compile-time for StoriesCreateAlbumRequest.
|
|
var (
|
|
_ bin.Encoder = &StoriesCreateAlbumRequest{}
|
|
_ bin.Decoder = &StoriesCreateAlbumRequest{}
|
|
_ bin.BareEncoder = &StoriesCreateAlbumRequest{}
|
|
_ bin.BareDecoder = &StoriesCreateAlbumRequest{}
|
|
)
|
|
|
|
func (c *StoriesCreateAlbumRequest) Zero() bool {
|
|
if c == nil {
|
|
return true
|
|
}
|
|
if !(c.Peer == nil) {
|
|
return false
|
|
}
|
|
if !(c.Title == "") {
|
|
return false
|
|
}
|
|
if !(c.Stories == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (c *StoriesCreateAlbumRequest) String() string {
|
|
if c == nil {
|
|
return "StoriesCreateAlbumRequest(nil)"
|
|
}
|
|
type Alias StoriesCreateAlbumRequest
|
|
return fmt.Sprintf("StoriesCreateAlbumRequest%+v", Alias(*c))
|
|
}
|
|
|
|
// FillFrom fills StoriesCreateAlbumRequest from given interface.
|
|
func (c *StoriesCreateAlbumRequest) FillFrom(from interface {
|
|
GetPeer() (value InputPeerClass)
|
|
GetTitle() (value string)
|
|
GetStories() (value []int)
|
|
}) {
|
|
c.Peer = from.GetPeer()
|
|
c.Title = from.GetTitle()
|
|
c.Stories = from.GetStories()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*StoriesCreateAlbumRequest) TypeID() uint32 {
|
|
return StoriesCreateAlbumRequestTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*StoriesCreateAlbumRequest) TypeName() string {
|
|
return "stories.createAlbum"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (c *StoriesCreateAlbumRequest) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "stories.createAlbum",
|
|
ID: StoriesCreateAlbumRequestTypeID,
|
|
}
|
|
if c == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Peer",
|
|
SchemaName: "peer",
|
|
},
|
|
{
|
|
Name: "Title",
|
|
SchemaName: "title",
|
|
},
|
|
{
|
|
Name: "Stories",
|
|
SchemaName: "stories",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (c *StoriesCreateAlbumRequest) Encode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode stories.createAlbum#a36396e5 as nil")
|
|
}
|
|
b.PutID(StoriesCreateAlbumRequestTypeID)
|
|
return c.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (c *StoriesCreateAlbumRequest) EncodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode stories.createAlbum#a36396e5 as nil")
|
|
}
|
|
if c.Peer == nil {
|
|
return fmt.Errorf("unable to encode stories.createAlbum#a36396e5: field peer is nil")
|
|
}
|
|
if err := c.Peer.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode stories.createAlbum#a36396e5: field peer: %w", err)
|
|
}
|
|
b.PutString(c.Title)
|
|
b.PutVectorHeader(len(c.Stories))
|
|
for _, v := range c.Stories {
|
|
b.PutInt(v)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (c *StoriesCreateAlbumRequest) Decode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode stories.createAlbum#a36396e5 to nil")
|
|
}
|
|
if err := b.ConsumeID(StoriesCreateAlbumRequestTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode stories.createAlbum#a36396e5: %w", err)
|
|
}
|
|
return c.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (c *StoriesCreateAlbumRequest) DecodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode stories.createAlbum#a36396e5 to nil")
|
|
}
|
|
{
|
|
value, err := DecodeInputPeer(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode stories.createAlbum#a36396e5: field peer: %w", err)
|
|
}
|
|
c.Peer = value
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode stories.createAlbum#a36396e5: field title: %w", err)
|
|
}
|
|
c.Title = value
|
|
}
|
|
{
|
|
headerLen, err := b.VectorHeader()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode stories.createAlbum#a36396e5: field stories: %w", err)
|
|
}
|
|
|
|
if headerLen > 0 {
|
|
c.Stories = make([]int, 0, headerLen%bin.PreallocateLimit)
|
|
}
|
|
for idx := 0; idx < headerLen; idx++ {
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode stories.createAlbum#a36396e5: field stories: %w", err)
|
|
}
|
|
c.Stories = append(c.Stories, value)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetPeer returns value of Peer field.
|
|
func (c *StoriesCreateAlbumRequest) GetPeer() (value InputPeerClass) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Peer
|
|
}
|
|
|
|
// GetTitle returns value of Title field.
|
|
func (c *StoriesCreateAlbumRequest) GetTitle() (value string) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Title
|
|
}
|
|
|
|
// GetStories returns value of Stories field.
|
|
func (c *StoriesCreateAlbumRequest) GetStories() (value []int) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.Stories
|
|
}
|
|
|
|
// StoriesCreateAlbum invokes method stories.createAlbum#a36396e5 returning error if any.
|
|
// Creates a story album¹.
|
|
//
|
|
// Links:
|
|
// 1. https://core.telegram.org/api/stories#story-albums
|
|
//
|
|
// Possible errors:
|
|
//
|
|
// 400 PEER_ID_INVALID: The provided peer id is invalid.
|
|
//
|
|
// See https://core.telegram.org/method/stories.createAlbum for reference.
|
|
func (c *Client) StoriesCreateAlbum(ctx context.Context, request *StoriesCreateAlbumRequest) (*StoryAlbum, error) {
|
|
var result StoryAlbum
|
|
|
|
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
|
return nil, err
|
|
}
|
|
return &result, nil
|
|
}
|