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 DocumentAttributeImageSize struct {
W int
H int
}
const DocumentAttributeImageSizeTypeID = 0x6c37c15c
func (d DocumentAttributeImageSize ) construct () DocumentAttributeClass { return &d }
var (
_ bin .Encoder = &DocumentAttributeImageSize {}
_ bin .Decoder = &DocumentAttributeImageSize {}
_ bin .BareEncoder = &DocumentAttributeImageSize {}
_ bin .BareDecoder = &DocumentAttributeImageSize {}
_ DocumentAttributeClass = &DocumentAttributeImageSize {}
)
func (d *DocumentAttributeImageSize ) Zero () bool {
if d == nil {
return true
}
if !(d .W == 0 ) {
return false
}
if !(d .H == 0 ) {
return false
}
return true
}
func (d *DocumentAttributeImageSize ) String () string {
if d == nil {
return "DocumentAttributeImageSize(nil)"
}
type Alias DocumentAttributeImageSize
return fmt .Sprintf ("DocumentAttributeImageSize%+v" , Alias (*d ))
}
func (d *DocumentAttributeImageSize ) FillFrom (from interface {
GetW () (value int )
GetH () (value int )
}) {
d .W = from .GetW ()
d .H = from .GetH ()
}
func (*DocumentAttributeImageSize ) TypeID () uint32 {
return DocumentAttributeImageSizeTypeID
}
func (*DocumentAttributeImageSize ) TypeName () string {
return "documentAttributeImageSize"
}
func (d *DocumentAttributeImageSize ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "documentAttributeImageSize" ,
ID : DocumentAttributeImageSizeTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "W" ,
SchemaName : "w" ,
},
{
Name : "H" ,
SchemaName : "h" ,
},
}
return typ
}
func (d *DocumentAttributeImageSize ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode documentAttributeImageSize#6c37c15c as nil" )
}
b .PutID (DocumentAttributeImageSizeTypeID )
return d .EncodeBare (b )
}
func (d *DocumentAttributeImageSize ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode documentAttributeImageSize#6c37c15c as nil" )
}
b .PutInt (d .W )
b .PutInt (d .H )
return nil
}
func (d *DocumentAttributeImageSize ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode documentAttributeImageSize#6c37c15c to nil" )
}
if err := b .ConsumeID (DocumentAttributeImageSizeTypeID ); err != nil {
return fmt .Errorf ("unable to decode documentAttributeImageSize#6c37c15c: %w" , err )
}
return d .DecodeBare (b )
}
func (d *DocumentAttributeImageSize ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode documentAttributeImageSize#6c37c15c to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode documentAttributeImageSize#6c37c15c: field w: %w" , err )
}
d .W = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode documentAttributeImageSize#6c37c15c: field h: %w" , err )
}
d .H = value
}
return nil
}
func (d *DocumentAttributeImageSize ) GetW () (value int ) {
if d == nil {
return
}
return d .W
}
func (d *DocumentAttributeImageSize ) GetH () (value int ) {
if d == nil {
return
}
return d .H
}
type DocumentAttributeAnimated struct {
}
const DocumentAttributeAnimatedTypeID = 0x11b58939
func (d DocumentAttributeAnimated ) construct () DocumentAttributeClass { return &d }
var (
_ bin .Encoder = &DocumentAttributeAnimated {}
_ bin .Decoder = &DocumentAttributeAnimated {}
_ bin .BareEncoder = &DocumentAttributeAnimated {}
_ bin .BareDecoder = &DocumentAttributeAnimated {}
_ DocumentAttributeClass = &DocumentAttributeAnimated {}
)
func (d *DocumentAttributeAnimated ) Zero () bool {
if d == nil {
return true
}
return true
}
func (d *DocumentAttributeAnimated ) String () string {
if d == nil {
return "DocumentAttributeAnimated(nil)"
}
type Alias DocumentAttributeAnimated
return fmt .Sprintf ("DocumentAttributeAnimated%+v" , Alias (*d ))
}
func (*DocumentAttributeAnimated ) TypeID () uint32 {
return DocumentAttributeAnimatedTypeID
}
func (*DocumentAttributeAnimated ) TypeName () string {
return "documentAttributeAnimated"
}
func (d *DocumentAttributeAnimated ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "documentAttributeAnimated" ,
ID : DocumentAttributeAnimatedTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (d *DocumentAttributeAnimated ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode documentAttributeAnimated#11b58939 as nil" )
}
b .PutID (DocumentAttributeAnimatedTypeID )
return d .EncodeBare (b )
}
func (d *DocumentAttributeAnimated ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode documentAttributeAnimated#11b58939 as nil" )
}
return nil
}
func (d *DocumentAttributeAnimated ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode documentAttributeAnimated#11b58939 to nil" )
}
if err := b .ConsumeID (DocumentAttributeAnimatedTypeID ); err != nil {
return fmt .Errorf ("unable to decode documentAttributeAnimated#11b58939: %w" , err )
}
return d .DecodeBare (b )
}
func (d *DocumentAttributeAnimated ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode documentAttributeAnimated#11b58939 to nil" )
}
return nil
}
type DocumentAttributeSticker struct {
Flags bin .Fields
Mask bool
Alt string
Stickerset InputStickerSetClass
MaskCoords MaskCoords
}
const DocumentAttributeStickerTypeID = 0x6319d612
func (d DocumentAttributeSticker ) construct () DocumentAttributeClass { return &d }
var (
_ bin .Encoder = &DocumentAttributeSticker {}
_ bin .Decoder = &DocumentAttributeSticker {}
_ bin .BareEncoder = &DocumentAttributeSticker {}
_ bin .BareDecoder = &DocumentAttributeSticker {}
_ DocumentAttributeClass = &DocumentAttributeSticker {}
)
func (d *DocumentAttributeSticker ) Zero () bool {
if d == nil {
return true
}
if !(d .Flags .Zero ()) {
return false
}
if !(d .Mask == false ) {
return false
}
if !(d .Alt == "" ) {
return false
}
if !(d .Stickerset == nil ) {
return false
}
if !(d .MaskCoords .Zero ()) {
return false
}
return true
}
func (d *DocumentAttributeSticker ) String () string {
if d == nil {
return "DocumentAttributeSticker(nil)"
}
type Alias DocumentAttributeSticker
return fmt .Sprintf ("DocumentAttributeSticker%+v" , Alias (*d ))
}
func (d *DocumentAttributeSticker ) FillFrom (from interface {
GetMask () (value bool )
GetAlt () (value string )
GetStickerset () (value InputStickerSetClass )
GetMaskCoords () (value MaskCoords , ok bool )
}) {
d .Mask = from .GetMask ()
d .Alt = from .GetAlt ()
d .Stickerset = from .GetStickerset ()
if val , ok := from .GetMaskCoords (); ok {
d .MaskCoords = val
}
}
func (*DocumentAttributeSticker ) TypeID () uint32 {
return DocumentAttributeStickerTypeID
}
func (*DocumentAttributeSticker ) TypeName () string {
return "documentAttributeSticker"
}
func (d *DocumentAttributeSticker ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "documentAttributeSticker" ,
ID : DocumentAttributeStickerTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Mask" ,
SchemaName : "mask" ,
Null : !d .Flags .Has (1 ),
},
{
Name : "Alt" ,
SchemaName : "alt" ,
},
{
Name : "Stickerset" ,
SchemaName : "stickerset" ,
},
{
Name : "MaskCoords" ,
SchemaName : "mask_coords" ,
Null : !d .Flags .Has (0 ),
},
}
return typ
}
func (d *DocumentAttributeSticker ) SetFlags () {
if !(d .Mask == false ) {
d .Flags .Set (1 )
}
if !(d .MaskCoords .Zero ()) {
d .Flags .Set (0 )
}
}
func (d *DocumentAttributeSticker ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode documentAttributeSticker#6319d612 as nil" )
}
b .PutID (DocumentAttributeStickerTypeID )
return d .EncodeBare (b )
}
func (d *DocumentAttributeSticker ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode documentAttributeSticker#6319d612 as nil" )
}
d .SetFlags ()
if err := d .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode documentAttributeSticker#6319d612: field flags: %w" , err )
}
b .PutString (d .Alt )
if d .Stickerset == nil {
return fmt .Errorf ("unable to encode documentAttributeSticker#6319d612: field stickerset is nil" )
}
if err := d .Stickerset .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode documentAttributeSticker#6319d612: field stickerset: %w" , err )
}
if d .Flags .Has (0 ) {
if err := d .MaskCoords .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode documentAttributeSticker#6319d612: field mask_coords: %w" , err )
}
}
return nil
}
func (d *DocumentAttributeSticker ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode documentAttributeSticker#6319d612 to nil" )
}
if err := b .ConsumeID (DocumentAttributeStickerTypeID ); err != nil {
return fmt .Errorf ("unable to decode documentAttributeSticker#6319d612: %w" , err )
}
return d .DecodeBare (b )
}
func (d *DocumentAttributeSticker ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode documentAttributeSticker#6319d612 to nil" )
}
{
if err := d .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode documentAttributeSticker#6319d612: field flags: %w" , err )
}
}
d .Mask = d .Flags .Has (1 )
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode documentAttributeSticker#6319d612: field alt: %w" , err )
}
d .Alt = value
}
{
value , err := DecodeInputStickerSet (b )
if err != nil {
return fmt .Errorf ("unable to decode documentAttributeSticker#6319d612: field stickerset: %w" , err )
}
d .Stickerset = value
}
if d .Flags .Has (0 ) {
if err := d .MaskCoords .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode documentAttributeSticker#6319d612: field mask_coords: %w" , err )
}
}
return nil
}
func (d *DocumentAttributeSticker ) SetMask (value bool ) {
if value {
d .Flags .Set (1 )
d .Mask = true
} else {
d .Flags .Unset (1 )
d .Mask = false
}
}
func (d *DocumentAttributeSticker ) GetMask () (value bool ) {
if d == nil {
return
}
return d .Flags .Has (1 )
}
func (d *DocumentAttributeSticker ) GetAlt () (value string ) {
if d == nil {
return
}
return d .Alt
}
func (d *DocumentAttributeSticker ) GetStickerset () (value InputStickerSetClass ) {
if d == nil {
return
}
return d .Stickerset
}
func (d *DocumentAttributeSticker ) SetMaskCoords (value MaskCoords ) {
d .Flags .Set (0 )
d .MaskCoords = value
}
func (d *DocumentAttributeSticker ) GetMaskCoords () (value MaskCoords , ok bool ) {
if d == nil {
return
}
if !d .Flags .Has (0 ) {
return value , false
}
return d .MaskCoords , true
}
type DocumentAttributeVideo struct {
Flags bin .Fields
RoundMessage bool
SupportsStreaming bool
Nosound bool
Duration float64
W int
H int
PreloadPrefixSize int
}
const DocumentAttributeVideoTypeID = 0xd38ff1c2
func (d DocumentAttributeVideo ) construct () DocumentAttributeClass { return &d }
var (
_ bin .Encoder = &DocumentAttributeVideo {}
_ bin .Decoder = &DocumentAttributeVideo {}
_ bin .BareEncoder = &DocumentAttributeVideo {}
_ bin .BareDecoder = &DocumentAttributeVideo {}
_ DocumentAttributeClass = &DocumentAttributeVideo {}
)
func (d *DocumentAttributeVideo ) Zero () bool {
if d == nil {
return true
}
if !(d .Flags .Zero ()) {
return false
}
if !(d .RoundMessage == false ) {
return false
}
if !(d .SupportsStreaming == false ) {
return false
}
if !(d .Nosound == false ) {
return false
}
if !(d .Duration == 0 ) {
return false
}
if !(d .W == 0 ) {
return false
}
if !(d .H == 0 ) {
return false
}
if !(d .PreloadPrefixSize == 0 ) {
return false
}
return true
}
func (d *DocumentAttributeVideo ) String () string {
if d == nil {
return "DocumentAttributeVideo(nil)"
}
type Alias DocumentAttributeVideo
return fmt .Sprintf ("DocumentAttributeVideo%+v" , Alias (*d ))
}
func (d *DocumentAttributeVideo ) FillFrom (from interface {
GetRoundMessage () (value bool )
GetSupportsStreaming () (value bool )
GetNosound () (value bool )
GetDuration () (value float64 )
GetW () (value int )
GetH () (value int )
GetPreloadPrefixSize () (value int , ok bool )
}) {
d .RoundMessage = from .GetRoundMessage ()
d .SupportsStreaming = from .GetSupportsStreaming ()
d .Nosound = from .GetNosound ()
d .Duration = from .GetDuration ()
d .W = from .GetW ()
d .H = from .GetH ()
if val , ok := from .GetPreloadPrefixSize (); ok {
d .PreloadPrefixSize = val
}
}
func (*DocumentAttributeVideo ) TypeID () uint32 {
return DocumentAttributeVideoTypeID
}
func (*DocumentAttributeVideo ) TypeName () string {
return "documentAttributeVideo"
}
func (d *DocumentAttributeVideo ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "documentAttributeVideo" ,
ID : DocumentAttributeVideoTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "RoundMessage" ,
SchemaName : "round_message" ,
Null : !d .Flags .Has (0 ),
},
{
Name : "SupportsStreaming" ,
SchemaName : "supports_streaming" ,
Null : !d .Flags .Has (1 ),
},
{
Name : "Nosound" ,
SchemaName : "nosound" ,
Null : !d .Flags .Has (3 ),
},
{
Name : "Duration" ,
SchemaName : "duration" ,
},
{
Name : "W" ,
SchemaName : "w" ,
},
{
Name : "H" ,
SchemaName : "h" ,
},
{
Name : "PreloadPrefixSize" ,
SchemaName : "preload_prefix_size" ,
Null : !d .Flags .Has (2 ),
},
}
return typ
}
func (d *DocumentAttributeVideo ) SetFlags () {
if !(d .RoundMessage == false ) {
d .Flags .Set (0 )
}
if !(d .SupportsStreaming == false ) {
d .Flags .Set (1 )
}
if !(d .Nosound == false ) {
d .Flags .Set (3 )
}
if !(d .PreloadPrefixSize == 0 ) {
d .Flags .Set (2 )
}
}
func (d *DocumentAttributeVideo ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode documentAttributeVideo#d38ff1c2 as nil" )
}
b .PutID (DocumentAttributeVideoTypeID )
return d .EncodeBare (b )
}
func (d *DocumentAttributeVideo ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode documentAttributeVideo#d38ff1c2 as nil" )
}
d .SetFlags ()
if err := d .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode documentAttributeVideo#d38ff1c2: field flags: %w" , err )
}
b .PutDouble (d .Duration )
b .PutInt (d .W )
b .PutInt (d .H )
if d .Flags .Has (2 ) {
b .PutInt (d .PreloadPrefixSize )
}
return nil
}
func (d *DocumentAttributeVideo ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode documentAttributeVideo#d38ff1c2 to nil" )
}
if err := b .ConsumeID (DocumentAttributeVideoTypeID ); err != nil {
return fmt .Errorf ("unable to decode documentAttributeVideo#d38ff1c2: %w" , err )
}
return d .DecodeBare (b )
}
func (d *DocumentAttributeVideo ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode documentAttributeVideo#d38ff1c2 to nil" )
}
{
if err := d .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode documentAttributeVideo#d38ff1c2: field flags: %w" , err )
}
}
d .RoundMessage = d .Flags .Has (0 )
d .SupportsStreaming = d .Flags .Has (1 )
d .Nosound = d .Flags .Has (3 )
{
value , err := b .Double ()
if err != nil {
return fmt .Errorf ("unable to decode documentAttributeVideo#d38ff1c2: field duration: %w" , err )
}
d .Duration = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode documentAttributeVideo#d38ff1c2: field w: %w" , err )
}
d .W = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode documentAttributeVideo#d38ff1c2: field h: %w" , err )
}
d .H = value
}
if d .Flags .Has (2 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode documentAttributeVideo#d38ff1c2: field preload_prefix_size: %w" , err )
}
d .PreloadPrefixSize = value
}
return nil
}
func (d *DocumentAttributeVideo ) SetRoundMessage (value bool ) {
if value {
d .Flags .Set (0 )
d .RoundMessage = true
} else {
d .Flags .Unset (0 )
d .RoundMessage = false
}
}
func (d *DocumentAttributeVideo ) GetRoundMessage () (value bool ) {
if d == nil {
return
}
return d .Flags .Has (0 )
}
func (d *DocumentAttributeVideo ) SetSupportsStreaming (value bool ) {
if value {
d .Flags .Set (1 )
d .SupportsStreaming = true
} else {
d .Flags .Unset (1 )
d .SupportsStreaming = false
}
}
func (d *DocumentAttributeVideo ) GetSupportsStreaming () (value bool ) {
if d == nil {
return
}
return d .Flags .Has (1 )
}
func (d *DocumentAttributeVideo ) SetNosound (value bool ) {
if value {
d .Flags .Set (3 )
d .Nosound = true
} else {
d .Flags .Unset (3 )
d .Nosound = false
}
}
func (d *DocumentAttributeVideo ) GetNosound () (value bool ) {
if d == nil {
return
}
return d .Flags .Has (3 )
}
func (d *DocumentAttributeVideo ) GetDuration () (value float64 ) {
if d == nil {
return
}
return d .Duration
}
func (d *DocumentAttributeVideo ) GetW () (value int ) {
if d == nil {
return
}
return d .W
}
func (d *DocumentAttributeVideo ) GetH () (value int ) {
if d == nil {
return
}
return d .H
}
func (d *DocumentAttributeVideo ) SetPreloadPrefixSize (value int ) {
d .Flags .Set (2 )
d .PreloadPrefixSize = value
}
func (d *DocumentAttributeVideo ) GetPreloadPrefixSize () (value int , ok bool ) {
if d == nil {
return
}
if !d .Flags .Has (2 ) {
return value , false
}
return d .PreloadPrefixSize , true
}
type DocumentAttributeAudio struct {
Flags bin .Fields
Voice bool
Duration int
Title string
Performer string
Waveform []byte
}
const DocumentAttributeAudioTypeID = 0x9852f9c6
func (d DocumentAttributeAudio ) construct () DocumentAttributeClass { return &d }
var (
_ bin .Encoder = &DocumentAttributeAudio {}
_ bin .Decoder = &DocumentAttributeAudio {}
_ bin .BareEncoder = &DocumentAttributeAudio {}
_ bin .BareDecoder = &DocumentAttributeAudio {}
_ DocumentAttributeClass = &DocumentAttributeAudio {}
)
func (d *DocumentAttributeAudio ) Zero () bool {
if d == nil {
return true
}
if !(d .Flags .Zero ()) {
return false
}
if !(d .Voice == false ) {
return false
}
if !(d .Duration == 0 ) {
return false
}
if !(d .Title == "" ) {
return false
}
if !(d .Performer == "" ) {
return false
}
if !(d .Waveform == nil ) {
return false
}
return true
}
func (d *DocumentAttributeAudio ) String () string {
if d == nil {
return "DocumentAttributeAudio(nil)"
}
type Alias DocumentAttributeAudio
return fmt .Sprintf ("DocumentAttributeAudio%+v" , Alias (*d ))
}
func (d *DocumentAttributeAudio ) FillFrom (from interface {
GetVoice () (value bool )
GetDuration () (value int )
GetTitle () (value string , ok bool )
GetPerformer () (value string , ok bool )
GetWaveform () (value []byte , ok bool )
}) {
d .Voice = from .GetVoice ()
d .Duration = from .GetDuration ()
if val , ok := from .GetTitle (); ok {
d .Title = val
}
if val , ok := from .GetPerformer (); ok {
d .Performer = val
}
if val , ok := from .GetWaveform (); ok {
d .Waveform = val
}
}
func (*DocumentAttributeAudio ) TypeID () uint32 {
return DocumentAttributeAudioTypeID
}
func (*DocumentAttributeAudio ) TypeName () string {
return "documentAttributeAudio"
}
func (d *DocumentAttributeAudio ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "documentAttributeAudio" ,
ID : DocumentAttributeAudioTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Voice" ,
SchemaName : "voice" ,
Null : !d .Flags .Has (10 ),
},
{
Name : "Duration" ,
SchemaName : "duration" ,
},
{
Name : "Title" ,
SchemaName : "title" ,
Null : !d .Flags .Has (0 ),
},
{
Name : "Performer" ,
SchemaName : "performer" ,
Null : !d .Flags .Has (1 ),
},
{
Name : "Waveform" ,
SchemaName : "waveform" ,
Null : !d .Flags .Has (2 ),
},
}
return typ
}
func (d *DocumentAttributeAudio ) SetFlags () {
if !(d .Voice == false ) {
d .Flags .Set (10 )
}
if !(d .Title == "" ) {
d .Flags .Set (0 )
}
if !(d .Performer == "" ) {
d .Flags .Set (1 )
}
if !(d .Waveform == nil ) {
d .Flags .Set (2 )
}
}
func (d *DocumentAttributeAudio ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode documentAttributeAudio#9852f9c6 as nil" )
}
b .PutID (DocumentAttributeAudioTypeID )
return d .EncodeBare (b )
}
func (d *DocumentAttributeAudio ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode documentAttributeAudio#9852f9c6 as nil" )
}
d .SetFlags ()
if err := d .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode documentAttributeAudio#9852f9c6: field flags: %w" , err )
}
b .PutInt (d .Duration )
if d .Flags .Has (0 ) {
b .PutString (d .Title )
}
if d .Flags .Has (1 ) {
b .PutString (d .Performer )
}
if d .Flags .Has (2 ) {
b .PutBytes (d .Waveform )
}
return nil
}
func (d *DocumentAttributeAudio ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode documentAttributeAudio#9852f9c6 to nil" )
}
if err := b .ConsumeID (DocumentAttributeAudioTypeID ); err != nil {
return fmt .Errorf ("unable to decode documentAttributeAudio#9852f9c6: %w" , err )
}
return d .DecodeBare (b )
}
func (d *DocumentAttributeAudio ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode documentAttributeAudio#9852f9c6 to nil" )
}
{
if err := d .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode documentAttributeAudio#9852f9c6: field flags: %w" , err )
}
}
d .Voice = d .Flags .Has (10 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode documentAttributeAudio#9852f9c6: field duration: %w" , err )
}
d .Duration = value
}
if d .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode documentAttributeAudio#9852f9c6: field title: %w" , err )
}
d .Title = value
}
if d .Flags .Has (1 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode documentAttributeAudio#9852f9c6: field performer: %w" , err )
}
d .Performer = value
}
if d .Flags .Has (2 ) {
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode documentAttributeAudio#9852f9c6: field waveform: %w" , err )
}
d .Waveform = value
}
return nil
}
func (d *DocumentAttributeAudio ) SetVoice (value bool ) {
if value {
d .Flags .Set (10 )
d .Voice = true
} else {
d .Flags .Unset (10 )
d .Voice = false
}
}
func (d *DocumentAttributeAudio ) GetVoice () (value bool ) {
if d == nil {
return
}
return d .Flags .Has (10 )
}
func (d *DocumentAttributeAudio ) GetDuration () (value int ) {
if d == nil {
return
}
return d .Duration
}
func (d *DocumentAttributeAudio ) SetTitle (value string ) {
d .Flags .Set (0 )
d .Title = value
}
func (d *DocumentAttributeAudio ) GetTitle () (value string , ok bool ) {
if d == nil {
return
}
if !d .Flags .Has (0 ) {
return value , false
}
return d .Title , true
}
func (d *DocumentAttributeAudio ) SetPerformer (value string ) {
d .Flags .Set (1 )
d .Performer = value
}
func (d *DocumentAttributeAudio ) GetPerformer () (value string , ok bool ) {
if d == nil {
return
}
if !d .Flags .Has (1 ) {
return value , false
}
return d .Performer , true
}
func (d *DocumentAttributeAudio ) SetWaveform (value []byte ) {
d .Flags .Set (2 )
d .Waveform = value
}
func (d *DocumentAttributeAudio ) GetWaveform () (value []byte , ok bool ) {
if d == nil {
return
}
if !d .Flags .Has (2 ) {
return value , false
}
return d .Waveform , true
}
type DocumentAttributeFilename struct {
FileName string
}
const DocumentAttributeFilenameTypeID = 0x15590068
func (d DocumentAttributeFilename ) construct () DocumentAttributeClass { return &d }
var (
_ bin .Encoder = &DocumentAttributeFilename {}
_ bin .Decoder = &DocumentAttributeFilename {}
_ bin .BareEncoder = &DocumentAttributeFilename {}
_ bin .BareDecoder = &DocumentAttributeFilename {}
_ DocumentAttributeClass = &DocumentAttributeFilename {}
)
func (d *DocumentAttributeFilename ) Zero () bool {
if d == nil {
return true
}
if !(d .FileName == "" ) {
return false
}
return true
}
func (d *DocumentAttributeFilename ) String () string {
if d == nil {
return "DocumentAttributeFilename(nil)"
}
type Alias DocumentAttributeFilename
return fmt .Sprintf ("DocumentAttributeFilename%+v" , Alias (*d ))
}
func (d *DocumentAttributeFilename ) FillFrom (from interface {
GetFileName () (value string )
}) {
d .FileName = from .GetFileName ()
}
func (*DocumentAttributeFilename ) TypeID () uint32 {
return DocumentAttributeFilenameTypeID
}
func (*DocumentAttributeFilename ) TypeName () string {
return "documentAttributeFilename"
}
func (d *DocumentAttributeFilename ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "documentAttributeFilename" ,
ID : DocumentAttributeFilenameTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "FileName" ,
SchemaName : "file_name" ,
},
}
return typ
}
func (d *DocumentAttributeFilename ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode documentAttributeFilename#15590068 as nil" )
}
b .PutID (DocumentAttributeFilenameTypeID )
return d .EncodeBare (b )
}
func (d *DocumentAttributeFilename ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode documentAttributeFilename#15590068 as nil" )
}
b .PutString (d .FileName )
return nil
}
func (d *DocumentAttributeFilename ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode documentAttributeFilename#15590068 to nil" )
}
if err := b .ConsumeID (DocumentAttributeFilenameTypeID ); err != nil {
return fmt .Errorf ("unable to decode documentAttributeFilename#15590068: %w" , err )
}
return d .DecodeBare (b )
}
func (d *DocumentAttributeFilename ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode documentAttributeFilename#15590068 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode documentAttributeFilename#15590068: field file_name: %w" , err )
}
d .FileName = value
}
return nil
}
func (d *DocumentAttributeFilename ) GetFileName () (value string ) {
if d == nil {
return
}
return d .FileName
}
type DocumentAttributeHasStickers struct {
}
const DocumentAttributeHasStickersTypeID = 0x9801d2f7
func (d DocumentAttributeHasStickers ) construct () DocumentAttributeClass { return &d }
var (
_ bin .Encoder = &DocumentAttributeHasStickers {}
_ bin .Decoder = &DocumentAttributeHasStickers {}
_ bin .BareEncoder = &DocumentAttributeHasStickers {}
_ bin .BareDecoder = &DocumentAttributeHasStickers {}
_ DocumentAttributeClass = &DocumentAttributeHasStickers {}
)
func (d *DocumentAttributeHasStickers ) Zero () bool {
if d == nil {
return true
}
return true
}
func (d *DocumentAttributeHasStickers ) String () string {
if d == nil {
return "DocumentAttributeHasStickers(nil)"
}
type Alias DocumentAttributeHasStickers
return fmt .Sprintf ("DocumentAttributeHasStickers%+v" , Alias (*d ))
}
func (*DocumentAttributeHasStickers ) TypeID () uint32 {
return DocumentAttributeHasStickersTypeID
}
func (*DocumentAttributeHasStickers ) TypeName () string {
return "documentAttributeHasStickers"
}
func (d *DocumentAttributeHasStickers ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "documentAttributeHasStickers" ,
ID : DocumentAttributeHasStickersTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (d *DocumentAttributeHasStickers ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode documentAttributeHasStickers#9801d2f7 as nil" )
}
b .PutID (DocumentAttributeHasStickersTypeID )
return d .EncodeBare (b )
}
func (d *DocumentAttributeHasStickers ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode documentAttributeHasStickers#9801d2f7 as nil" )
}
return nil
}
func (d *DocumentAttributeHasStickers ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode documentAttributeHasStickers#9801d2f7 to nil" )
}
if err := b .ConsumeID (DocumentAttributeHasStickersTypeID ); err != nil {
return fmt .Errorf ("unable to decode documentAttributeHasStickers#9801d2f7: %w" , err )
}
return d .DecodeBare (b )
}
func (d *DocumentAttributeHasStickers ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode documentAttributeHasStickers#9801d2f7 to nil" )
}
return nil
}
type DocumentAttributeCustomEmoji struct {
Flags bin .Fields
Free bool
TextColor bool
Alt string
Stickerset InputStickerSetClass
}
const DocumentAttributeCustomEmojiTypeID = 0xfd149899
func (d DocumentAttributeCustomEmoji ) construct () DocumentAttributeClass { return &d }
var (
_ bin .Encoder = &DocumentAttributeCustomEmoji {}
_ bin .Decoder = &DocumentAttributeCustomEmoji {}
_ bin .BareEncoder = &DocumentAttributeCustomEmoji {}
_ bin .BareDecoder = &DocumentAttributeCustomEmoji {}
_ DocumentAttributeClass = &DocumentAttributeCustomEmoji {}
)
func (d *DocumentAttributeCustomEmoji ) Zero () bool {
if d == nil {
return true
}
if !(d .Flags .Zero ()) {
return false
}
if !(d .Free == false ) {
return false
}
if !(d .TextColor == false ) {
return false
}
if !(d .Alt == "" ) {
return false
}
if !(d .Stickerset == nil ) {
return false
}
return true
}
func (d *DocumentAttributeCustomEmoji ) String () string {
if d == nil {
return "DocumentAttributeCustomEmoji(nil)"
}
type Alias DocumentAttributeCustomEmoji
return fmt .Sprintf ("DocumentAttributeCustomEmoji%+v" , Alias (*d ))
}
func (d *DocumentAttributeCustomEmoji ) FillFrom (from interface {
GetFree () (value bool )
GetTextColor () (value bool )
GetAlt () (value string )
GetStickerset () (value InputStickerSetClass )
}) {
d .Free = from .GetFree ()
d .TextColor = from .GetTextColor ()
d .Alt = from .GetAlt ()
d .Stickerset = from .GetStickerset ()
}
func (*DocumentAttributeCustomEmoji ) TypeID () uint32 {
return DocumentAttributeCustomEmojiTypeID
}
func (*DocumentAttributeCustomEmoji ) TypeName () string {
return "documentAttributeCustomEmoji"
}
func (d *DocumentAttributeCustomEmoji ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "documentAttributeCustomEmoji" ,
ID : DocumentAttributeCustomEmojiTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Free" ,
SchemaName : "free" ,
Null : !d .Flags .Has (0 ),
},
{
Name : "TextColor" ,
SchemaName : "text_color" ,
Null : !d .Flags .Has (1 ),
},
{
Name : "Alt" ,
SchemaName : "alt" ,
},
{
Name : "Stickerset" ,
SchemaName : "stickerset" ,
},
}
return typ
}
func (d *DocumentAttributeCustomEmoji ) SetFlags () {
if !(d .Free == false ) {
d .Flags .Set (0 )
}
if !(d .TextColor == false ) {
d .Flags .Set (1 )
}
}
func (d *DocumentAttributeCustomEmoji ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode documentAttributeCustomEmoji#fd149899 as nil" )
}
b .PutID (DocumentAttributeCustomEmojiTypeID )
return d .EncodeBare (b )
}
func (d *DocumentAttributeCustomEmoji ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode documentAttributeCustomEmoji#fd149899 as nil" )
}
d .SetFlags ()
if err := d .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode documentAttributeCustomEmoji#fd149899: field flags: %w" , err )
}
b .PutString (d .Alt )
if d .Stickerset == nil {
return fmt .Errorf ("unable to encode documentAttributeCustomEmoji#fd149899: field stickerset is nil" )
}
if err := d .Stickerset .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode documentAttributeCustomEmoji#fd149899: field stickerset: %w" , err )
}
return nil
}
func (d *DocumentAttributeCustomEmoji ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode documentAttributeCustomEmoji#fd149899 to nil" )
}
if err := b .ConsumeID (DocumentAttributeCustomEmojiTypeID ); err != nil {
return fmt .Errorf ("unable to decode documentAttributeCustomEmoji#fd149899: %w" , err )
}
return d .DecodeBare (b )
}
func (d *DocumentAttributeCustomEmoji ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode documentAttributeCustomEmoji#fd149899 to nil" )
}
{
if err := d .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode documentAttributeCustomEmoji#fd149899: field flags: %w" , err )
}
}
d .Free = d .Flags .Has (0 )
d .TextColor = d .Flags .Has (1 )
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode documentAttributeCustomEmoji#fd149899: field alt: %w" , err )
}
d .Alt = value
}
{
value , err := DecodeInputStickerSet (b )
if err != nil {
return fmt .Errorf ("unable to decode documentAttributeCustomEmoji#fd149899: field stickerset: %w" , err )
}
d .Stickerset = value
}
return nil
}
func (d *DocumentAttributeCustomEmoji ) SetFree (value bool ) {
if value {
d .Flags .Set (0 )
d .Free = true
} else {
d .Flags .Unset (0 )
d .Free = false
}
}
func (d *DocumentAttributeCustomEmoji ) GetFree () (value bool ) {
if d == nil {
return
}
return d .Flags .Has (0 )
}
func (d *DocumentAttributeCustomEmoji ) SetTextColor (value bool ) {
if value {
d .Flags .Set (1 )
d .TextColor = true
} else {
d .Flags .Unset (1 )
d .TextColor = false
}
}
func (d *DocumentAttributeCustomEmoji ) GetTextColor () (value bool ) {
if d == nil {
return
}
return d .Flags .Has (1 )
}
func (d *DocumentAttributeCustomEmoji ) GetAlt () (value string ) {
if d == nil {
return
}
return d .Alt
}
func (d *DocumentAttributeCustomEmoji ) GetStickerset () (value InputStickerSetClass ) {
if d == nil {
return
}
return d .Stickerset
}
const DocumentAttributeClassName = "DocumentAttribute"
type DocumentAttributeClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () DocumentAttributeClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeDocumentAttribute (buf *bin .Buffer ) (DocumentAttributeClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case DocumentAttributeImageSizeTypeID :
v := DocumentAttributeImageSize {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode DocumentAttributeClass: %w" , err )
}
return &v , nil
case DocumentAttributeAnimatedTypeID :
v := DocumentAttributeAnimated {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode DocumentAttributeClass: %w" , err )
}
return &v , nil
case DocumentAttributeStickerTypeID :
v := DocumentAttributeSticker {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode DocumentAttributeClass: %w" , err )
}
return &v , nil
case DocumentAttributeVideoTypeID :
v := DocumentAttributeVideo {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode DocumentAttributeClass: %w" , err )
}
return &v , nil
case DocumentAttributeAudioTypeID :
v := DocumentAttributeAudio {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode DocumentAttributeClass: %w" , err )
}
return &v , nil
case DocumentAttributeFilenameTypeID :
v := DocumentAttributeFilename {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode DocumentAttributeClass: %w" , err )
}
return &v , nil
case DocumentAttributeHasStickersTypeID :
v := DocumentAttributeHasStickers {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode DocumentAttributeClass: %w" , err )
}
return &v , nil
case DocumentAttributeCustomEmojiTypeID :
v := DocumentAttributeCustomEmoji {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode DocumentAttributeClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode DocumentAttributeClass: %w" , bin .NewUnexpectedID (id ))
}
}
type DocumentAttributeBox struct {
DocumentAttribute DocumentAttributeClass
}
func (b *DocumentAttributeBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode DocumentAttributeBox to nil" )
}
v , err := DecodeDocumentAttribute (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .DocumentAttribute = v
return nil
}
func (b *DocumentAttributeBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .DocumentAttribute == nil {
return fmt .Errorf ("unable to encode DocumentAttributeClass as nil" )
}
return b .DocumentAttribute .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 .