7a04f298d2
- 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
467 lines
11 KiB
Go
467 lines
11 KiB
Go
// 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{}
|
|
)
|
|
|
|
// Animation represents TL type `animation#cc00db3e`.
|
|
type Animation struct {
|
|
// Duration of the animation, in seconds; as defined by the sender
|
|
Duration int32
|
|
// Width of the animation
|
|
Width int32
|
|
// Height of the animation
|
|
Height int32
|
|
// Original name of the file; as defined by the sender
|
|
FileName string
|
|
// MIME type of the file, usually "image/gif" or "video/mp4"
|
|
MimeType string
|
|
// True, if stickers were added to the animation. The list of corresponding sticker set
|
|
// can be received using getAttachedStickerSets
|
|
HasStickers bool
|
|
// Animation minithumbnail; may be null
|
|
Minithumbnail Minithumbnail
|
|
// Animation thumbnail in JPEG or MPEG4 format; may be null
|
|
Thumbnail Thumbnail
|
|
// File containing the animation
|
|
Animation File
|
|
}
|
|
|
|
// AnimationTypeID is TL type id of Animation.
|
|
const AnimationTypeID = 0xcc00db3e
|
|
|
|
// Ensuring interfaces in compile-time for Animation.
|
|
var (
|
|
_ bin.Encoder = &Animation{}
|
|
_ bin.Decoder = &Animation{}
|
|
_ bin.BareEncoder = &Animation{}
|
|
_ bin.BareDecoder = &Animation{}
|
|
)
|
|
|
|
func (a *Animation) Zero() bool {
|
|
if a == nil {
|
|
return true
|
|
}
|
|
if !(a.Duration == 0) {
|
|
return false
|
|
}
|
|
if !(a.Width == 0) {
|
|
return false
|
|
}
|
|
if !(a.Height == 0) {
|
|
return false
|
|
}
|
|
if !(a.FileName == "") {
|
|
return false
|
|
}
|
|
if !(a.MimeType == "") {
|
|
return false
|
|
}
|
|
if !(a.HasStickers == false) {
|
|
return false
|
|
}
|
|
if !(a.Minithumbnail.Zero()) {
|
|
return false
|
|
}
|
|
if !(a.Thumbnail.Zero()) {
|
|
return false
|
|
}
|
|
if !(a.Animation.Zero()) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (a *Animation) String() string {
|
|
if a == nil {
|
|
return "Animation(nil)"
|
|
}
|
|
type Alias Animation
|
|
return fmt.Sprintf("Animation%+v", Alias(*a))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*Animation) TypeID() uint32 {
|
|
return AnimationTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*Animation) TypeName() string {
|
|
return "animation"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (a *Animation) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "animation",
|
|
ID: AnimationTypeID,
|
|
}
|
|
if a == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Duration",
|
|
SchemaName: "duration",
|
|
},
|
|
{
|
|
Name: "Width",
|
|
SchemaName: "width",
|
|
},
|
|
{
|
|
Name: "Height",
|
|
SchemaName: "height",
|
|
},
|
|
{
|
|
Name: "FileName",
|
|
SchemaName: "file_name",
|
|
},
|
|
{
|
|
Name: "MimeType",
|
|
SchemaName: "mime_type",
|
|
},
|
|
{
|
|
Name: "HasStickers",
|
|
SchemaName: "has_stickers",
|
|
},
|
|
{
|
|
Name: "Minithumbnail",
|
|
SchemaName: "minithumbnail",
|
|
},
|
|
{
|
|
Name: "Thumbnail",
|
|
SchemaName: "thumbnail",
|
|
},
|
|
{
|
|
Name: "Animation",
|
|
SchemaName: "animation",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (a *Animation) Encode(b *bin.Buffer) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't encode animation#cc00db3e as nil")
|
|
}
|
|
b.PutID(AnimationTypeID)
|
|
return a.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (a *Animation) EncodeBare(b *bin.Buffer) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't encode animation#cc00db3e as nil")
|
|
}
|
|
b.PutInt32(a.Duration)
|
|
b.PutInt32(a.Width)
|
|
b.PutInt32(a.Height)
|
|
b.PutString(a.FileName)
|
|
b.PutString(a.MimeType)
|
|
b.PutBool(a.HasStickers)
|
|
if err := a.Minithumbnail.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode animation#cc00db3e: field minithumbnail: %w", err)
|
|
}
|
|
if err := a.Thumbnail.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode animation#cc00db3e: field thumbnail: %w", err)
|
|
}
|
|
if err := a.Animation.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode animation#cc00db3e: field animation: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (a *Animation) Decode(b *bin.Buffer) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't decode animation#cc00db3e to nil")
|
|
}
|
|
if err := b.ConsumeID(AnimationTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode animation#cc00db3e: %w", err)
|
|
}
|
|
return a.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (a *Animation) DecodeBare(b *bin.Buffer) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't decode animation#cc00db3e to nil")
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode animation#cc00db3e: field duration: %w", err)
|
|
}
|
|
a.Duration = value
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode animation#cc00db3e: field width: %w", err)
|
|
}
|
|
a.Width = value
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode animation#cc00db3e: field height: %w", err)
|
|
}
|
|
a.Height = value
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode animation#cc00db3e: field file_name: %w", err)
|
|
}
|
|
a.FileName = value
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode animation#cc00db3e: field mime_type: %w", err)
|
|
}
|
|
a.MimeType = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode animation#cc00db3e: field has_stickers: %w", err)
|
|
}
|
|
a.HasStickers = value
|
|
}
|
|
{
|
|
if err := a.Minithumbnail.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode animation#cc00db3e: field minithumbnail: %w", err)
|
|
}
|
|
}
|
|
{
|
|
if err := a.Thumbnail.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode animation#cc00db3e: field thumbnail: %w", err)
|
|
}
|
|
}
|
|
{
|
|
if err := a.Animation.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode animation#cc00db3e: field animation: %w", err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (a *Animation) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't encode animation#cc00db3e as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("animation")
|
|
b.Comma()
|
|
b.FieldStart("duration")
|
|
b.PutInt32(a.Duration)
|
|
b.Comma()
|
|
b.FieldStart("width")
|
|
b.PutInt32(a.Width)
|
|
b.Comma()
|
|
b.FieldStart("height")
|
|
b.PutInt32(a.Height)
|
|
b.Comma()
|
|
b.FieldStart("file_name")
|
|
b.PutString(a.FileName)
|
|
b.Comma()
|
|
b.FieldStart("mime_type")
|
|
b.PutString(a.MimeType)
|
|
b.Comma()
|
|
b.FieldStart("has_stickers")
|
|
b.PutBool(a.HasStickers)
|
|
b.Comma()
|
|
b.FieldStart("minithumbnail")
|
|
if err := a.Minithumbnail.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode animation#cc00db3e: field minithumbnail: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("thumbnail")
|
|
if err := a.Thumbnail.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode animation#cc00db3e: field thumbnail: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("animation")
|
|
if err := a.Animation.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode animation#cc00db3e: field animation: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (a *Animation) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if a == nil {
|
|
return fmt.Errorf("can't decode animation#cc00db3e to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("animation"); err != nil {
|
|
return fmt.Errorf("unable to decode animation#cc00db3e: %w", err)
|
|
}
|
|
case "duration":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode animation#cc00db3e: field duration: %w", err)
|
|
}
|
|
a.Duration = value
|
|
case "width":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode animation#cc00db3e: field width: %w", err)
|
|
}
|
|
a.Width = value
|
|
case "height":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode animation#cc00db3e: field height: %w", err)
|
|
}
|
|
a.Height = value
|
|
case "file_name":
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode animation#cc00db3e: field file_name: %w", err)
|
|
}
|
|
a.FileName = value
|
|
case "mime_type":
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode animation#cc00db3e: field mime_type: %w", err)
|
|
}
|
|
a.MimeType = value
|
|
case "has_stickers":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode animation#cc00db3e: field has_stickers: %w", err)
|
|
}
|
|
a.HasStickers = value
|
|
case "minithumbnail":
|
|
if err := a.Minithumbnail.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode animation#cc00db3e: field minithumbnail: %w", err)
|
|
}
|
|
case "thumbnail":
|
|
if err := a.Thumbnail.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode animation#cc00db3e: field thumbnail: %w", err)
|
|
}
|
|
case "animation":
|
|
if err := a.Animation.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode animation#cc00db3e: field animation: %w", err)
|
|
}
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetDuration returns value of Duration field.
|
|
func (a *Animation) GetDuration() (value int32) {
|
|
if a == nil {
|
|
return
|
|
}
|
|
return a.Duration
|
|
}
|
|
|
|
// GetWidth returns value of Width field.
|
|
func (a *Animation) GetWidth() (value int32) {
|
|
if a == nil {
|
|
return
|
|
}
|
|
return a.Width
|
|
}
|
|
|
|
// GetHeight returns value of Height field.
|
|
func (a *Animation) GetHeight() (value int32) {
|
|
if a == nil {
|
|
return
|
|
}
|
|
return a.Height
|
|
}
|
|
|
|
// GetFileName returns value of FileName field.
|
|
func (a *Animation) GetFileName() (value string) {
|
|
if a == nil {
|
|
return
|
|
}
|
|
return a.FileName
|
|
}
|
|
|
|
// GetMimeType returns value of MimeType field.
|
|
func (a *Animation) GetMimeType() (value string) {
|
|
if a == nil {
|
|
return
|
|
}
|
|
return a.MimeType
|
|
}
|
|
|
|
// GetHasStickers returns value of HasStickers field.
|
|
func (a *Animation) GetHasStickers() (value bool) {
|
|
if a == nil {
|
|
return
|
|
}
|
|
return a.HasStickers
|
|
}
|
|
|
|
// GetMinithumbnail returns value of Minithumbnail field.
|
|
func (a *Animation) GetMinithumbnail() (value Minithumbnail) {
|
|
if a == nil {
|
|
return
|
|
}
|
|
return a.Minithumbnail
|
|
}
|
|
|
|
// GetThumbnail returns value of Thumbnail field.
|
|
func (a *Animation) GetThumbnail() (value Thumbnail) {
|
|
if a == nil {
|
|
return
|
|
}
|
|
return a.Thumbnail
|
|
}
|
|
|
|
// GetAnimation returns value of Animation field.
|
|
func (a *Animation) GetAnimation() (value File) {
|
|
if a == nil {
|
|
return
|
|
}
|
|
return a.Animation
|
|
}
|