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 WebPageEmpty struct {
Flags bin .Fields
ID int64
URL string
}
const WebPageEmptyTypeID = 0x211a1788
func (w WebPageEmpty ) construct () WebPageClass { return &w }
var (
_ bin .Encoder = &WebPageEmpty {}
_ bin .Decoder = &WebPageEmpty {}
_ bin .BareEncoder = &WebPageEmpty {}
_ bin .BareDecoder = &WebPageEmpty {}
_ WebPageClass = &WebPageEmpty {}
)
func (w *WebPageEmpty ) Zero () bool {
if w == nil {
return true
}
if !(w .Flags .Zero ()) {
return false
}
if !(w .ID == 0 ) {
return false
}
if !(w .URL == "" ) {
return false
}
return true
}
func (w *WebPageEmpty ) String () string {
if w == nil {
return "WebPageEmpty(nil)"
}
type Alias WebPageEmpty
return fmt .Sprintf ("WebPageEmpty%+v" , Alias (*w ))
}
func (w *WebPageEmpty ) FillFrom (from interface {
GetID () (value int64 )
GetURL () (value string , ok bool )
}) {
w .ID = from .GetID ()
if val , ok := from .GetURL (); ok {
w .URL = val
}
}
func (*WebPageEmpty ) TypeID () uint32 {
return WebPageEmptyTypeID
}
func (*WebPageEmpty ) TypeName () string {
return "webPageEmpty"
}
func (w *WebPageEmpty ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "webPageEmpty" ,
ID : WebPageEmptyTypeID ,
}
if w == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "URL" ,
SchemaName : "url" ,
Null : !w .Flags .Has (0 ),
},
}
return typ
}
func (w *WebPageEmpty ) SetFlags () {
if !(w .URL == "" ) {
w .Flags .Set (0 )
}
}
func (w *WebPageEmpty ) Encode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode webPageEmpty#211a1788 as nil" )
}
b .PutID (WebPageEmptyTypeID )
return w .EncodeBare (b )
}
func (w *WebPageEmpty ) EncodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode webPageEmpty#211a1788 as nil" )
}
w .SetFlags ()
if err := w .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode webPageEmpty#211a1788: field flags: %w" , err )
}
b .PutLong (w .ID )
if w .Flags .Has (0 ) {
b .PutString (w .URL )
}
return nil
}
func (w *WebPageEmpty ) Decode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode webPageEmpty#211a1788 to nil" )
}
if err := b .ConsumeID (WebPageEmptyTypeID ); err != nil {
return fmt .Errorf ("unable to decode webPageEmpty#211a1788: %w" , err )
}
return w .DecodeBare (b )
}
func (w *WebPageEmpty ) DecodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode webPageEmpty#211a1788 to nil" )
}
{
if err := w .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode webPageEmpty#211a1788: field flags: %w" , err )
}
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode webPageEmpty#211a1788: field id: %w" , err )
}
w .ID = value
}
if w .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode webPageEmpty#211a1788: field url: %w" , err )
}
w .URL = value
}
return nil
}
func (w *WebPageEmpty ) GetID () (value int64 ) {
if w == nil {
return
}
return w .ID
}
func (w *WebPageEmpty ) SetURL (value string ) {
w .Flags .Set (0 )
w .URL = value
}
func (w *WebPageEmpty ) GetURL () (value string , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (0 ) {
return value , false
}
return w .URL , true
}
type WebPagePending struct {
Flags bin .Fields
ID int64
URL string
Date int
}
const WebPagePendingTypeID = 0xb0d13e47
func (w WebPagePending ) construct () WebPageClass { return &w }
var (
_ bin .Encoder = &WebPagePending {}
_ bin .Decoder = &WebPagePending {}
_ bin .BareEncoder = &WebPagePending {}
_ bin .BareDecoder = &WebPagePending {}
_ WebPageClass = &WebPagePending {}
)
func (w *WebPagePending ) Zero () bool {
if w == nil {
return true
}
if !(w .Flags .Zero ()) {
return false
}
if !(w .ID == 0 ) {
return false
}
if !(w .URL == "" ) {
return false
}
if !(w .Date == 0 ) {
return false
}
return true
}
func (w *WebPagePending ) String () string {
if w == nil {
return "WebPagePending(nil)"
}
type Alias WebPagePending
return fmt .Sprintf ("WebPagePending%+v" , Alias (*w ))
}
func (w *WebPagePending ) FillFrom (from interface {
GetID () (value int64 )
GetURL () (value string , ok bool )
GetDate () (value int )
}) {
w .ID = from .GetID ()
if val , ok := from .GetURL (); ok {
w .URL = val
}
w .Date = from .GetDate ()
}
func (*WebPagePending ) TypeID () uint32 {
return WebPagePendingTypeID
}
func (*WebPagePending ) TypeName () string {
return "webPagePending"
}
func (w *WebPagePending ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "webPagePending" ,
ID : WebPagePendingTypeID ,
}
if w == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "URL" ,
SchemaName : "url" ,
Null : !w .Flags .Has (0 ),
},
{
Name : "Date" ,
SchemaName : "date" ,
},
}
return typ
}
func (w *WebPagePending ) SetFlags () {
if !(w .URL == "" ) {
w .Flags .Set (0 )
}
}
func (w *WebPagePending ) Encode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode webPagePending#b0d13e47 as nil" )
}
b .PutID (WebPagePendingTypeID )
return w .EncodeBare (b )
}
func (w *WebPagePending ) EncodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode webPagePending#b0d13e47 as nil" )
}
w .SetFlags ()
if err := w .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode webPagePending#b0d13e47: field flags: %w" , err )
}
b .PutLong (w .ID )
if w .Flags .Has (0 ) {
b .PutString (w .URL )
}
b .PutInt (w .Date )
return nil
}
func (w *WebPagePending ) Decode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode webPagePending#b0d13e47 to nil" )
}
if err := b .ConsumeID (WebPagePendingTypeID ); err != nil {
return fmt .Errorf ("unable to decode webPagePending#b0d13e47: %w" , err )
}
return w .DecodeBare (b )
}
func (w *WebPagePending ) DecodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode webPagePending#b0d13e47 to nil" )
}
{
if err := w .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode webPagePending#b0d13e47: field flags: %w" , err )
}
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode webPagePending#b0d13e47: field id: %w" , err )
}
w .ID = value
}
if w .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode webPagePending#b0d13e47: field url: %w" , err )
}
w .URL = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode webPagePending#b0d13e47: field date: %w" , err )
}
w .Date = value
}
return nil
}
func (w *WebPagePending ) GetID () (value int64 ) {
if w == nil {
return
}
return w .ID
}
func (w *WebPagePending ) SetURL (value string ) {
w .Flags .Set (0 )
w .URL = value
}
func (w *WebPagePending ) GetURL () (value string , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (0 ) {
return value , false
}
return w .URL , true
}
func (w *WebPagePending ) GetDate () (value int ) {
if w == nil {
return
}
return w .Date
}
type WebPage struct {
Flags bin .Fields
HasLargeMedia bool
ID int64
URL string
DisplayURL string
Hash int
Type string
SiteName string
Title string
Description string
Photo PhotoClass
EmbedURL string
EmbedType string
EmbedWidth int
EmbedHeight int
Duration int
Author string
Document DocumentClass
CachedPage Page
Attributes []WebPageAttributeClass
}
const WebPageTypeID = 0xe89c45b2
func (w WebPage ) construct () WebPageClass { return &w }
var (
_ bin .Encoder = &WebPage {}
_ bin .Decoder = &WebPage {}
_ bin .BareEncoder = &WebPage {}
_ bin .BareDecoder = &WebPage {}
_ WebPageClass = &WebPage {}
)
func (w *WebPage ) Zero () bool {
if w == nil {
return true
}
if !(w .Flags .Zero ()) {
return false
}
if !(w .HasLargeMedia == false ) {
return false
}
if !(w .ID == 0 ) {
return false
}
if !(w .URL == "" ) {
return false
}
if !(w .DisplayURL == "" ) {
return false
}
if !(w .Hash == 0 ) {
return false
}
if !(w .Type == "" ) {
return false
}
if !(w .SiteName == "" ) {
return false
}
if !(w .Title == "" ) {
return false
}
if !(w .Description == "" ) {
return false
}
if !(w .Photo == nil ) {
return false
}
if !(w .EmbedURL == "" ) {
return false
}
if !(w .EmbedType == "" ) {
return false
}
if !(w .EmbedWidth == 0 ) {
return false
}
if !(w .EmbedHeight == 0 ) {
return false
}
if !(w .Duration == 0 ) {
return false
}
if !(w .Author == "" ) {
return false
}
if !(w .Document == nil ) {
return false
}
if !(w .CachedPage .Zero ()) {
return false
}
if !(w .Attributes == nil ) {
return false
}
return true
}
func (w *WebPage ) String () string {
if w == nil {
return "WebPage(nil)"
}
type Alias WebPage
return fmt .Sprintf ("WebPage%+v" , Alias (*w ))
}
func (w *WebPage ) FillFrom (from interface {
GetHasLargeMedia () (value bool )
GetID () (value int64 )
GetURL () (value string )
GetDisplayURL () (value string )
GetHash () (value int )
GetType () (value string , ok bool )
GetSiteName () (value string , ok bool )
GetTitle () (value string , ok bool )
GetDescription () (value string , ok bool )
GetPhoto () (value PhotoClass , ok bool )
GetEmbedURL () (value string , ok bool )
GetEmbedType () (value string , ok bool )
GetEmbedWidth () (value int , ok bool )
GetEmbedHeight () (value int , ok bool )
GetDuration () (value int , ok bool )
GetAuthor () (value string , ok bool )
GetDocument () (value DocumentClass , ok bool )
GetCachedPage () (value Page , ok bool )
GetAttributes () (value []WebPageAttributeClass , ok bool )
}) {
w .HasLargeMedia = from .GetHasLargeMedia ()
w .ID = from .GetID ()
w .URL = from .GetURL ()
w .DisplayURL = from .GetDisplayURL ()
w .Hash = from .GetHash ()
if val , ok := from .GetType (); ok {
w .Type = val
}
if val , ok := from .GetSiteName (); ok {
w .SiteName = val
}
if val , ok := from .GetTitle (); ok {
w .Title = val
}
if val , ok := from .GetDescription (); ok {
w .Description = val
}
if val , ok := from .GetPhoto (); ok {
w .Photo = val
}
if val , ok := from .GetEmbedURL (); ok {
w .EmbedURL = val
}
if val , ok := from .GetEmbedType (); ok {
w .EmbedType = val
}
if val , ok := from .GetEmbedWidth (); ok {
w .EmbedWidth = val
}
if val , ok := from .GetEmbedHeight (); ok {
w .EmbedHeight = val
}
if val , ok := from .GetDuration (); ok {
w .Duration = val
}
if val , ok := from .GetAuthor (); ok {
w .Author = val
}
if val , ok := from .GetDocument (); ok {
w .Document = val
}
if val , ok := from .GetCachedPage (); ok {
w .CachedPage = val
}
if val , ok := from .GetAttributes (); ok {
w .Attributes = val
}
}
func (*WebPage ) TypeID () uint32 {
return WebPageTypeID
}
func (*WebPage ) TypeName () string {
return "webPage"
}
func (w *WebPage ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "webPage" ,
ID : WebPageTypeID ,
}
if w == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "HasLargeMedia" ,
SchemaName : "has_large_media" ,
Null : !w .Flags .Has (13 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "URL" ,
SchemaName : "url" ,
},
{
Name : "DisplayURL" ,
SchemaName : "display_url" ,
},
{
Name : "Hash" ,
SchemaName : "hash" ,
},
{
Name : "Type" ,
SchemaName : "type" ,
Null : !w .Flags .Has (0 ),
},
{
Name : "SiteName" ,
SchemaName : "site_name" ,
Null : !w .Flags .Has (1 ),
},
{
Name : "Title" ,
SchemaName : "title" ,
Null : !w .Flags .Has (2 ),
},
{
Name : "Description" ,
SchemaName : "description" ,
Null : !w .Flags .Has (3 ),
},
{
Name : "Photo" ,
SchemaName : "photo" ,
Null : !w .Flags .Has (4 ),
},
{
Name : "EmbedURL" ,
SchemaName : "embed_url" ,
Null : !w .Flags .Has (5 ),
},
{
Name : "EmbedType" ,
SchemaName : "embed_type" ,
Null : !w .Flags .Has (5 ),
},
{
Name : "EmbedWidth" ,
SchemaName : "embed_width" ,
Null : !w .Flags .Has (6 ),
},
{
Name : "EmbedHeight" ,
SchemaName : "embed_height" ,
Null : !w .Flags .Has (6 ),
},
{
Name : "Duration" ,
SchemaName : "duration" ,
Null : !w .Flags .Has (7 ),
},
{
Name : "Author" ,
SchemaName : "author" ,
Null : !w .Flags .Has (8 ),
},
{
Name : "Document" ,
SchemaName : "document" ,
Null : !w .Flags .Has (9 ),
},
{
Name : "CachedPage" ,
SchemaName : "cached_page" ,
Null : !w .Flags .Has (10 ),
},
{
Name : "Attributes" ,
SchemaName : "attributes" ,
Null : !w .Flags .Has (12 ),
},
}
return typ
}
func (w *WebPage ) SetFlags () {
if !(w .HasLargeMedia == false ) {
w .Flags .Set (13 )
}
if !(w .Type == "" ) {
w .Flags .Set (0 )
}
if !(w .SiteName == "" ) {
w .Flags .Set (1 )
}
if !(w .Title == "" ) {
w .Flags .Set (2 )
}
if !(w .Description == "" ) {
w .Flags .Set (3 )
}
if !(w .Photo == nil ) {
w .Flags .Set (4 )
}
if !(w .EmbedURL == "" ) {
w .Flags .Set (5 )
}
if !(w .EmbedType == "" ) {
w .Flags .Set (5 )
}
if !(w .EmbedWidth == 0 ) {
w .Flags .Set (6 )
}
if !(w .EmbedHeight == 0 ) {
w .Flags .Set (6 )
}
if !(w .Duration == 0 ) {
w .Flags .Set (7 )
}
if !(w .Author == "" ) {
w .Flags .Set (8 )
}
if !(w .Document == nil ) {
w .Flags .Set (9 )
}
if !(w .CachedPage .Zero ()) {
w .Flags .Set (10 )
}
if !(w .Attributes == nil ) {
w .Flags .Set (12 )
}
}
func (w *WebPage ) Encode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode webPage#e89c45b2 as nil" )
}
b .PutID (WebPageTypeID )
return w .EncodeBare (b )
}
func (w *WebPage ) EncodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode webPage#e89c45b2 as nil" )
}
w .SetFlags ()
if err := w .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode webPage#e89c45b2: field flags: %w" , err )
}
b .PutLong (w .ID )
b .PutString (w .URL )
b .PutString (w .DisplayURL )
b .PutInt (w .Hash )
if w .Flags .Has (0 ) {
b .PutString (w .Type )
}
if w .Flags .Has (1 ) {
b .PutString (w .SiteName )
}
if w .Flags .Has (2 ) {
b .PutString (w .Title )
}
if w .Flags .Has (3 ) {
b .PutString (w .Description )
}
if w .Flags .Has (4 ) {
if w .Photo == nil {
return fmt .Errorf ("unable to encode webPage#e89c45b2: field photo is nil" )
}
if err := w .Photo .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode webPage#e89c45b2: field photo: %w" , err )
}
}
if w .Flags .Has (5 ) {
b .PutString (w .EmbedURL )
}
if w .Flags .Has (5 ) {
b .PutString (w .EmbedType )
}
if w .Flags .Has (6 ) {
b .PutInt (w .EmbedWidth )
}
if w .Flags .Has (6 ) {
b .PutInt (w .EmbedHeight )
}
if w .Flags .Has (7 ) {
b .PutInt (w .Duration )
}
if w .Flags .Has (8 ) {
b .PutString (w .Author )
}
if w .Flags .Has (9 ) {
if w .Document == nil {
return fmt .Errorf ("unable to encode webPage#e89c45b2: field document is nil" )
}
if err := w .Document .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode webPage#e89c45b2: field document: %w" , err )
}
}
if w .Flags .Has (10 ) {
if err := w .CachedPage .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode webPage#e89c45b2: field cached_page: %w" , err )
}
}
if w .Flags .Has (12 ) {
b .PutVectorHeader (len (w .Attributes ))
for idx , v := range w .Attributes {
if v == nil {
return fmt .Errorf ("unable to encode webPage#e89c45b2: field attributes element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode webPage#e89c45b2: field attributes element with index %d: %w" , idx , err )
}
}
}
return nil
}
func (w *WebPage ) Decode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode webPage#e89c45b2 to nil" )
}
if err := b .ConsumeID (WebPageTypeID ); err != nil {
return fmt .Errorf ("unable to decode webPage#e89c45b2: %w" , err )
}
return w .DecodeBare (b )
}
func (w *WebPage ) DecodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode webPage#e89c45b2 to nil" )
}
{
if err := w .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode webPage#e89c45b2: field flags: %w" , err )
}
}
w .HasLargeMedia = w .Flags .Has (13 )
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode webPage#e89c45b2: field id: %w" , err )
}
w .ID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode webPage#e89c45b2: field url: %w" , err )
}
w .URL = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode webPage#e89c45b2: field display_url: %w" , err )
}
w .DisplayURL = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode webPage#e89c45b2: field hash: %w" , err )
}
w .Hash = value
}
if w .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode webPage#e89c45b2: field type: %w" , err )
}
w .Type = value
}
if w .Flags .Has (1 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode webPage#e89c45b2: field site_name: %w" , err )
}
w .SiteName = value
}
if w .Flags .Has (2 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode webPage#e89c45b2: field title: %w" , err )
}
w .Title = value
}
if w .Flags .Has (3 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode webPage#e89c45b2: field description: %w" , err )
}
w .Description = value
}
if w .Flags .Has (4 ) {
value , err := DecodePhoto (b )
if err != nil {
return fmt .Errorf ("unable to decode webPage#e89c45b2: field photo: %w" , err )
}
w .Photo = value
}
if w .Flags .Has (5 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode webPage#e89c45b2: field embed_url: %w" , err )
}
w .EmbedURL = value
}
if w .Flags .Has (5 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode webPage#e89c45b2: field embed_type: %w" , err )
}
w .EmbedType = value
}
if w .Flags .Has (6 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode webPage#e89c45b2: field embed_width: %w" , err )
}
w .EmbedWidth = value
}
if w .Flags .Has (6 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode webPage#e89c45b2: field embed_height: %w" , err )
}
w .EmbedHeight = value
}
if w .Flags .Has (7 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode webPage#e89c45b2: field duration: %w" , err )
}
w .Duration = value
}
if w .Flags .Has (8 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode webPage#e89c45b2: field author: %w" , err )
}
w .Author = value
}
if w .Flags .Has (9 ) {
value , err := DecodeDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode webPage#e89c45b2: field document: %w" , err )
}
w .Document = value
}
if w .Flags .Has (10 ) {
if err := w .CachedPage .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode webPage#e89c45b2: field cached_page: %w" , err )
}
}
if w .Flags .Has (12 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode webPage#e89c45b2: field attributes: %w" , err )
}
if headerLen > 0 {
w .Attributes = make ([]WebPageAttributeClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeWebPageAttribute (b )
if err != nil {
return fmt .Errorf ("unable to decode webPage#e89c45b2: field attributes: %w" , err )
}
w .Attributes = append (w .Attributes , value )
}
}
return nil
}
func (w *WebPage ) SetHasLargeMedia (value bool ) {
if value {
w .Flags .Set (13 )
w .HasLargeMedia = true
} else {
w .Flags .Unset (13 )
w .HasLargeMedia = false
}
}
func (w *WebPage ) GetHasLargeMedia () (value bool ) {
if w == nil {
return
}
return w .Flags .Has (13 )
}
func (w *WebPage ) GetID () (value int64 ) {
if w == nil {
return
}
return w .ID
}
func (w *WebPage ) GetURL () (value string ) {
if w == nil {
return
}
return w .URL
}
func (w *WebPage ) GetDisplayURL () (value string ) {
if w == nil {
return
}
return w .DisplayURL
}
func (w *WebPage ) GetHash () (value int ) {
if w == nil {
return
}
return w .Hash
}
func (w *WebPage ) SetType (value string ) {
w .Flags .Set (0 )
w .Type = value
}
func (w *WebPage ) GetType () (value string , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (0 ) {
return value , false
}
return w .Type , true
}
func (w *WebPage ) SetSiteName (value string ) {
w .Flags .Set (1 )
w .SiteName = value
}
func (w *WebPage ) GetSiteName () (value string , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (1 ) {
return value , false
}
return w .SiteName , true
}
func (w *WebPage ) SetTitle (value string ) {
w .Flags .Set (2 )
w .Title = value
}
func (w *WebPage ) GetTitle () (value string , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (2 ) {
return value , false
}
return w .Title , true
}
func (w *WebPage ) SetDescription (value string ) {
w .Flags .Set (3 )
w .Description = value
}
func (w *WebPage ) GetDescription () (value string , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (3 ) {
return value , false
}
return w .Description , true
}
func (w *WebPage ) SetPhoto (value PhotoClass ) {
w .Flags .Set (4 )
w .Photo = value
}
func (w *WebPage ) GetPhoto () (value PhotoClass , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (4 ) {
return value , false
}
return w .Photo , true
}
func (w *WebPage ) SetEmbedURL (value string ) {
w .Flags .Set (5 )
w .EmbedURL = value
}
func (w *WebPage ) GetEmbedURL () (value string , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (5 ) {
return value , false
}
return w .EmbedURL , true
}
func (w *WebPage ) SetEmbedType (value string ) {
w .Flags .Set (5 )
w .EmbedType = value
}
func (w *WebPage ) GetEmbedType () (value string , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (5 ) {
return value , false
}
return w .EmbedType , true
}
func (w *WebPage ) SetEmbedWidth (value int ) {
w .Flags .Set (6 )
w .EmbedWidth = value
}
func (w *WebPage ) GetEmbedWidth () (value int , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (6 ) {
return value , false
}
return w .EmbedWidth , true
}
func (w *WebPage ) SetEmbedHeight (value int ) {
w .Flags .Set (6 )
w .EmbedHeight = value
}
func (w *WebPage ) GetEmbedHeight () (value int , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (6 ) {
return value , false
}
return w .EmbedHeight , true
}
func (w *WebPage ) SetDuration (value int ) {
w .Flags .Set (7 )
w .Duration = value
}
func (w *WebPage ) GetDuration () (value int , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (7 ) {
return value , false
}
return w .Duration , true
}
func (w *WebPage ) SetAuthor (value string ) {
w .Flags .Set (8 )
w .Author = value
}
func (w *WebPage ) GetAuthor () (value string , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (8 ) {
return value , false
}
return w .Author , true
}
func (w *WebPage ) SetDocument (value DocumentClass ) {
w .Flags .Set (9 )
w .Document = value
}
func (w *WebPage ) GetDocument () (value DocumentClass , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (9 ) {
return value , false
}
return w .Document , true
}
func (w *WebPage ) SetCachedPage (value Page ) {
w .Flags .Set (10 )
w .CachedPage = value
}
func (w *WebPage ) GetCachedPage () (value Page , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (10 ) {
return value , false
}
return w .CachedPage , true
}
func (w *WebPage ) SetAttributes (value []WebPageAttributeClass ) {
w .Flags .Set (12 )
w .Attributes = value
}
func (w *WebPage ) GetAttributes () (value []WebPageAttributeClass , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (12 ) {
return value , false
}
return w .Attributes , true
}
func (w *WebPage ) MapAttributes () (value WebPageAttributeClassArray , ok bool ) {
if !w .Flags .Has (12 ) {
return value , false
}
return WebPageAttributeClassArray (w .Attributes ), true
}
type WebPageNotModified struct {
Flags bin .Fields
CachedPageViews int
}
const WebPageNotModifiedTypeID = 0x7311ca11
func (w WebPageNotModified ) construct () WebPageClass { return &w }
var (
_ bin .Encoder = &WebPageNotModified {}
_ bin .Decoder = &WebPageNotModified {}
_ bin .BareEncoder = &WebPageNotModified {}
_ bin .BareDecoder = &WebPageNotModified {}
_ WebPageClass = &WebPageNotModified {}
)
func (w *WebPageNotModified ) Zero () bool {
if w == nil {
return true
}
if !(w .Flags .Zero ()) {
return false
}
if !(w .CachedPageViews == 0 ) {
return false
}
return true
}
func (w *WebPageNotModified ) String () string {
if w == nil {
return "WebPageNotModified(nil)"
}
type Alias WebPageNotModified
return fmt .Sprintf ("WebPageNotModified%+v" , Alias (*w ))
}
func (w *WebPageNotModified ) FillFrom (from interface {
GetCachedPageViews () (value int , ok bool )
}) {
if val , ok := from .GetCachedPageViews (); ok {
w .CachedPageViews = val
}
}
func (*WebPageNotModified ) TypeID () uint32 {
return WebPageNotModifiedTypeID
}
func (*WebPageNotModified ) TypeName () string {
return "webPageNotModified"
}
func (w *WebPageNotModified ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "webPageNotModified" ,
ID : WebPageNotModifiedTypeID ,
}
if w == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "CachedPageViews" ,
SchemaName : "cached_page_views" ,
Null : !w .Flags .Has (0 ),
},
}
return typ
}
func (w *WebPageNotModified ) SetFlags () {
if !(w .CachedPageViews == 0 ) {
w .Flags .Set (0 )
}
}
func (w *WebPageNotModified ) Encode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode webPageNotModified#7311ca11 as nil" )
}
b .PutID (WebPageNotModifiedTypeID )
return w .EncodeBare (b )
}
func (w *WebPageNotModified ) EncodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode webPageNotModified#7311ca11 as nil" )
}
w .SetFlags ()
if err := w .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode webPageNotModified#7311ca11: field flags: %w" , err )
}
if w .Flags .Has (0 ) {
b .PutInt (w .CachedPageViews )
}
return nil
}
func (w *WebPageNotModified ) Decode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode webPageNotModified#7311ca11 to nil" )
}
if err := b .ConsumeID (WebPageNotModifiedTypeID ); err != nil {
return fmt .Errorf ("unable to decode webPageNotModified#7311ca11: %w" , err )
}
return w .DecodeBare (b )
}
func (w *WebPageNotModified ) DecodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode webPageNotModified#7311ca11 to nil" )
}
{
if err := w .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode webPageNotModified#7311ca11: field flags: %w" , err )
}
}
if w .Flags .Has (0 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode webPageNotModified#7311ca11: field cached_page_views: %w" , err )
}
w .CachedPageViews = value
}
return nil
}
func (w *WebPageNotModified ) SetCachedPageViews (value int ) {
w .Flags .Set (0 )
w .CachedPageViews = value
}
func (w *WebPageNotModified ) GetCachedPageViews () (value int , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (0 ) {
return value , false
}
return w .CachedPageViews , true
}
const WebPageClassName = "WebPage"
type WebPageClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () WebPageClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsModified () (ModifiedWebPage , bool )
}
type ModifiedWebPage interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () WebPageClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetID () (value int64 )
}
func (w *WebPageEmpty ) AsModified () (ModifiedWebPage , bool ) {
value , ok := (WebPageClass (w )).(ModifiedWebPage )
return value , ok
}
func (w *WebPagePending ) AsModified () (ModifiedWebPage , bool ) {
value , ok := (WebPageClass (w )).(ModifiedWebPage )
return value , ok
}
func (w *WebPage ) AsModified () (ModifiedWebPage , bool ) {
value , ok := (WebPageClass (w )).(ModifiedWebPage )
return value , ok
}
func (w *WebPageNotModified ) AsModified () (ModifiedWebPage , bool ) {
value , ok := (WebPageClass (w )).(ModifiedWebPage )
return value , ok
}
func DecodeWebPage (buf *bin .Buffer ) (WebPageClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case WebPageEmptyTypeID :
v := WebPageEmpty {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode WebPageClass: %w" , err )
}
return &v , nil
case WebPagePendingTypeID :
v := WebPagePending {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode WebPageClass: %w" , err )
}
return &v , nil
case WebPageTypeID :
v := WebPage {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode WebPageClass: %w" , err )
}
return &v , nil
case WebPageNotModifiedTypeID :
v := WebPageNotModified {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode WebPageClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode WebPageClass: %w" , bin .NewUnexpectedID (id ))
}
}
type WebPageBox struct {
WebPage WebPageClass
}
func (b *WebPageBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode WebPageBox to nil" )
}
v , err := DecodeWebPage (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .WebPage = v
return nil
}
func (b *WebPageBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .WebPage == nil {
return fmt .Errorf ("unable to encode WebPageClass as nil" )
}
return b .WebPage .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 .