package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type VideoSize struct {
Flags bin .Fields
Type string
W int
H int
Size int
VideoStartTs float64
}
const VideoSizeTypeID = 0xde33b094
func (v VideoSize ) construct () VideoSizeClass { return &v }
var (
_ bin .Encoder = &VideoSize {}
_ bin .Decoder = &VideoSize {}
_ bin .BareEncoder = &VideoSize {}
_ bin .BareDecoder = &VideoSize {}
_ VideoSizeClass = &VideoSize {}
)
func (v *VideoSize ) Zero () bool {
if v == nil {
return true
}
if !(v .Flags .Zero ()) {
return false
}
if !(v .Type == "" ) {
return false
}
if !(v .W == 0 ) {
return false
}
if !(v .H == 0 ) {
return false
}
if !(v .Size == 0 ) {
return false
}
if !(v .VideoStartTs == 0 ) {
return false
}
return true
}
func (v *VideoSize ) String () string {
if v == nil {
return "VideoSize(nil)"
}
type Alias VideoSize
return fmt .Sprintf ("VideoSize%+v" , Alias (*v ))
}
func (v *VideoSize ) FillFrom (from interface {
GetType () (value string )
GetW () (value int )
GetH () (value int )
GetSize () (value int )
GetVideoStartTs () (value float64 , ok bool )
}) {
v .Type = from .GetType ()
v .W = from .GetW ()
v .H = from .GetH ()
v .Size = from .GetSize ()
if val , ok := from .GetVideoStartTs (); ok {
v .VideoStartTs = val
}
}
func (*VideoSize ) TypeID () uint32 {
return VideoSizeTypeID
}
func (*VideoSize ) TypeName () string {
return "videoSize"
}
func (v *VideoSize ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "videoSize" ,
ID : VideoSizeTypeID ,
}
if v == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Type" ,
SchemaName : "type" ,
},
{
Name : "W" ,
SchemaName : "w" ,
},
{
Name : "H" ,
SchemaName : "h" ,
},
{
Name : "Size" ,
SchemaName : "size" ,
},
{
Name : "VideoStartTs" ,
SchemaName : "video_start_ts" ,
Null : !v .Flags .Has (0 ),
},
}
return typ
}
func (v *VideoSize ) SetFlags () {
if !(v .VideoStartTs == 0 ) {
v .Flags .Set (0 )
}
}
func (v *VideoSize ) Encode (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't encode videoSize#de33b094 as nil" )
}
b .PutID (VideoSizeTypeID )
return v .EncodeBare (b )
}
func (v *VideoSize ) EncodeBare (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't encode videoSize#de33b094 as nil" )
}
v .SetFlags ()
if err := v .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode videoSize#de33b094: field flags: %w" , err )
}
b .PutString (v .Type )
b .PutInt (v .W )
b .PutInt (v .H )
b .PutInt (v .Size )
if v .Flags .Has (0 ) {
b .PutDouble (v .VideoStartTs )
}
return nil
}
func (v *VideoSize ) Decode (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't decode videoSize#de33b094 to nil" )
}
if err := b .ConsumeID (VideoSizeTypeID ); err != nil {
return fmt .Errorf ("unable to decode videoSize#de33b094: %w" , err )
}
return v .DecodeBare (b )
}
func (v *VideoSize ) DecodeBare (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't decode videoSize#de33b094 to nil" )
}
{
if err := v .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode videoSize#de33b094: field flags: %w" , err )
}
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode videoSize#de33b094: field type: %w" , err )
}
v .Type = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode videoSize#de33b094: field w: %w" , err )
}
v .W = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode videoSize#de33b094: field h: %w" , err )
}
v .H = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode videoSize#de33b094: field size: %w" , err )
}
v .Size = value
}
if v .Flags .Has (0 ) {
value , err := b .Double ()
if err != nil {
return fmt .Errorf ("unable to decode videoSize#de33b094: field video_start_ts: %w" , err )
}
v .VideoStartTs = value
}
return nil
}
func (v *VideoSize ) GetType () (value string ) {
if v == nil {
return
}
return v .Type
}
func (v *VideoSize ) GetW () (value int ) {
if v == nil {
return
}
return v .W
}
func (v *VideoSize ) GetH () (value int ) {
if v == nil {
return
}
return v .H
}
func (v *VideoSize ) GetSize () (value int ) {
if v == nil {
return
}
return v .Size
}
func (v *VideoSize ) SetVideoStartTs (value float64 ) {
v .Flags .Set (0 )
v .VideoStartTs = value
}
func (v *VideoSize ) GetVideoStartTs () (value float64 , ok bool ) {
if v == nil {
return
}
if !v .Flags .Has (0 ) {
return value , false
}
return v .VideoStartTs , true
}
type VideoSizeEmojiMarkup struct {
EmojiID int64
BackgroundColors []int
}
const VideoSizeEmojiMarkupTypeID = 0xf85c413c
func (v VideoSizeEmojiMarkup ) construct () VideoSizeClass { return &v }
var (
_ bin .Encoder = &VideoSizeEmojiMarkup {}
_ bin .Decoder = &VideoSizeEmojiMarkup {}
_ bin .BareEncoder = &VideoSizeEmojiMarkup {}
_ bin .BareDecoder = &VideoSizeEmojiMarkup {}
_ VideoSizeClass = &VideoSizeEmojiMarkup {}
)
func (v *VideoSizeEmojiMarkup ) Zero () bool {
if v == nil {
return true
}
if !(v .EmojiID == 0 ) {
return false
}
if !(v .BackgroundColors == nil ) {
return false
}
return true
}
func (v *VideoSizeEmojiMarkup ) String () string {
if v == nil {
return "VideoSizeEmojiMarkup(nil)"
}
type Alias VideoSizeEmojiMarkup
return fmt .Sprintf ("VideoSizeEmojiMarkup%+v" , Alias (*v ))
}
func (v *VideoSizeEmojiMarkup ) FillFrom (from interface {
GetEmojiID () (value int64 )
GetBackgroundColors () (value []int )
}) {
v .EmojiID = from .GetEmojiID ()
v .BackgroundColors = from .GetBackgroundColors ()
}
func (*VideoSizeEmojiMarkup ) TypeID () uint32 {
return VideoSizeEmojiMarkupTypeID
}
func (*VideoSizeEmojiMarkup ) TypeName () string {
return "videoSizeEmojiMarkup"
}
func (v *VideoSizeEmojiMarkup ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "videoSizeEmojiMarkup" ,
ID : VideoSizeEmojiMarkupTypeID ,
}
if v == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "EmojiID" ,
SchemaName : "emoji_id" ,
},
{
Name : "BackgroundColors" ,
SchemaName : "background_colors" ,
},
}
return typ
}
func (v *VideoSizeEmojiMarkup ) Encode (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't encode videoSizeEmojiMarkup#f85c413c as nil" )
}
b .PutID (VideoSizeEmojiMarkupTypeID )
return v .EncodeBare (b )
}
func (v *VideoSizeEmojiMarkup ) EncodeBare (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't encode videoSizeEmojiMarkup#f85c413c as nil" )
}
b .PutLong (v .EmojiID )
b .PutVectorHeader (len (v .BackgroundColors ))
for _ , v := range v .BackgroundColors {
b .PutInt (v )
}
return nil
}
func (v *VideoSizeEmojiMarkup ) Decode (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't decode videoSizeEmojiMarkup#f85c413c to nil" )
}
if err := b .ConsumeID (VideoSizeEmojiMarkupTypeID ); err != nil {
return fmt .Errorf ("unable to decode videoSizeEmojiMarkup#f85c413c: %w" , err )
}
return v .DecodeBare (b )
}
func (v *VideoSizeEmojiMarkup ) DecodeBare (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't decode videoSizeEmojiMarkup#f85c413c to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode videoSizeEmojiMarkup#f85c413c: field emoji_id: %w" , err )
}
v .EmojiID = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode videoSizeEmojiMarkup#f85c413c: field background_colors: %w" , err )
}
if headerLen > 0 {
v .BackgroundColors = 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 videoSizeEmojiMarkup#f85c413c: field background_colors: %w" , err )
}
v .BackgroundColors = append (v .BackgroundColors , value )
}
}
return nil
}
func (v *VideoSizeEmojiMarkup ) GetEmojiID () (value int64 ) {
if v == nil {
return
}
return v .EmojiID
}
func (v *VideoSizeEmojiMarkup ) GetBackgroundColors () (value []int ) {
if v == nil {
return
}
return v .BackgroundColors
}
type VideoSizeStickerMarkup struct {
Stickerset InputStickerSetClass
StickerID int64
BackgroundColors []int
}
const VideoSizeStickerMarkupTypeID = 0xda082fe
func (v VideoSizeStickerMarkup ) construct () VideoSizeClass { return &v }
var (
_ bin .Encoder = &VideoSizeStickerMarkup {}
_ bin .Decoder = &VideoSizeStickerMarkup {}
_ bin .BareEncoder = &VideoSizeStickerMarkup {}
_ bin .BareDecoder = &VideoSizeStickerMarkup {}
_ VideoSizeClass = &VideoSizeStickerMarkup {}
)
func (v *VideoSizeStickerMarkup ) Zero () bool {
if v == nil {
return true
}
if !(v .Stickerset == nil ) {
return false
}
if !(v .StickerID == 0 ) {
return false
}
if !(v .BackgroundColors == nil ) {
return false
}
return true
}
func (v *VideoSizeStickerMarkup ) String () string {
if v == nil {
return "VideoSizeStickerMarkup(nil)"
}
type Alias VideoSizeStickerMarkup
return fmt .Sprintf ("VideoSizeStickerMarkup%+v" , Alias (*v ))
}
func (v *VideoSizeStickerMarkup ) FillFrom (from interface {
GetStickerset () (value InputStickerSetClass )
GetStickerID () (value int64 )
GetBackgroundColors () (value []int )
}) {
v .Stickerset = from .GetStickerset ()
v .StickerID = from .GetStickerID ()
v .BackgroundColors = from .GetBackgroundColors ()
}
func (*VideoSizeStickerMarkup ) TypeID () uint32 {
return VideoSizeStickerMarkupTypeID
}
func (*VideoSizeStickerMarkup ) TypeName () string {
return "videoSizeStickerMarkup"
}
func (v *VideoSizeStickerMarkup ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "videoSizeStickerMarkup" ,
ID : VideoSizeStickerMarkupTypeID ,
}
if v == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Stickerset" ,
SchemaName : "stickerset" ,
},
{
Name : "StickerID" ,
SchemaName : "sticker_id" ,
},
{
Name : "BackgroundColors" ,
SchemaName : "background_colors" ,
},
}
return typ
}
func (v *VideoSizeStickerMarkup ) Encode (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't encode videoSizeStickerMarkup#da082fe as nil" )
}
b .PutID (VideoSizeStickerMarkupTypeID )
return v .EncodeBare (b )
}
func (v *VideoSizeStickerMarkup ) EncodeBare (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't encode videoSizeStickerMarkup#da082fe as nil" )
}
if v .Stickerset == nil {
return fmt .Errorf ("unable to encode videoSizeStickerMarkup#da082fe: field stickerset is nil" )
}
if err := v .Stickerset .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode videoSizeStickerMarkup#da082fe: field stickerset: %w" , err )
}
b .PutLong (v .StickerID )
b .PutVectorHeader (len (v .BackgroundColors ))
for _ , v := range v .BackgroundColors {
b .PutInt (v )
}
return nil
}
func (v *VideoSizeStickerMarkup ) Decode (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't decode videoSizeStickerMarkup#da082fe to nil" )
}
if err := b .ConsumeID (VideoSizeStickerMarkupTypeID ); err != nil {
return fmt .Errorf ("unable to decode videoSizeStickerMarkup#da082fe: %w" , err )
}
return v .DecodeBare (b )
}
func (v *VideoSizeStickerMarkup ) DecodeBare (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't decode videoSizeStickerMarkup#da082fe to nil" )
}
{
value , err := DecodeInputStickerSet (b )
if err != nil {
return fmt .Errorf ("unable to decode videoSizeStickerMarkup#da082fe: field stickerset: %w" , err )
}
v .Stickerset = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode videoSizeStickerMarkup#da082fe: field sticker_id: %w" , err )
}
v .StickerID = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode videoSizeStickerMarkup#da082fe: field background_colors: %w" , err )
}
if headerLen > 0 {
v .BackgroundColors = 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 videoSizeStickerMarkup#da082fe: field background_colors: %w" , err )
}
v .BackgroundColors = append (v .BackgroundColors , value )
}
}
return nil
}
func (v *VideoSizeStickerMarkup ) GetStickerset () (value InputStickerSetClass ) {
if v == nil {
return
}
return v .Stickerset
}
func (v *VideoSizeStickerMarkup ) GetStickerID () (value int64 ) {
if v == nil {
return
}
return v .StickerID
}
func (v *VideoSizeStickerMarkup ) GetBackgroundColors () (value []int ) {
if v == nil {
return
}
return v .BackgroundColors
}
const VideoSizeClassName = "VideoSize"
type VideoSizeClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () VideoSizeClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeVideoSize (buf *bin .Buffer ) (VideoSizeClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case VideoSizeTypeID :
v := VideoSize {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode VideoSizeClass: %w" , err )
}
return &v , nil
case VideoSizeEmojiMarkupTypeID :
v := VideoSizeEmojiMarkup {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode VideoSizeClass: %w" , err )
}
return &v , nil
case VideoSizeStickerMarkupTypeID :
v := VideoSizeStickerMarkup {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode VideoSizeClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode VideoSizeClass: %w" , bin .NewUnexpectedID (id ))
}
}
type VideoSizeBox struct {
VideoSize VideoSizeClass
}
func (b *VideoSizeBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode VideoSizeBox to nil" )
}
v , err := DecodeVideoSize (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .VideoSize = v
return nil
}
func (b *VideoSizeBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .VideoSize == nil {
return fmt .Errorf ("unable to encode VideoSizeClass as nil" )
}
return b .VideoSize .Encode (buf )
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .