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 InputWebFileLocation struct {
URL string
AccessHash int64
}
const InputWebFileLocationTypeID = 0xc239d686
func (i InputWebFileLocation ) construct () InputWebFileLocationClass { return &i }
var (
_ bin .Encoder = &InputWebFileLocation {}
_ bin .Decoder = &InputWebFileLocation {}
_ bin .BareEncoder = &InputWebFileLocation {}
_ bin .BareDecoder = &InputWebFileLocation {}
_ InputWebFileLocationClass = &InputWebFileLocation {}
)
func (i *InputWebFileLocation ) Zero () bool {
if i == nil {
return true
}
if !(i .URL == "" ) {
return false
}
if !(i .AccessHash == 0 ) {
return false
}
return true
}
func (i *InputWebFileLocation ) String () string {
if i == nil {
return "InputWebFileLocation(nil)"
}
type Alias InputWebFileLocation
return fmt .Sprintf ("InputWebFileLocation%+v" , Alias (*i ))
}
func (i *InputWebFileLocation ) FillFrom (from interface {
GetURL () (value string )
GetAccessHash () (value int64 )
}) {
i .URL = from .GetURL ()
i .AccessHash = from .GetAccessHash ()
}
func (*InputWebFileLocation ) TypeID () uint32 {
return InputWebFileLocationTypeID
}
func (*InputWebFileLocation ) TypeName () string {
return "inputWebFileLocation"
}
func (i *InputWebFileLocation ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputWebFileLocation" ,
ID : InputWebFileLocationTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "URL" ,
SchemaName : "url" ,
},
{
Name : "AccessHash" ,
SchemaName : "access_hash" ,
},
}
return typ
}
func (i *InputWebFileLocation ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputWebFileLocation#c239d686 as nil" )
}
b .PutID (InputWebFileLocationTypeID )
return i .EncodeBare (b )
}
func (i *InputWebFileLocation ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputWebFileLocation#c239d686 as nil" )
}
b .PutString (i .URL )
b .PutLong (i .AccessHash )
return nil
}
func (i *InputWebFileLocation ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputWebFileLocation#c239d686 to nil" )
}
if err := b .ConsumeID (InputWebFileLocationTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputWebFileLocation#c239d686: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputWebFileLocation ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputWebFileLocation#c239d686 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputWebFileLocation#c239d686: field url: %w" , err )
}
i .URL = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputWebFileLocation#c239d686: field access_hash: %w" , err )
}
i .AccessHash = value
}
return nil
}
func (i *InputWebFileLocation ) GetURL () (value string ) {
if i == nil {
return
}
return i .URL
}
func (i *InputWebFileLocation ) GetAccessHash () (value int64 ) {
if i == nil {
return
}
return i .AccessHash
}
type InputWebFileGeoPointLocation struct {
GeoPoint InputGeoPointClass
AccessHash int64
W int
H int
Zoom int
Scale int
}
const InputWebFileGeoPointLocationTypeID = 0x9f2221c9
func (i InputWebFileGeoPointLocation ) construct () InputWebFileLocationClass { return &i }
var (
_ bin .Encoder = &InputWebFileGeoPointLocation {}
_ bin .Decoder = &InputWebFileGeoPointLocation {}
_ bin .BareEncoder = &InputWebFileGeoPointLocation {}
_ bin .BareDecoder = &InputWebFileGeoPointLocation {}
_ InputWebFileLocationClass = &InputWebFileGeoPointLocation {}
)
func (i *InputWebFileGeoPointLocation ) Zero () bool {
if i == nil {
return true
}
if !(i .GeoPoint == nil ) {
return false
}
if !(i .AccessHash == 0 ) {
return false
}
if !(i .W == 0 ) {
return false
}
if !(i .H == 0 ) {
return false
}
if !(i .Zoom == 0 ) {
return false
}
if !(i .Scale == 0 ) {
return false
}
return true
}
func (i *InputWebFileGeoPointLocation ) String () string {
if i == nil {
return "InputWebFileGeoPointLocation(nil)"
}
type Alias InputWebFileGeoPointLocation
return fmt .Sprintf ("InputWebFileGeoPointLocation%+v" , Alias (*i ))
}
func (i *InputWebFileGeoPointLocation ) FillFrom (from interface {
GetGeoPoint () (value InputGeoPointClass )
GetAccessHash () (value int64 )
GetW () (value int )
GetH () (value int )
GetZoom () (value int )
GetScale () (value int )
}) {
i .GeoPoint = from .GetGeoPoint ()
i .AccessHash = from .GetAccessHash ()
i .W = from .GetW ()
i .H = from .GetH ()
i .Zoom = from .GetZoom ()
i .Scale = from .GetScale ()
}
func (*InputWebFileGeoPointLocation ) TypeID () uint32 {
return InputWebFileGeoPointLocationTypeID
}
func (*InputWebFileGeoPointLocation ) TypeName () string {
return "inputWebFileGeoPointLocation"
}
func (i *InputWebFileGeoPointLocation ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputWebFileGeoPointLocation" ,
ID : InputWebFileGeoPointLocationTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "GeoPoint" ,
SchemaName : "geo_point" ,
},
{
Name : "AccessHash" ,
SchemaName : "access_hash" ,
},
{
Name : "W" ,
SchemaName : "w" ,
},
{
Name : "H" ,
SchemaName : "h" ,
},
{
Name : "Zoom" ,
SchemaName : "zoom" ,
},
{
Name : "Scale" ,
SchemaName : "scale" ,
},
}
return typ
}
func (i *InputWebFileGeoPointLocation ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputWebFileGeoPointLocation#9f2221c9 as nil" )
}
b .PutID (InputWebFileGeoPointLocationTypeID )
return i .EncodeBare (b )
}
func (i *InputWebFileGeoPointLocation ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputWebFileGeoPointLocation#9f2221c9 as nil" )
}
if i .GeoPoint == nil {
return fmt .Errorf ("unable to encode inputWebFileGeoPointLocation#9f2221c9: field geo_point is nil" )
}
if err := i .GeoPoint .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputWebFileGeoPointLocation#9f2221c9: field geo_point: %w" , err )
}
b .PutLong (i .AccessHash )
b .PutInt (i .W )
b .PutInt (i .H )
b .PutInt (i .Zoom )
b .PutInt (i .Scale )
return nil
}
func (i *InputWebFileGeoPointLocation ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputWebFileGeoPointLocation#9f2221c9 to nil" )
}
if err := b .ConsumeID (InputWebFileGeoPointLocationTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputWebFileGeoPointLocation#9f2221c9: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputWebFileGeoPointLocation ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputWebFileGeoPointLocation#9f2221c9 to nil" )
}
{
value , err := DecodeInputGeoPoint (b )
if err != nil {
return fmt .Errorf ("unable to decode inputWebFileGeoPointLocation#9f2221c9: field geo_point: %w" , err )
}
i .GeoPoint = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputWebFileGeoPointLocation#9f2221c9: field access_hash: %w" , err )
}
i .AccessHash = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode inputWebFileGeoPointLocation#9f2221c9: field w: %w" , err )
}
i .W = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode inputWebFileGeoPointLocation#9f2221c9: field h: %w" , err )
}
i .H = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode inputWebFileGeoPointLocation#9f2221c9: field zoom: %w" , err )
}
i .Zoom = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode inputWebFileGeoPointLocation#9f2221c9: field scale: %w" , err )
}
i .Scale = value
}
return nil
}
func (i *InputWebFileGeoPointLocation ) GetGeoPoint () (value InputGeoPointClass ) {
if i == nil {
return
}
return i .GeoPoint
}
func (i *InputWebFileGeoPointLocation ) GetAccessHash () (value int64 ) {
if i == nil {
return
}
return i .AccessHash
}
func (i *InputWebFileGeoPointLocation ) GetW () (value int ) {
if i == nil {
return
}
return i .W
}
func (i *InputWebFileGeoPointLocation ) GetH () (value int ) {
if i == nil {
return
}
return i .H
}
func (i *InputWebFileGeoPointLocation ) GetZoom () (value int ) {
if i == nil {
return
}
return i .Zoom
}
func (i *InputWebFileGeoPointLocation ) GetScale () (value int ) {
if i == nil {
return
}
return i .Scale
}
type InputWebFileAudioAlbumThumbLocation struct {
Flags bin .Fields
Small bool
Document InputDocumentClass
Title string
Performer string
}
const InputWebFileAudioAlbumThumbLocationTypeID = 0xf46fe924
func (i InputWebFileAudioAlbumThumbLocation ) construct () InputWebFileLocationClass { return &i }
var (
_ bin .Encoder = &InputWebFileAudioAlbumThumbLocation {}
_ bin .Decoder = &InputWebFileAudioAlbumThumbLocation {}
_ bin .BareEncoder = &InputWebFileAudioAlbumThumbLocation {}
_ bin .BareDecoder = &InputWebFileAudioAlbumThumbLocation {}
_ InputWebFileLocationClass = &InputWebFileAudioAlbumThumbLocation {}
)
func (i *InputWebFileAudioAlbumThumbLocation ) Zero () bool {
if i == nil {
return true
}
if !(i .Flags .Zero ()) {
return false
}
if !(i .Small == false ) {
return false
}
if !(i .Document == nil ) {
return false
}
if !(i .Title == "" ) {
return false
}
if !(i .Performer == "" ) {
return false
}
return true
}
func (i *InputWebFileAudioAlbumThumbLocation ) String () string {
if i == nil {
return "InputWebFileAudioAlbumThumbLocation(nil)"
}
type Alias InputWebFileAudioAlbumThumbLocation
return fmt .Sprintf ("InputWebFileAudioAlbumThumbLocation%+v" , Alias (*i ))
}
func (i *InputWebFileAudioAlbumThumbLocation ) FillFrom (from interface {
GetSmall () (value bool )
GetDocument () (value InputDocumentClass , ok bool )
GetTitle () (value string , ok bool )
GetPerformer () (value string , ok bool )
}) {
i .Small = from .GetSmall ()
if val , ok := from .GetDocument (); ok {
i .Document = val
}
if val , ok := from .GetTitle (); ok {
i .Title = val
}
if val , ok := from .GetPerformer (); ok {
i .Performer = val
}
}
func (*InputWebFileAudioAlbumThumbLocation ) TypeID () uint32 {
return InputWebFileAudioAlbumThumbLocationTypeID
}
func (*InputWebFileAudioAlbumThumbLocation ) TypeName () string {
return "inputWebFileAudioAlbumThumbLocation"
}
func (i *InputWebFileAudioAlbumThumbLocation ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputWebFileAudioAlbumThumbLocation" ,
ID : InputWebFileAudioAlbumThumbLocationTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Small" ,
SchemaName : "small" ,
Null : !i .Flags .Has (2 ),
},
{
Name : "Document" ,
SchemaName : "document" ,
Null : !i .Flags .Has (0 ),
},
{
Name : "Title" ,
SchemaName : "title" ,
Null : !i .Flags .Has (1 ),
},
{
Name : "Performer" ,
SchemaName : "performer" ,
Null : !i .Flags .Has (1 ),
},
}
return typ
}
func (i *InputWebFileAudioAlbumThumbLocation ) SetFlags () {
if !(i .Small == false ) {
i .Flags .Set (2 )
}
if !(i .Document == nil ) {
i .Flags .Set (0 )
}
if !(i .Title == "" ) {
i .Flags .Set (1 )
}
if !(i .Performer == "" ) {
i .Flags .Set (1 )
}
}
func (i *InputWebFileAudioAlbumThumbLocation ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputWebFileAudioAlbumThumbLocation#f46fe924 as nil" )
}
b .PutID (InputWebFileAudioAlbumThumbLocationTypeID )
return i .EncodeBare (b )
}
func (i *InputWebFileAudioAlbumThumbLocation ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputWebFileAudioAlbumThumbLocation#f46fe924 as nil" )
}
i .SetFlags ()
if err := i .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputWebFileAudioAlbumThumbLocation#f46fe924: field flags: %w" , err )
}
if i .Flags .Has (0 ) {
if i .Document == nil {
return fmt .Errorf ("unable to encode inputWebFileAudioAlbumThumbLocation#f46fe924: field document is nil" )
}
if err := i .Document .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputWebFileAudioAlbumThumbLocation#f46fe924: field document: %w" , err )
}
}
if i .Flags .Has (1 ) {
b .PutString (i .Title )
}
if i .Flags .Has (1 ) {
b .PutString (i .Performer )
}
return nil
}
func (i *InputWebFileAudioAlbumThumbLocation ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputWebFileAudioAlbumThumbLocation#f46fe924 to nil" )
}
if err := b .ConsumeID (InputWebFileAudioAlbumThumbLocationTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputWebFileAudioAlbumThumbLocation#f46fe924: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputWebFileAudioAlbumThumbLocation ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputWebFileAudioAlbumThumbLocation#f46fe924 to nil" )
}
{
if err := i .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode inputWebFileAudioAlbumThumbLocation#f46fe924: field flags: %w" , err )
}
}
i .Small = i .Flags .Has (2 )
if i .Flags .Has (0 ) {
value , err := DecodeInputDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode inputWebFileAudioAlbumThumbLocation#f46fe924: field document: %w" , err )
}
i .Document = value
}
if i .Flags .Has (1 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputWebFileAudioAlbumThumbLocation#f46fe924: field title: %w" , err )
}
i .Title = value
}
if i .Flags .Has (1 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputWebFileAudioAlbumThumbLocation#f46fe924: field performer: %w" , err )
}
i .Performer = value
}
return nil
}
func (i *InputWebFileAudioAlbumThumbLocation ) SetSmall (value bool ) {
if value {
i .Flags .Set (2 )
i .Small = true
} else {
i .Flags .Unset (2 )
i .Small = false
}
}
func (i *InputWebFileAudioAlbumThumbLocation ) GetSmall () (value bool ) {
if i == nil {
return
}
return i .Flags .Has (2 )
}
func (i *InputWebFileAudioAlbumThumbLocation ) SetDocument (value InputDocumentClass ) {
i .Flags .Set (0 )
i .Document = value
}
func (i *InputWebFileAudioAlbumThumbLocation ) GetDocument () (value InputDocumentClass , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (0 ) {
return value , false
}
return i .Document , true
}
func (i *InputWebFileAudioAlbumThumbLocation ) SetTitle (value string ) {
i .Flags .Set (1 )
i .Title = value
}
func (i *InputWebFileAudioAlbumThumbLocation ) GetTitle () (value string , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (1 ) {
return value , false
}
return i .Title , true
}
func (i *InputWebFileAudioAlbumThumbLocation ) SetPerformer (value string ) {
i .Flags .Set (1 )
i .Performer = value
}
func (i *InputWebFileAudioAlbumThumbLocation ) GetPerformer () (value string , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (1 ) {
return value , false
}
return i .Performer , true
}
const InputWebFileLocationClassName = "InputWebFileLocation"
type InputWebFileLocationClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () InputWebFileLocationClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeInputWebFileLocation (buf *bin .Buffer ) (InputWebFileLocationClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case InputWebFileLocationTypeID :
v := InputWebFileLocation {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputWebFileLocationClass: %w" , err )
}
return &v , nil
case InputWebFileGeoPointLocationTypeID :
v := InputWebFileGeoPointLocation {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputWebFileLocationClass: %w" , err )
}
return &v , nil
case InputWebFileAudioAlbumThumbLocationTypeID :
v := InputWebFileAudioAlbumThumbLocation {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputWebFileLocationClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode InputWebFileLocationClass: %w" , bin .NewUnexpectedID (id ))
}
}
type InputWebFileLocationBox struct {
InputWebFileLocation InputWebFileLocationClass
}
func (b *InputWebFileLocationBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode InputWebFileLocationBox to nil" )
}
v , err := DecodeInputWebFileLocation (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .InputWebFileLocation = v
return nil
}
func (b *InputWebFileLocationBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .InputWebFileLocation == nil {
return fmt .Errorf ("unable to encode InputWebFileLocationClass as nil" )
}
return b .InputWebFileLocation .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 .