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 WebPageAttributeTheme struct {
Flags bin .Fields
Documents []DocumentClass
Settings ThemeSettings
}
const WebPageAttributeThemeTypeID = 0x54b56617
func (w WebPageAttributeTheme ) construct () WebPageAttributeClass { return &w }
var (
_ bin .Encoder = &WebPageAttributeTheme {}
_ bin .Decoder = &WebPageAttributeTheme {}
_ bin .BareEncoder = &WebPageAttributeTheme {}
_ bin .BareDecoder = &WebPageAttributeTheme {}
_ WebPageAttributeClass = &WebPageAttributeTheme {}
)
func (w *WebPageAttributeTheme ) Zero () bool {
if w == nil {
return true
}
if !(w .Flags .Zero ()) {
return false
}
if !(w .Documents == nil ) {
return false
}
if !(w .Settings .Zero ()) {
return false
}
return true
}
func (w *WebPageAttributeTheme ) String () string {
if w == nil {
return "WebPageAttributeTheme(nil)"
}
type Alias WebPageAttributeTheme
return fmt .Sprintf ("WebPageAttributeTheme%+v" , Alias (*w ))
}
func (w *WebPageAttributeTheme ) FillFrom (from interface {
GetDocuments () (value []DocumentClass , ok bool )
GetSettings () (value ThemeSettings , ok bool )
}) {
if val , ok := from .GetDocuments (); ok {
w .Documents = val
}
if val , ok := from .GetSettings (); ok {
w .Settings = val
}
}
func (*WebPageAttributeTheme ) TypeID () uint32 {
return WebPageAttributeThemeTypeID
}
func (*WebPageAttributeTheme ) TypeName () string {
return "webPageAttributeTheme"
}
func (w *WebPageAttributeTheme ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "webPageAttributeTheme" ,
ID : WebPageAttributeThemeTypeID ,
}
if w == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Documents" ,
SchemaName : "documents" ,
Null : !w .Flags .Has (0 ),
},
{
Name : "Settings" ,
SchemaName : "settings" ,
Null : !w .Flags .Has (1 ),
},
}
return typ
}
func (w *WebPageAttributeTheme ) SetFlags () {
if !(w .Documents == nil ) {
w .Flags .Set (0 )
}
if !(w .Settings .Zero ()) {
w .Flags .Set (1 )
}
}
func (w *WebPageAttributeTheme ) Encode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode webPageAttributeTheme#54b56617 as nil" )
}
b .PutID (WebPageAttributeThemeTypeID )
return w .EncodeBare (b )
}
func (w *WebPageAttributeTheme ) EncodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode webPageAttributeTheme#54b56617 as nil" )
}
w .SetFlags ()
if err := w .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode webPageAttributeTheme#54b56617: field flags: %w" , err )
}
if w .Flags .Has (0 ) {
b .PutVectorHeader (len (w .Documents ))
for idx , v := range w .Documents {
if v == nil {
return fmt .Errorf ("unable to encode webPageAttributeTheme#54b56617: field documents element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode webPageAttributeTheme#54b56617: field documents element with index %d: %w" , idx , err )
}
}
}
if w .Flags .Has (1 ) {
if err := w .Settings .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode webPageAttributeTheme#54b56617: field settings: %w" , err )
}
}
return nil
}
func (w *WebPageAttributeTheme ) Decode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode webPageAttributeTheme#54b56617 to nil" )
}
if err := b .ConsumeID (WebPageAttributeThemeTypeID ); err != nil {
return fmt .Errorf ("unable to decode webPageAttributeTheme#54b56617: %w" , err )
}
return w .DecodeBare (b )
}
func (w *WebPageAttributeTheme ) DecodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode webPageAttributeTheme#54b56617 to nil" )
}
{
if err := w .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode webPageAttributeTheme#54b56617: field flags: %w" , err )
}
}
if w .Flags .Has (0 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode webPageAttributeTheme#54b56617: field documents: %w" , err )
}
if headerLen > 0 {
w .Documents = make ([]DocumentClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode webPageAttributeTheme#54b56617: field documents: %w" , err )
}
w .Documents = append (w .Documents , value )
}
}
if w .Flags .Has (1 ) {
if err := w .Settings .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode webPageAttributeTheme#54b56617: field settings: %w" , err )
}
}
return nil
}
func (w *WebPageAttributeTheme ) SetDocuments (value []DocumentClass ) {
w .Flags .Set (0 )
w .Documents = value
}
func (w *WebPageAttributeTheme ) GetDocuments () (value []DocumentClass , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (0 ) {
return value , false
}
return w .Documents , true
}
func (w *WebPageAttributeTheme ) SetSettings (value ThemeSettings ) {
w .Flags .Set (1 )
w .Settings = value
}
func (w *WebPageAttributeTheme ) GetSettings () (value ThemeSettings , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (1 ) {
return value , false
}
return w .Settings , true
}
func (w *WebPageAttributeTheme ) MapDocuments () (value DocumentClassArray , ok bool ) {
if !w .Flags .Has (0 ) {
return value , false
}
return DocumentClassArray (w .Documents ), true
}
type WebPageAttributeStory struct {
Flags bin .Fields
Peer PeerClass
ID int
Story StoryItemClass
}
const WebPageAttributeStoryTypeID = 0x2e94c3e7
func (w WebPageAttributeStory ) construct () WebPageAttributeClass { return &w }
var (
_ bin .Encoder = &WebPageAttributeStory {}
_ bin .Decoder = &WebPageAttributeStory {}
_ bin .BareEncoder = &WebPageAttributeStory {}
_ bin .BareDecoder = &WebPageAttributeStory {}
_ WebPageAttributeClass = &WebPageAttributeStory {}
)
func (w *WebPageAttributeStory ) Zero () bool {
if w == nil {
return true
}
if !(w .Flags .Zero ()) {
return false
}
if !(w .Peer == nil ) {
return false
}
if !(w .ID == 0 ) {
return false
}
if !(w .Story == nil ) {
return false
}
return true
}
func (w *WebPageAttributeStory ) String () string {
if w == nil {
return "WebPageAttributeStory(nil)"
}
type Alias WebPageAttributeStory
return fmt .Sprintf ("WebPageAttributeStory%+v" , Alias (*w ))
}
func (w *WebPageAttributeStory ) FillFrom (from interface {
GetPeer () (value PeerClass )
GetID () (value int )
GetStory () (value StoryItemClass , ok bool )
}) {
w .Peer = from .GetPeer ()
w .ID = from .GetID ()
if val , ok := from .GetStory (); ok {
w .Story = val
}
}
func (*WebPageAttributeStory ) TypeID () uint32 {
return WebPageAttributeStoryTypeID
}
func (*WebPageAttributeStory ) TypeName () string {
return "webPageAttributeStory"
}
func (w *WebPageAttributeStory ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "webPageAttributeStory" ,
ID : WebPageAttributeStoryTypeID ,
}
if w == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Story" ,
SchemaName : "story" ,
Null : !w .Flags .Has (0 ),
},
}
return typ
}
func (w *WebPageAttributeStory ) SetFlags () {
if !(w .Story == nil ) {
w .Flags .Set (0 )
}
}
func (w *WebPageAttributeStory ) Encode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode webPageAttributeStory#2e94c3e7 as nil" )
}
b .PutID (WebPageAttributeStoryTypeID )
return w .EncodeBare (b )
}
func (w *WebPageAttributeStory ) EncodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode webPageAttributeStory#2e94c3e7 as nil" )
}
w .SetFlags ()
if err := w .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode webPageAttributeStory#2e94c3e7: field flags: %w" , err )
}
if w .Peer == nil {
return fmt .Errorf ("unable to encode webPageAttributeStory#2e94c3e7: field peer is nil" )
}
if err := w .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode webPageAttributeStory#2e94c3e7: field peer: %w" , err )
}
b .PutInt (w .ID )
if w .Flags .Has (0 ) {
if w .Story == nil {
return fmt .Errorf ("unable to encode webPageAttributeStory#2e94c3e7: field story is nil" )
}
if err := w .Story .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode webPageAttributeStory#2e94c3e7: field story: %w" , err )
}
}
return nil
}
func (w *WebPageAttributeStory ) Decode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode webPageAttributeStory#2e94c3e7 to nil" )
}
if err := b .ConsumeID (WebPageAttributeStoryTypeID ); err != nil {
return fmt .Errorf ("unable to decode webPageAttributeStory#2e94c3e7: %w" , err )
}
return w .DecodeBare (b )
}
func (w *WebPageAttributeStory ) DecodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode webPageAttributeStory#2e94c3e7 to nil" )
}
{
if err := w .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode webPageAttributeStory#2e94c3e7: field flags: %w" , err )
}
}
{
value , err := DecodePeer (b )
if err != nil {
return fmt .Errorf ("unable to decode webPageAttributeStory#2e94c3e7: field peer: %w" , err )
}
w .Peer = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode webPageAttributeStory#2e94c3e7: field id: %w" , err )
}
w .ID = value
}
if w .Flags .Has (0 ) {
value , err := DecodeStoryItem (b )
if err != nil {
return fmt .Errorf ("unable to decode webPageAttributeStory#2e94c3e7: field story: %w" , err )
}
w .Story = value
}
return nil
}
func (w *WebPageAttributeStory ) GetPeer () (value PeerClass ) {
if w == nil {
return
}
return w .Peer
}
func (w *WebPageAttributeStory ) GetID () (value int ) {
if w == nil {
return
}
return w .ID
}
func (w *WebPageAttributeStory ) SetStory (value StoryItemClass ) {
w .Flags .Set (0 )
w .Story = value
}
func (w *WebPageAttributeStory ) GetStory () (value StoryItemClass , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (0 ) {
return value , false
}
return w .Story , true
}
const WebPageAttributeClassName = "WebPageAttribute"
type WebPageAttributeClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () WebPageAttributeClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeWebPageAttribute (buf *bin .Buffer ) (WebPageAttributeClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case WebPageAttributeThemeTypeID :
v := WebPageAttributeTheme {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode WebPageAttributeClass: %w" , err )
}
return &v , nil
case WebPageAttributeStoryTypeID :
v := WebPageAttributeStory {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode WebPageAttributeClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode WebPageAttributeClass: %w" , bin .NewUnexpectedID (id ))
}
}
type WebPageAttributeBox struct {
WebPageAttribute WebPageAttributeClass
}
func (b *WebPageAttributeBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode WebPageAttributeBox to nil" )
}
v , err := DecodeWebPageAttribute (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .WebPageAttribute = v
return nil
}
func (b *WebPageAttributeBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .WebPageAttribute == nil {
return fmt .Errorf ("unable to encode WebPageAttributeClass as nil" )
}
return b .WebPageAttribute .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 .