move gotd fork into repo. (#111)
- 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
This commit is contained in:
@@ -0,0 +1,292 @@
|
||||
// Code generated by gotdgen, DO NOT EDIT.
|
||||
|
||||
package tdapi
|
||||
|
||||
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{}
|
||||
)
|
||||
|
||||
// UploadStickerFileRequest represents TL type `uploadStickerFile#269650c3`.
|
||||
type UploadStickerFileRequest struct {
|
||||
// Sticker file owner; ignored for regular users
|
||||
UserID int64
|
||||
// Sticker format
|
||||
StickerFormat StickerFormatClass
|
||||
// File file to upload; must fit in a 512x512 square. For WEBP stickers the file must be
|
||||
// in WEBP or PNG format, which will be converted to WEBP server-side.
|
||||
Sticker InputFileClass
|
||||
}
|
||||
|
||||
// UploadStickerFileRequestTypeID is TL type id of UploadStickerFileRequest.
|
||||
const UploadStickerFileRequestTypeID = 0x269650c3
|
||||
|
||||
// Ensuring interfaces in compile-time for UploadStickerFileRequest.
|
||||
var (
|
||||
_ bin.Encoder = &UploadStickerFileRequest{}
|
||||
_ bin.Decoder = &UploadStickerFileRequest{}
|
||||
_ bin.BareEncoder = &UploadStickerFileRequest{}
|
||||
_ bin.BareDecoder = &UploadStickerFileRequest{}
|
||||
)
|
||||
|
||||
func (u *UploadStickerFileRequest) Zero() bool {
|
||||
if u == nil {
|
||||
return true
|
||||
}
|
||||
if !(u.UserID == 0) {
|
||||
return false
|
||||
}
|
||||
if !(u.StickerFormat == nil) {
|
||||
return false
|
||||
}
|
||||
if !(u.Sticker == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (u *UploadStickerFileRequest) String() string {
|
||||
if u == nil {
|
||||
return "UploadStickerFileRequest(nil)"
|
||||
}
|
||||
type Alias UploadStickerFileRequest
|
||||
return fmt.Sprintf("UploadStickerFileRequest%+v", Alias(*u))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*UploadStickerFileRequest) TypeID() uint32 {
|
||||
return UploadStickerFileRequestTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*UploadStickerFileRequest) TypeName() string {
|
||||
return "uploadStickerFile"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (u *UploadStickerFileRequest) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "uploadStickerFile",
|
||||
ID: UploadStickerFileRequestTypeID,
|
||||
}
|
||||
if u == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "UserID",
|
||||
SchemaName: "user_id",
|
||||
},
|
||||
{
|
||||
Name: "StickerFormat",
|
||||
SchemaName: "sticker_format",
|
||||
},
|
||||
{
|
||||
Name: "Sticker",
|
||||
SchemaName: "sticker",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (u *UploadStickerFileRequest) Encode(b *bin.Buffer) error {
|
||||
if u == nil {
|
||||
return fmt.Errorf("can't encode uploadStickerFile#269650c3 as nil")
|
||||
}
|
||||
b.PutID(UploadStickerFileRequestTypeID)
|
||||
return u.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (u *UploadStickerFileRequest) EncodeBare(b *bin.Buffer) error {
|
||||
if u == nil {
|
||||
return fmt.Errorf("can't encode uploadStickerFile#269650c3 as nil")
|
||||
}
|
||||
b.PutInt53(u.UserID)
|
||||
if u.StickerFormat == nil {
|
||||
return fmt.Errorf("unable to encode uploadStickerFile#269650c3: field sticker_format is nil")
|
||||
}
|
||||
if err := u.StickerFormat.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode uploadStickerFile#269650c3: field sticker_format: %w", err)
|
||||
}
|
||||
if u.Sticker == nil {
|
||||
return fmt.Errorf("unable to encode uploadStickerFile#269650c3: field sticker is nil")
|
||||
}
|
||||
if err := u.Sticker.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode uploadStickerFile#269650c3: field sticker: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (u *UploadStickerFileRequest) Decode(b *bin.Buffer) error {
|
||||
if u == nil {
|
||||
return fmt.Errorf("can't decode uploadStickerFile#269650c3 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(UploadStickerFileRequestTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode uploadStickerFile#269650c3: %w", err)
|
||||
}
|
||||
return u.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (u *UploadStickerFileRequest) DecodeBare(b *bin.Buffer) error {
|
||||
if u == nil {
|
||||
return fmt.Errorf("can't decode uploadStickerFile#269650c3 to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.Int53()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode uploadStickerFile#269650c3: field user_id: %w", err)
|
||||
}
|
||||
u.UserID = value
|
||||
}
|
||||
{
|
||||
value, err := DecodeStickerFormat(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode uploadStickerFile#269650c3: field sticker_format: %w", err)
|
||||
}
|
||||
u.StickerFormat = value
|
||||
}
|
||||
{
|
||||
value, err := DecodeInputFile(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode uploadStickerFile#269650c3: field sticker: %w", err)
|
||||
}
|
||||
u.Sticker = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
||||
func (u *UploadStickerFileRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
|
||||
if u == nil {
|
||||
return fmt.Errorf("can't encode uploadStickerFile#269650c3 as nil")
|
||||
}
|
||||
b.ObjStart()
|
||||
b.PutID("uploadStickerFile")
|
||||
b.Comma()
|
||||
b.FieldStart("user_id")
|
||||
b.PutInt53(u.UserID)
|
||||
b.Comma()
|
||||
b.FieldStart("sticker_format")
|
||||
if u.StickerFormat == nil {
|
||||
return fmt.Errorf("unable to encode uploadStickerFile#269650c3: field sticker_format is nil")
|
||||
}
|
||||
if err := u.StickerFormat.EncodeTDLibJSON(b); err != nil {
|
||||
return fmt.Errorf("unable to encode uploadStickerFile#269650c3: field sticker_format: %w", err)
|
||||
}
|
||||
b.Comma()
|
||||
b.FieldStart("sticker")
|
||||
if u.Sticker == nil {
|
||||
return fmt.Errorf("unable to encode uploadStickerFile#269650c3: field sticker is nil")
|
||||
}
|
||||
if err := u.Sticker.EncodeTDLibJSON(b); err != nil {
|
||||
return fmt.Errorf("unable to encode uploadStickerFile#269650c3: field sticker: %w", err)
|
||||
}
|
||||
b.Comma()
|
||||
b.StripComma()
|
||||
b.ObjEnd()
|
||||
return nil
|
||||
}
|
||||
|
||||
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
||||
func (u *UploadStickerFileRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
|
||||
if u == nil {
|
||||
return fmt.Errorf("can't decode uploadStickerFile#269650c3 to nil")
|
||||
}
|
||||
|
||||
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
||||
switch string(key) {
|
||||
case tdjson.TypeField:
|
||||
if err := b.ConsumeID("uploadStickerFile"); err != nil {
|
||||
return fmt.Errorf("unable to decode uploadStickerFile#269650c3: %w", err)
|
||||
}
|
||||
case "user_id":
|
||||
value, err := b.Int53()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode uploadStickerFile#269650c3: field user_id: %w", err)
|
||||
}
|
||||
u.UserID = value
|
||||
case "sticker_format":
|
||||
value, err := DecodeTDLibJSONStickerFormat(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode uploadStickerFile#269650c3: field sticker_format: %w", err)
|
||||
}
|
||||
u.StickerFormat = value
|
||||
case "sticker":
|
||||
value, err := DecodeTDLibJSONInputFile(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode uploadStickerFile#269650c3: field sticker: %w", err)
|
||||
}
|
||||
u.Sticker = value
|
||||
default:
|
||||
return b.Skip()
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// GetUserID returns value of UserID field.
|
||||
func (u *UploadStickerFileRequest) GetUserID() (value int64) {
|
||||
if u == nil {
|
||||
return
|
||||
}
|
||||
return u.UserID
|
||||
}
|
||||
|
||||
// GetStickerFormat returns value of StickerFormat field.
|
||||
func (u *UploadStickerFileRequest) GetStickerFormat() (value StickerFormatClass) {
|
||||
if u == nil {
|
||||
return
|
||||
}
|
||||
return u.StickerFormat
|
||||
}
|
||||
|
||||
// GetSticker returns value of Sticker field.
|
||||
func (u *UploadStickerFileRequest) GetSticker() (value InputFileClass) {
|
||||
if u == nil {
|
||||
return
|
||||
}
|
||||
return u.Sticker
|
||||
}
|
||||
|
||||
// UploadStickerFile invokes method uploadStickerFile#269650c3 returning error if any.
|
||||
func (c *Client) UploadStickerFile(ctx context.Context, request *UploadStickerFileRequest) (*File, error) {
|
||||
var result File
|
||||
|
||||
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &result, nil
|
||||
}
|
||||
Reference in New Issue
Block a user