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

276 lines
6.7 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{}
)
// PhotosGetUserPhotosRequest represents TL type `photos.getUserPhotos#91cd32a8`.
// Returns the list of user photos.
//
// See https://core.telegram.org/method/photos.getUserPhotos for reference.
type PhotosGetUserPhotosRequest struct {
// User ID
UserID InputUserClass
// Number of list elements to be skipped
Offset int
// If a positive value was transferred, the method will return only photos with IDs less
// than the set one. This parameter is often useful when refetching file references »¹,
// as in conjuction with limit=1 and offset=-1 the photo² object with the id specified
// in max_id can be fetched.
//
// Links:
// 1) https://core.telegram.org/api/file_reference
// 2) https://core.telegram.org/constructor/photo
MaxID int64
// Number of list elements to be returned
Limit int
}
// PhotosGetUserPhotosRequestTypeID is TL type id of PhotosGetUserPhotosRequest.
const PhotosGetUserPhotosRequestTypeID = 0x91cd32a8
// Ensuring interfaces in compile-time for PhotosGetUserPhotosRequest.
var (
_ bin.Encoder = &PhotosGetUserPhotosRequest{}
_ bin.Decoder = &PhotosGetUserPhotosRequest{}
_ bin.BareEncoder = &PhotosGetUserPhotosRequest{}
_ bin.BareDecoder = &PhotosGetUserPhotosRequest{}
)
func (g *PhotosGetUserPhotosRequest) Zero() bool {
if g == nil {
return true
}
if !(g.UserID == nil) {
return false
}
if !(g.Offset == 0) {
return false
}
if !(g.MaxID == 0) {
return false
}
if !(g.Limit == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (g *PhotosGetUserPhotosRequest) String() string {
if g == nil {
return "PhotosGetUserPhotosRequest(nil)"
}
type Alias PhotosGetUserPhotosRequest
return fmt.Sprintf("PhotosGetUserPhotosRequest%+v", Alias(*g))
}
// FillFrom fills PhotosGetUserPhotosRequest from given interface.
func (g *PhotosGetUserPhotosRequest) FillFrom(from interface {
GetUserID() (value InputUserClass)
GetOffset() (value int)
GetMaxID() (value int64)
GetLimit() (value int)
}) {
g.UserID = from.GetUserID()
g.Offset = from.GetOffset()
g.MaxID = from.GetMaxID()
g.Limit = from.GetLimit()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PhotosGetUserPhotosRequest) TypeID() uint32 {
return PhotosGetUserPhotosRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*PhotosGetUserPhotosRequest) TypeName() string {
return "photos.getUserPhotos"
}
// TypeInfo returns info about TL type.
func (g *PhotosGetUserPhotosRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "photos.getUserPhotos",
ID: PhotosGetUserPhotosRequestTypeID,
}
if g == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "UserID",
SchemaName: "user_id",
},
{
Name: "Offset",
SchemaName: "offset",
},
{
Name: "MaxID",
SchemaName: "max_id",
},
{
Name: "Limit",
SchemaName: "limit",
},
}
return typ
}
// Encode implements bin.Encoder.
func (g *PhotosGetUserPhotosRequest) Encode(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't encode photos.getUserPhotos#91cd32a8 as nil")
}
b.PutID(PhotosGetUserPhotosRequestTypeID)
return g.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (g *PhotosGetUserPhotosRequest) EncodeBare(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't encode photos.getUserPhotos#91cd32a8 as nil")
}
if g.UserID == nil {
return fmt.Errorf("unable to encode photos.getUserPhotos#91cd32a8: field user_id is nil")
}
if err := g.UserID.Encode(b); err != nil {
return fmt.Errorf("unable to encode photos.getUserPhotos#91cd32a8: field user_id: %w", err)
}
b.PutInt(g.Offset)
b.PutLong(g.MaxID)
b.PutInt(g.Limit)
return nil
}
// Decode implements bin.Decoder.
func (g *PhotosGetUserPhotosRequest) Decode(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't decode photos.getUserPhotos#91cd32a8 to nil")
}
if err := b.ConsumeID(PhotosGetUserPhotosRequestTypeID); err != nil {
return fmt.Errorf("unable to decode photos.getUserPhotos#91cd32a8: %w", err)
}
return g.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (g *PhotosGetUserPhotosRequest) DecodeBare(b *bin.Buffer) error {
if g == nil {
return fmt.Errorf("can't decode photos.getUserPhotos#91cd32a8 to nil")
}
{
value, err := DecodeInputUser(b)
if err != nil {
return fmt.Errorf("unable to decode photos.getUserPhotos#91cd32a8: field user_id: %w", err)
}
g.UserID = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode photos.getUserPhotos#91cd32a8: field offset: %w", err)
}
g.Offset = value
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode photos.getUserPhotos#91cd32a8: field max_id: %w", err)
}
g.MaxID = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode photos.getUserPhotos#91cd32a8: field limit: %w", err)
}
g.Limit = value
}
return nil
}
// GetUserID returns value of UserID field.
func (g *PhotosGetUserPhotosRequest) GetUserID() (value InputUserClass) {
if g == nil {
return
}
return g.UserID
}
// GetOffset returns value of Offset field.
func (g *PhotosGetUserPhotosRequest) GetOffset() (value int) {
if g == nil {
return
}
return g.Offset
}
// GetMaxID returns value of MaxID field.
func (g *PhotosGetUserPhotosRequest) GetMaxID() (value int64) {
if g == nil {
return
}
return g.MaxID
}
// GetLimit returns value of Limit field.
func (g *PhotosGetUserPhotosRequest) GetLimit() (value int) {
if g == nil {
return
}
return g.Limit
}
// PhotosGetUserPhotos invokes method photos.getUserPhotos#91cd32a8 returning error if any.
// Returns the list of user photos.
//
// Possible errors:
//
// 400 MAX_ID_INVALID: The provided max ID is invalid.
// 400 MSG_ID_INVALID: Invalid message ID provided.
// 400 USER_ID_INVALID: The provided user ID is invalid.
//
// See https://core.telegram.org/method/photos.getUserPhotos for reference.
// Can be used by bots.
func (c *Client) PhotosGetUserPhotos(ctx context.Context, request *PhotosGetUserPhotosRequest) (PhotosPhotosClass, error) {
var result PhotosPhotosBox
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
return nil, err
}
return result.Photos, nil
}