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 WallPaper struct {
ID int64
Flags bin .Fields
Creator bool
Default bool
Pattern bool
Dark bool
AccessHash int64
Slug string
Document DocumentClass
Settings WallPaperSettings
}
const WallPaperTypeID = 0xa437c3ed
func (w WallPaper ) construct () WallPaperClass { return &w }
var (
_ bin .Encoder = &WallPaper {}
_ bin .Decoder = &WallPaper {}
_ bin .BareEncoder = &WallPaper {}
_ bin .BareDecoder = &WallPaper {}
_ WallPaperClass = &WallPaper {}
)
func (w *WallPaper ) Zero () bool {
if w == nil {
return true
}
if !(w .ID == 0 ) {
return false
}
if !(w .Flags .Zero ()) {
return false
}
if !(w .Creator == false ) {
return false
}
if !(w .Default == false ) {
return false
}
if !(w .Pattern == false ) {
return false
}
if !(w .Dark == false ) {
return false
}
if !(w .AccessHash == 0 ) {
return false
}
if !(w .Slug == "" ) {
return false
}
if !(w .Document == nil ) {
return false
}
if !(w .Settings .Zero ()) {
return false
}
return true
}
func (w *WallPaper ) String () string {
if w == nil {
return "WallPaper(nil)"
}
type Alias WallPaper
return fmt .Sprintf ("WallPaper%+v" , Alias (*w ))
}
func (w *WallPaper ) FillFrom (from interface {
GetID () (value int64 )
GetCreator () (value bool )
GetDefault () (value bool )
GetPattern () (value bool )
GetDark () (value bool )
GetAccessHash () (value int64 )
GetSlug () (value string )
GetDocument () (value DocumentClass )
GetSettings () (value WallPaperSettings , ok bool )
}) {
w .ID = from .GetID ()
w .Creator = from .GetCreator ()
w .Default = from .GetDefault ()
w .Pattern = from .GetPattern ()
w .Dark = from .GetDark ()
w .AccessHash = from .GetAccessHash ()
w .Slug = from .GetSlug ()
w .Document = from .GetDocument ()
if val , ok := from .GetSettings (); ok {
w .Settings = val
}
}
func (*WallPaper ) TypeID () uint32 {
return WallPaperTypeID
}
func (*WallPaper ) TypeName () string {
return "wallPaper"
}
func (w *WallPaper ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "wallPaper" ,
ID : WallPaperTypeID ,
}
if w == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Creator" ,
SchemaName : "creator" ,
Null : !w .Flags .Has (0 ),
},
{
Name : "Default" ,
SchemaName : "default" ,
Null : !w .Flags .Has (1 ),
},
{
Name : "Pattern" ,
SchemaName : "pattern" ,
Null : !w .Flags .Has (3 ),
},
{
Name : "Dark" ,
SchemaName : "dark" ,
Null : !w .Flags .Has (4 ),
},
{
Name : "AccessHash" ,
SchemaName : "access_hash" ,
},
{
Name : "Slug" ,
SchemaName : "slug" ,
},
{
Name : "Document" ,
SchemaName : "document" ,
},
{
Name : "Settings" ,
SchemaName : "settings" ,
Null : !w .Flags .Has (2 ),
},
}
return typ
}
func (w *WallPaper ) SetFlags () {
if !(w .Creator == false ) {
w .Flags .Set (0 )
}
if !(w .Default == false ) {
w .Flags .Set (1 )
}
if !(w .Pattern == false ) {
w .Flags .Set (3 )
}
if !(w .Dark == false ) {
w .Flags .Set (4 )
}
if !(w .Settings .Zero ()) {
w .Flags .Set (2 )
}
}
func (w *WallPaper ) Encode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode wallPaper#a437c3ed as nil" )
}
b .PutID (WallPaperTypeID )
return w .EncodeBare (b )
}
func (w *WallPaper ) EncodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode wallPaper#a437c3ed as nil" )
}
w .SetFlags ()
b .PutLong (w .ID )
if err := w .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallPaper#a437c3ed: field flags: %w" , err )
}
b .PutLong (w .AccessHash )
b .PutString (w .Slug )
if w .Document == nil {
return fmt .Errorf ("unable to encode wallPaper#a437c3ed: field document is nil" )
}
if err := w .Document .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallPaper#a437c3ed: field document: %w" , err )
}
if w .Flags .Has (2 ) {
if err := w .Settings .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallPaper#a437c3ed: field settings: %w" , err )
}
}
return nil
}
func (w *WallPaper ) Decode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode wallPaper#a437c3ed to nil" )
}
if err := b .ConsumeID (WallPaperTypeID ); err != nil {
return fmt .Errorf ("unable to decode wallPaper#a437c3ed: %w" , err )
}
return w .DecodeBare (b )
}
func (w *WallPaper ) DecodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode wallPaper#a437c3ed to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode wallPaper#a437c3ed: field id: %w" , err )
}
w .ID = value
}
{
if err := w .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode wallPaper#a437c3ed: field flags: %w" , err )
}
}
w .Creator = w .Flags .Has (0 )
w .Default = w .Flags .Has (1 )
w .Pattern = w .Flags .Has (3 )
w .Dark = w .Flags .Has (4 )
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode wallPaper#a437c3ed: field access_hash: %w" , err )
}
w .AccessHash = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode wallPaper#a437c3ed: field slug: %w" , err )
}
w .Slug = value
}
{
value , err := DecodeDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode wallPaper#a437c3ed: field document: %w" , err )
}
w .Document = value
}
if w .Flags .Has (2 ) {
if err := w .Settings .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode wallPaper#a437c3ed: field settings: %w" , err )
}
}
return nil
}
func (w *WallPaper ) GetID () (value int64 ) {
if w == nil {
return
}
return w .ID
}
func (w *WallPaper ) SetCreator (value bool ) {
if value {
w .Flags .Set (0 )
w .Creator = true
} else {
w .Flags .Unset (0 )
w .Creator = false
}
}
func (w *WallPaper ) GetCreator () (value bool ) {
if w == nil {
return
}
return w .Flags .Has (0 )
}
func (w *WallPaper ) SetDefault (value bool ) {
if value {
w .Flags .Set (1 )
w .Default = true
} else {
w .Flags .Unset (1 )
w .Default = false
}
}
func (w *WallPaper ) GetDefault () (value bool ) {
if w == nil {
return
}
return w .Flags .Has (1 )
}
func (w *WallPaper ) SetPattern (value bool ) {
if value {
w .Flags .Set (3 )
w .Pattern = true
} else {
w .Flags .Unset (3 )
w .Pattern = false
}
}
func (w *WallPaper ) GetPattern () (value bool ) {
if w == nil {
return
}
return w .Flags .Has (3 )
}
func (w *WallPaper ) SetDark (value bool ) {
if value {
w .Flags .Set (4 )
w .Dark = true
} else {
w .Flags .Unset (4 )
w .Dark = false
}
}
func (w *WallPaper ) GetDark () (value bool ) {
if w == nil {
return
}
return w .Flags .Has (4 )
}
func (w *WallPaper ) GetAccessHash () (value int64 ) {
if w == nil {
return
}
return w .AccessHash
}
func (w *WallPaper ) GetSlug () (value string ) {
if w == nil {
return
}
return w .Slug
}
func (w *WallPaper ) GetDocument () (value DocumentClass ) {
if w == nil {
return
}
return w .Document
}
func (w *WallPaper ) SetSettings (value WallPaperSettings ) {
w .Flags .Set (2 )
w .Settings = value
}
func (w *WallPaper ) GetSettings () (value WallPaperSettings , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (2 ) {
return value , false
}
return w .Settings , true
}
type WallPaperNoFile struct {
ID int64
Flags bin .Fields
Default bool
Dark bool
Settings WallPaperSettings
}
const WallPaperNoFileTypeID = 0xe0804116
func (w WallPaperNoFile ) construct () WallPaperClass { return &w }
var (
_ bin .Encoder = &WallPaperNoFile {}
_ bin .Decoder = &WallPaperNoFile {}
_ bin .BareEncoder = &WallPaperNoFile {}
_ bin .BareDecoder = &WallPaperNoFile {}
_ WallPaperClass = &WallPaperNoFile {}
)
func (w *WallPaperNoFile ) Zero () bool {
if w == nil {
return true
}
if !(w .ID == 0 ) {
return false
}
if !(w .Flags .Zero ()) {
return false
}
if !(w .Default == false ) {
return false
}
if !(w .Dark == false ) {
return false
}
if !(w .Settings .Zero ()) {
return false
}
return true
}
func (w *WallPaperNoFile ) String () string {
if w == nil {
return "WallPaperNoFile(nil)"
}
type Alias WallPaperNoFile
return fmt .Sprintf ("WallPaperNoFile%+v" , Alias (*w ))
}
func (w *WallPaperNoFile ) FillFrom (from interface {
GetID () (value int64 )
GetDefault () (value bool )
GetDark () (value bool )
GetSettings () (value WallPaperSettings , ok bool )
}) {
w .ID = from .GetID ()
w .Default = from .GetDefault ()
w .Dark = from .GetDark ()
if val , ok := from .GetSettings (); ok {
w .Settings = val
}
}
func (*WallPaperNoFile ) TypeID () uint32 {
return WallPaperNoFileTypeID
}
func (*WallPaperNoFile ) TypeName () string {
return "wallPaperNoFile"
}
func (w *WallPaperNoFile ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "wallPaperNoFile" ,
ID : WallPaperNoFileTypeID ,
}
if w == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Default" ,
SchemaName : "default" ,
Null : !w .Flags .Has (1 ),
},
{
Name : "Dark" ,
SchemaName : "dark" ,
Null : !w .Flags .Has (4 ),
},
{
Name : "Settings" ,
SchemaName : "settings" ,
Null : !w .Flags .Has (2 ),
},
}
return typ
}
func (w *WallPaperNoFile ) SetFlags () {
if !(w .Default == false ) {
w .Flags .Set (1 )
}
if !(w .Dark == false ) {
w .Flags .Set (4 )
}
if !(w .Settings .Zero ()) {
w .Flags .Set (2 )
}
}
func (w *WallPaperNoFile ) Encode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode wallPaperNoFile#e0804116 as nil" )
}
b .PutID (WallPaperNoFileTypeID )
return w .EncodeBare (b )
}
func (w *WallPaperNoFile ) EncodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't encode wallPaperNoFile#e0804116 as nil" )
}
w .SetFlags ()
b .PutLong (w .ID )
if err := w .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallPaperNoFile#e0804116: field flags: %w" , err )
}
if w .Flags .Has (2 ) {
if err := w .Settings .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallPaperNoFile#e0804116: field settings: %w" , err )
}
}
return nil
}
func (w *WallPaperNoFile ) Decode (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode wallPaperNoFile#e0804116 to nil" )
}
if err := b .ConsumeID (WallPaperNoFileTypeID ); err != nil {
return fmt .Errorf ("unable to decode wallPaperNoFile#e0804116: %w" , err )
}
return w .DecodeBare (b )
}
func (w *WallPaperNoFile ) DecodeBare (b *bin .Buffer ) error {
if w == nil {
return fmt .Errorf ("can't decode wallPaperNoFile#e0804116 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode wallPaperNoFile#e0804116: field id: %w" , err )
}
w .ID = value
}
{
if err := w .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode wallPaperNoFile#e0804116: field flags: %w" , err )
}
}
w .Default = w .Flags .Has (1 )
w .Dark = w .Flags .Has (4 )
if w .Flags .Has (2 ) {
if err := w .Settings .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode wallPaperNoFile#e0804116: field settings: %w" , err )
}
}
return nil
}
func (w *WallPaperNoFile ) GetID () (value int64 ) {
if w == nil {
return
}
return w .ID
}
func (w *WallPaperNoFile ) SetDefault (value bool ) {
if value {
w .Flags .Set (1 )
w .Default = true
} else {
w .Flags .Unset (1 )
w .Default = false
}
}
func (w *WallPaperNoFile ) GetDefault () (value bool ) {
if w == nil {
return
}
return w .Flags .Has (1 )
}
func (w *WallPaperNoFile ) SetDark (value bool ) {
if value {
w .Flags .Set (4 )
w .Dark = true
} else {
w .Flags .Unset (4 )
w .Dark = false
}
}
func (w *WallPaperNoFile ) GetDark () (value bool ) {
if w == nil {
return
}
return w .Flags .Has (4 )
}
func (w *WallPaperNoFile ) SetSettings (value WallPaperSettings ) {
w .Flags .Set (2 )
w .Settings = value
}
func (w *WallPaperNoFile ) GetSettings () (value WallPaperSettings , ok bool ) {
if w == nil {
return
}
if !w .Flags .Has (2 ) {
return value , false
}
return w .Settings , true
}
const WallPaperClassName = "WallPaper"
type WallPaperClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () WallPaperClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetID () (value int64 )
GetDefault () (value bool )
GetDark () (value bool )
GetSettings () (value WallPaperSettings , ok bool )
}
func (w *WallPaper ) AsInput () *InputWallPaper {
value := new (InputWallPaper )
value .ID = w .GetID ()
value .AccessHash = w .GetAccessHash ()
return value
}
func (w *WallPaper ) AsInputWallPaperSlug () *InputWallPaperSlug {
value := new (InputWallPaperSlug )
value .Slug = w .GetSlug ()
return value
}
func (w *WallPaper ) AsInputWallPaperNoFile () *InputWallPaperNoFile {
value := new (InputWallPaperNoFile )
value .ID = w .GetID ()
return value
}
func (w *WallPaperNoFile ) AsInput () *InputWallPaperNoFile {
value := new (InputWallPaperNoFile )
value .ID = w .GetID ()
return value
}
func DecodeWallPaper (buf *bin .Buffer ) (WallPaperClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case WallPaperTypeID :
v := WallPaper {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode WallPaperClass: %w" , err )
}
return &v , nil
case WallPaperNoFileTypeID :
v := WallPaperNoFile {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode WallPaperClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode WallPaperClass: %w" , bin .NewUnexpectedID (id ))
}
}
type WallPaperBox struct {
WallPaper WallPaperClass
}
func (b *WallPaperBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode WallPaperBox to nil" )
}
v , err := DecodeWallPaper (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .WallPaper = v
return nil
}
func (b *WallPaperBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .WallPaper == nil {
return fmt .Errorf ("unable to encode WallPaperClass as nil" )
}
return b .WallPaper .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 .