Files
mautrix-telegram/pkg/gotd/tg/tl_account_get_wall_papers_gen.go
T
2025-06-27 20:03:37 -07:00

188 lines
4.6 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{}
)
// AccountGetWallPapersRequest represents TL type `account.getWallPapers#7967d36`.
// Returns a list of available wallpapers¹.
//
// Links:
// 1. https://core.telegram.org/api/wallpapers
//
// See https://core.telegram.org/method/account.getWallPapers for reference.
type AccountGetWallPapersRequest struct {
// Hash used for caching, for more info click here¹.
//
// Links:
// 1) https://core.telegram.org/api/offsets#hash-generation
Hash int64
}
// AccountGetWallPapersRequestTypeID is TL type id of AccountGetWallPapersRequest.
const AccountGetWallPapersRequestTypeID = 0x7967d36
// Ensuring interfaces in compile-time for AccountGetWallPapersRequest.
var (
_ bin.Encoder = &AccountGetWallPapersRequest{}
_ bin.Decoder = &AccountGetWallPapersRequest{}
_ bin.BareEncoder = &AccountGetWallPapersRequest{}
_ bin.BareDecoder = &AccountGetWallPapersRequest{}
)
func (g *AccountGetWallPapersRequest) Zero() bool {
if g == nil {
return true
}
if !(g.Hash == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (g *AccountGetWallPapersRequest) String() string {
if g == nil {
return "AccountGetWallPapersRequest(nil)"
}
type Alias AccountGetWallPapersRequest
return fmt.Sprintf("AccountGetWallPapersRequest%+v", Alias(*g))
}
// FillFrom fills AccountGetWallPapersRequest from given interface.
func (g *AccountGetWallPapersRequest) FillFrom(from interface {
GetHash() (value int64)
}) {
g.Hash = from.GetHash()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*AccountGetWallPapersRequest) TypeID() uint32 {
return AccountGetWallPapersRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*AccountGetWallPapersRequest) TypeName() string {
return "account.getWallPapers"
}
// TypeInfo returns info about TL type.
func (g *AccountGetWallPapersRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "account.getWallPapers",
ID: AccountGetWallPapersRequestTypeID,
}
if g == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Hash",
SchemaName: "hash",
},
}
return typ
}
// Encode implements bin.Encoder.
func (g *AccountGetWallPapersRequest) Encode(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't encode account.getWallPapers#7967d36 as nil")
}
b.PutID(AccountGetWallPapersRequestTypeID)
return g.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (g *AccountGetWallPapersRequest) EncodeBare(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't encode account.getWallPapers#7967d36 as nil")
}
b.PutLong(g.Hash)
return nil
}
// Decode implements bin.Decoder.
func (g *AccountGetWallPapersRequest) Decode(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't decode account.getWallPapers#7967d36 to nil")
}
if err := b.ConsumeID(AccountGetWallPapersRequestTypeID); err != nil {
return fmt.Errorf("unable to decode account.getWallPapers#7967d36: %w", err)
}
return g.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (g *AccountGetWallPapersRequest) DecodeBare(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't decode account.getWallPapers#7967d36 to nil")
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode account.getWallPapers#7967d36: field hash: %w", err)
}
g.Hash = value
}
return nil
}
// GetHash returns value of Hash field.
func (g *AccountGetWallPapersRequest) GetHash() (value int64) {
if g == nil {
return
}
return g.Hash
}
// AccountGetWallPapers invokes method account.getWallPapers#7967d36 returning error if any.
// Returns a list of available wallpapers¹.
//
// Links:
// 1. https://core.telegram.org/api/wallpapers
//
// See https://core.telegram.org/method/account.getWallPapers for reference.
func (c *Client) AccountGetWallPapers(ctx context.Context, hash int64) (AccountWallPapersClass, error) {
var result AccountWallPapersBox
request := &AccountGetWallPapersRequest{
Hash: hash,
}
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
return nil, err
}
return result.WallPapers, nil
}