7a04f298d2
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
7132 lines
182 KiB
Go
7132 lines
182 KiB
Go
// Code generated by gotdgen, DO NOT EDIT.
|
|
|
|
package tdapi
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"sort"
|
|
"strings"
|
|
|
|
"go.uber.org/multierr"
|
|
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
|
|
)
|
|
|
|
// No-op definition for keeping imports.
|
|
var (
|
|
_ = bin.Buffer{}
|
|
_ = context.Background()
|
|
_ = fmt.Stringer(nil)
|
|
_ = strings.Builder{}
|
|
_ = errors.Is
|
|
_ = multierr.AppendInto
|
|
_ = sort.Ints
|
|
_ = tdp.Format
|
|
_ = tgerr.Error{}
|
|
_ = tdjson.Encoder{}
|
|
)
|
|
|
|
// PageBlockTitle represents TL type `pageBlockTitle#6122b610`.
|
|
type PageBlockTitle struct {
|
|
// Title
|
|
Title RichTextClass
|
|
}
|
|
|
|
// PageBlockTitleTypeID is TL type id of PageBlockTitle.
|
|
const PageBlockTitleTypeID = 0x6122b610
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockTitle) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockTitle.
|
|
var (
|
|
_ bin.Encoder = &PageBlockTitle{}
|
|
_ bin.Decoder = &PageBlockTitle{}
|
|
_ bin.BareEncoder = &PageBlockTitle{}
|
|
_ bin.BareDecoder = &PageBlockTitle{}
|
|
|
|
_ PageBlockClass = &PageBlockTitle{}
|
|
)
|
|
|
|
func (p *PageBlockTitle) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Title == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockTitle) String() string {
|
|
if p == nil {
|
|
return "PageBlockTitle(nil)"
|
|
}
|
|
type Alias PageBlockTitle
|
|
return fmt.Sprintf("PageBlockTitle%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockTitle) TypeID() uint32 {
|
|
return PageBlockTitleTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockTitle) TypeName() string {
|
|
return "pageBlockTitle"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockTitle) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockTitle",
|
|
ID: PageBlockTitleTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Title",
|
|
SchemaName: "title",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockTitle) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockTitle#6122b610 as nil")
|
|
}
|
|
b.PutID(PageBlockTitleTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockTitle) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockTitle#6122b610 as nil")
|
|
}
|
|
if p.Title == nil {
|
|
return fmt.Errorf("unable to encode pageBlockTitle#6122b610: field title is nil")
|
|
}
|
|
if err := p.Title.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockTitle#6122b610: field title: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockTitle) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockTitle#6122b610 to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockTitleTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockTitle#6122b610: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockTitle) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockTitle#6122b610 to nil")
|
|
}
|
|
{
|
|
value, err := DecodeRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockTitle#6122b610: field title: %w", err)
|
|
}
|
|
p.Title = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockTitle) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockTitle#6122b610 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockTitle")
|
|
b.Comma()
|
|
b.FieldStart("title")
|
|
if p.Title == nil {
|
|
return fmt.Errorf("unable to encode pageBlockTitle#6122b610: field title is nil")
|
|
}
|
|
if err := p.Title.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockTitle#6122b610: field title: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockTitle) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockTitle#6122b610 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockTitle"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockTitle#6122b610: %w", err)
|
|
}
|
|
case "title":
|
|
value, err := DecodeTDLibJSONRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockTitle#6122b610: field title: %w", err)
|
|
}
|
|
p.Title = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetTitle returns value of Title field.
|
|
func (p *PageBlockTitle) GetTitle() (value RichTextClass) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Title
|
|
}
|
|
|
|
// PageBlockSubtitle represents TL type `pageBlockSubtitle#fc451e7`.
|
|
type PageBlockSubtitle struct {
|
|
// Subtitle
|
|
Subtitle RichTextClass
|
|
}
|
|
|
|
// PageBlockSubtitleTypeID is TL type id of PageBlockSubtitle.
|
|
const PageBlockSubtitleTypeID = 0xfc451e7
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockSubtitle) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockSubtitle.
|
|
var (
|
|
_ bin.Encoder = &PageBlockSubtitle{}
|
|
_ bin.Decoder = &PageBlockSubtitle{}
|
|
_ bin.BareEncoder = &PageBlockSubtitle{}
|
|
_ bin.BareDecoder = &PageBlockSubtitle{}
|
|
|
|
_ PageBlockClass = &PageBlockSubtitle{}
|
|
)
|
|
|
|
func (p *PageBlockSubtitle) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Subtitle == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockSubtitle) String() string {
|
|
if p == nil {
|
|
return "PageBlockSubtitle(nil)"
|
|
}
|
|
type Alias PageBlockSubtitle
|
|
return fmt.Sprintf("PageBlockSubtitle%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockSubtitle) TypeID() uint32 {
|
|
return PageBlockSubtitleTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockSubtitle) TypeName() string {
|
|
return "pageBlockSubtitle"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockSubtitle) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockSubtitle",
|
|
ID: PageBlockSubtitleTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Subtitle",
|
|
SchemaName: "subtitle",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockSubtitle) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockSubtitle#fc451e7 as nil")
|
|
}
|
|
b.PutID(PageBlockSubtitleTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockSubtitle) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockSubtitle#fc451e7 as nil")
|
|
}
|
|
if p.Subtitle == nil {
|
|
return fmt.Errorf("unable to encode pageBlockSubtitle#fc451e7: field subtitle is nil")
|
|
}
|
|
if err := p.Subtitle.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockSubtitle#fc451e7: field subtitle: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockSubtitle) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockSubtitle#fc451e7 to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockSubtitleTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockSubtitle#fc451e7: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockSubtitle) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockSubtitle#fc451e7 to nil")
|
|
}
|
|
{
|
|
value, err := DecodeRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockSubtitle#fc451e7: field subtitle: %w", err)
|
|
}
|
|
p.Subtitle = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockSubtitle) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockSubtitle#fc451e7 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockSubtitle")
|
|
b.Comma()
|
|
b.FieldStart("subtitle")
|
|
if p.Subtitle == nil {
|
|
return fmt.Errorf("unable to encode pageBlockSubtitle#fc451e7: field subtitle is nil")
|
|
}
|
|
if err := p.Subtitle.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockSubtitle#fc451e7: field subtitle: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockSubtitle) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockSubtitle#fc451e7 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockSubtitle"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockSubtitle#fc451e7: %w", err)
|
|
}
|
|
case "subtitle":
|
|
value, err := DecodeTDLibJSONRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockSubtitle#fc451e7: field subtitle: %w", err)
|
|
}
|
|
p.Subtitle = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetSubtitle returns value of Subtitle field.
|
|
func (p *PageBlockSubtitle) GetSubtitle() (value RichTextClass) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Subtitle
|
|
}
|
|
|
|
// PageBlockAuthorDate represents TL type `pageBlockAuthorDate#4d7ff410`.
|
|
type PageBlockAuthorDate struct {
|
|
// Author
|
|
Author RichTextClass
|
|
// Point in time (Unix timestamp) when the article was published; 0 if unknown
|
|
PublishDate int32
|
|
}
|
|
|
|
// PageBlockAuthorDateTypeID is TL type id of PageBlockAuthorDate.
|
|
const PageBlockAuthorDateTypeID = 0x4d7ff410
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockAuthorDate) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockAuthorDate.
|
|
var (
|
|
_ bin.Encoder = &PageBlockAuthorDate{}
|
|
_ bin.Decoder = &PageBlockAuthorDate{}
|
|
_ bin.BareEncoder = &PageBlockAuthorDate{}
|
|
_ bin.BareDecoder = &PageBlockAuthorDate{}
|
|
|
|
_ PageBlockClass = &PageBlockAuthorDate{}
|
|
)
|
|
|
|
func (p *PageBlockAuthorDate) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Author == nil) {
|
|
return false
|
|
}
|
|
if !(p.PublishDate == 0) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockAuthorDate) String() string {
|
|
if p == nil {
|
|
return "PageBlockAuthorDate(nil)"
|
|
}
|
|
type Alias PageBlockAuthorDate
|
|
return fmt.Sprintf("PageBlockAuthorDate%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockAuthorDate) TypeID() uint32 {
|
|
return PageBlockAuthorDateTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockAuthorDate) TypeName() string {
|
|
return "pageBlockAuthorDate"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockAuthorDate) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockAuthorDate",
|
|
ID: PageBlockAuthorDateTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Author",
|
|
SchemaName: "author",
|
|
},
|
|
{
|
|
Name: "PublishDate",
|
|
SchemaName: "publish_date",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockAuthorDate) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockAuthorDate#4d7ff410 as nil")
|
|
}
|
|
b.PutID(PageBlockAuthorDateTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockAuthorDate) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockAuthorDate#4d7ff410 as nil")
|
|
}
|
|
if p.Author == nil {
|
|
return fmt.Errorf("unable to encode pageBlockAuthorDate#4d7ff410: field author is nil")
|
|
}
|
|
if err := p.Author.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockAuthorDate#4d7ff410: field author: %w", err)
|
|
}
|
|
b.PutInt32(p.PublishDate)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockAuthorDate) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockAuthorDate#4d7ff410 to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockAuthorDateTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAuthorDate#4d7ff410: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockAuthorDate) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockAuthorDate#4d7ff410 to nil")
|
|
}
|
|
{
|
|
value, err := DecodeRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAuthorDate#4d7ff410: field author: %w", err)
|
|
}
|
|
p.Author = value
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAuthorDate#4d7ff410: field publish_date: %w", err)
|
|
}
|
|
p.PublishDate = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockAuthorDate) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockAuthorDate#4d7ff410 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockAuthorDate")
|
|
b.Comma()
|
|
b.FieldStart("author")
|
|
if p.Author == nil {
|
|
return fmt.Errorf("unable to encode pageBlockAuthorDate#4d7ff410: field author is nil")
|
|
}
|
|
if err := p.Author.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockAuthorDate#4d7ff410: field author: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("publish_date")
|
|
b.PutInt32(p.PublishDate)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockAuthorDate) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockAuthorDate#4d7ff410 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockAuthorDate"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAuthorDate#4d7ff410: %w", err)
|
|
}
|
|
case "author":
|
|
value, err := DecodeTDLibJSONRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAuthorDate#4d7ff410: field author: %w", err)
|
|
}
|
|
p.Author = value
|
|
case "publish_date":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAuthorDate#4d7ff410: field publish_date: %w", err)
|
|
}
|
|
p.PublishDate = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetAuthor returns value of Author field.
|
|
func (p *PageBlockAuthorDate) GetAuthor() (value RichTextClass) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Author
|
|
}
|
|
|
|
// GetPublishDate returns value of PublishDate field.
|
|
func (p *PageBlockAuthorDate) GetPublishDate() (value int32) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.PublishDate
|
|
}
|
|
|
|
// PageBlockHeader represents TL type `pageBlockHeader#539ddd9b`.
|
|
type PageBlockHeader struct {
|
|
// Header
|
|
Header RichTextClass
|
|
}
|
|
|
|
// PageBlockHeaderTypeID is TL type id of PageBlockHeader.
|
|
const PageBlockHeaderTypeID = 0x539ddd9b
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockHeader) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockHeader.
|
|
var (
|
|
_ bin.Encoder = &PageBlockHeader{}
|
|
_ bin.Decoder = &PageBlockHeader{}
|
|
_ bin.BareEncoder = &PageBlockHeader{}
|
|
_ bin.BareDecoder = &PageBlockHeader{}
|
|
|
|
_ PageBlockClass = &PageBlockHeader{}
|
|
)
|
|
|
|
func (p *PageBlockHeader) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Header == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockHeader) String() string {
|
|
if p == nil {
|
|
return "PageBlockHeader(nil)"
|
|
}
|
|
type Alias PageBlockHeader
|
|
return fmt.Sprintf("PageBlockHeader%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockHeader) TypeID() uint32 {
|
|
return PageBlockHeaderTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockHeader) TypeName() string {
|
|
return "pageBlockHeader"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockHeader) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockHeader",
|
|
ID: PageBlockHeaderTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Header",
|
|
SchemaName: "header",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockHeader) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockHeader#539ddd9b as nil")
|
|
}
|
|
b.PutID(PageBlockHeaderTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockHeader) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockHeader#539ddd9b as nil")
|
|
}
|
|
if p.Header == nil {
|
|
return fmt.Errorf("unable to encode pageBlockHeader#539ddd9b: field header is nil")
|
|
}
|
|
if err := p.Header.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockHeader#539ddd9b: field header: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockHeader) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockHeader#539ddd9b to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockHeaderTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockHeader#539ddd9b: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockHeader) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockHeader#539ddd9b to nil")
|
|
}
|
|
{
|
|
value, err := DecodeRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockHeader#539ddd9b: field header: %w", err)
|
|
}
|
|
p.Header = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockHeader) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockHeader#539ddd9b as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockHeader")
|
|
b.Comma()
|
|
b.FieldStart("header")
|
|
if p.Header == nil {
|
|
return fmt.Errorf("unable to encode pageBlockHeader#539ddd9b: field header is nil")
|
|
}
|
|
if err := p.Header.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockHeader#539ddd9b: field header: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockHeader) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockHeader#539ddd9b to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockHeader"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockHeader#539ddd9b: %w", err)
|
|
}
|
|
case "header":
|
|
value, err := DecodeTDLibJSONRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockHeader#539ddd9b: field header: %w", err)
|
|
}
|
|
p.Header = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetHeader returns value of Header field.
|
|
func (p *PageBlockHeader) GetHeader() (value RichTextClass) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Header
|
|
}
|
|
|
|
// PageBlockSubheader represents TL type `pageBlockSubheader#4b567326`.
|
|
type PageBlockSubheader struct {
|
|
// Subheader
|
|
Subheader RichTextClass
|
|
}
|
|
|
|
// PageBlockSubheaderTypeID is TL type id of PageBlockSubheader.
|
|
const PageBlockSubheaderTypeID = 0x4b567326
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockSubheader) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockSubheader.
|
|
var (
|
|
_ bin.Encoder = &PageBlockSubheader{}
|
|
_ bin.Decoder = &PageBlockSubheader{}
|
|
_ bin.BareEncoder = &PageBlockSubheader{}
|
|
_ bin.BareDecoder = &PageBlockSubheader{}
|
|
|
|
_ PageBlockClass = &PageBlockSubheader{}
|
|
)
|
|
|
|
func (p *PageBlockSubheader) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Subheader == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockSubheader) String() string {
|
|
if p == nil {
|
|
return "PageBlockSubheader(nil)"
|
|
}
|
|
type Alias PageBlockSubheader
|
|
return fmt.Sprintf("PageBlockSubheader%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockSubheader) TypeID() uint32 {
|
|
return PageBlockSubheaderTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockSubheader) TypeName() string {
|
|
return "pageBlockSubheader"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockSubheader) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockSubheader",
|
|
ID: PageBlockSubheaderTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Subheader",
|
|
SchemaName: "subheader",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockSubheader) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockSubheader#4b567326 as nil")
|
|
}
|
|
b.PutID(PageBlockSubheaderTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockSubheader) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockSubheader#4b567326 as nil")
|
|
}
|
|
if p.Subheader == nil {
|
|
return fmt.Errorf("unable to encode pageBlockSubheader#4b567326: field subheader is nil")
|
|
}
|
|
if err := p.Subheader.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockSubheader#4b567326: field subheader: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockSubheader) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockSubheader#4b567326 to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockSubheaderTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockSubheader#4b567326: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockSubheader) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockSubheader#4b567326 to nil")
|
|
}
|
|
{
|
|
value, err := DecodeRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockSubheader#4b567326: field subheader: %w", err)
|
|
}
|
|
p.Subheader = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockSubheader) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockSubheader#4b567326 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockSubheader")
|
|
b.Comma()
|
|
b.FieldStart("subheader")
|
|
if p.Subheader == nil {
|
|
return fmt.Errorf("unable to encode pageBlockSubheader#4b567326: field subheader is nil")
|
|
}
|
|
if err := p.Subheader.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockSubheader#4b567326: field subheader: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockSubheader) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockSubheader#4b567326 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockSubheader"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockSubheader#4b567326: %w", err)
|
|
}
|
|
case "subheader":
|
|
value, err := DecodeTDLibJSONRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockSubheader#4b567326: field subheader: %w", err)
|
|
}
|
|
p.Subheader = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetSubheader returns value of Subheader field.
|
|
func (p *PageBlockSubheader) GetSubheader() (value RichTextClass) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Subheader
|
|
}
|
|
|
|
// PageBlockKicker represents TL type `pageBlockKicker#5123864b`.
|
|
type PageBlockKicker struct {
|
|
// Kicker
|
|
Kicker RichTextClass
|
|
}
|
|
|
|
// PageBlockKickerTypeID is TL type id of PageBlockKicker.
|
|
const PageBlockKickerTypeID = 0x5123864b
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockKicker) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockKicker.
|
|
var (
|
|
_ bin.Encoder = &PageBlockKicker{}
|
|
_ bin.Decoder = &PageBlockKicker{}
|
|
_ bin.BareEncoder = &PageBlockKicker{}
|
|
_ bin.BareDecoder = &PageBlockKicker{}
|
|
|
|
_ PageBlockClass = &PageBlockKicker{}
|
|
)
|
|
|
|
func (p *PageBlockKicker) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Kicker == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockKicker) String() string {
|
|
if p == nil {
|
|
return "PageBlockKicker(nil)"
|
|
}
|
|
type Alias PageBlockKicker
|
|
return fmt.Sprintf("PageBlockKicker%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockKicker) TypeID() uint32 {
|
|
return PageBlockKickerTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockKicker) TypeName() string {
|
|
return "pageBlockKicker"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockKicker) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockKicker",
|
|
ID: PageBlockKickerTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Kicker",
|
|
SchemaName: "kicker",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockKicker) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockKicker#5123864b as nil")
|
|
}
|
|
b.PutID(PageBlockKickerTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockKicker) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockKicker#5123864b as nil")
|
|
}
|
|
if p.Kicker == nil {
|
|
return fmt.Errorf("unable to encode pageBlockKicker#5123864b: field kicker is nil")
|
|
}
|
|
if err := p.Kicker.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockKicker#5123864b: field kicker: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockKicker) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockKicker#5123864b to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockKickerTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockKicker#5123864b: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockKicker) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockKicker#5123864b to nil")
|
|
}
|
|
{
|
|
value, err := DecodeRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockKicker#5123864b: field kicker: %w", err)
|
|
}
|
|
p.Kicker = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockKicker) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockKicker#5123864b as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockKicker")
|
|
b.Comma()
|
|
b.FieldStart("kicker")
|
|
if p.Kicker == nil {
|
|
return fmt.Errorf("unable to encode pageBlockKicker#5123864b: field kicker is nil")
|
|
}
|
|
if err := p.Kicker.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockKicker#5123864b: field kicker: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockKicker) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockKicker#5123864b to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockKicker"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockKicker#5123864b: %w", err)
|
|
}
|
|
case "kicker":
|
|
value, err := DecodeTDLibJSONRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockKicker#5123864b: field kicker: %w", err)
|
|
}
|
|
p.Kicker = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetKicker returns value of Kicker field.
|
|
func (p *PageBlockKicker) GetKicker() (value RichTextClass) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Kicker
|
|
}
|
|
|
|
// PageBlockParagraph represents TL type `pageBlockParagraph#467a0766`.
|
|
type PageBlockParagraph struct {
|
|
// Paragraph text
|
|
Text RichTextClass
|
|
}
|
|
|
|
// PageBlockParagraphTypeID is TL type id of PageBlockParagraph.
|
|
const PageBlockParagraphTypeID = 0x467a0766
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockParagraph) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockParagraph.
|
|
var (
|
|
_ bin.Encoder = &PageBlockParagraph{}
|
|
_ bin.Decoder = &PageBlockParagraph{}
|
|
_ bin.BareEncoder = &PageBlockParagraph{}
|
|
_ bin.BareDecoder = &PageBlockParagraph{}
|
|
|
|
_ PageBlockClass = &PageBlockParagraph{}
|
|
)
|
|
|
|
func (p *PageBlockParagraph) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Text == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockParagraph) String() string {
|
|
if p == nil {
|
|
return "PageBlockParagraph(nil)"
|
|
}
|
|
type Alias PageBlockParagraph
|
|
return fmt.Sprintf("PageBlockParagraph%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockParagraph) TypeID() uint32 {
|
|
return PageBlockParagraphTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockParagraph) TypeName() string {
|
|
return "pageBlockParagraph"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockParagraph) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockParagraph",
|
|
ID: PageBlockParagraphTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Text",
|
|
SchemaName: "text",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockParagraph) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockParagraph#467a0766 as nil")
|
|
}
|
|
b.PutID(PageBlockParagraphTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockParagraph) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockParagraph#467a0766 as nil")
|
|
}
|
|
if p.Text == nil {
|
|
return fmt.Errorf("unable to encode pageBlockParagraph#467a0766: field text is nil")
|
|
}
|
|
if err := p.Text.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockParagraph#467a0766: field text: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockParagraph) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockParagraph#467a0766 to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockParagraphTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockParagraph#467a0766: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockParagraph) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockParagraph#467a0766 to nil")
|
|
}
|
|
{
|
|
value, err := DecodeRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockParagraph#467a0766: field text: %w", err)
|
|
}
|
|
p.Text = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockParagraph) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockParagraph#467a0766 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockParagraph")
|
|
b.Comma()
|
|
b.FieldStart("text")
|
|
if p.Text == nil {
|
|
return fmt.Errorf("unable to encode pageBlockParagraph#467a0766: field text is nil")
|
|
}
|
|
if err := p.Text.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockParagraph#467a0766: field text: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockParagraph) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockParagraph#467a0766 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockParagraph"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockParagraph#467a0766: %w", err)
|
|
}
|
|
case "text":
|
|
value, err := DecodeTDLibJSONRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockParagraph#467a0766: field text: %w", err)
|
|
}
|
|
p.Text = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetText returns value of Text field.
|
|
func (p *PageBlockParagraph) GetText() (value RichTextClass) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Text
|
|
}
|
|
|
|
// PageBlockPreformatted represents TL type `pageBlockPreformatted#c070d93e`.
|
|
type PageBlockPreformatted struct {
|
|
// Paragraph text
|
|
Text RichTextClass
|
|
// Programming language for which the text needs to be formatted
|
|
Language string
|
|
}
|
|
|
|
// PageBlockPreformattedTypeID is TL type id of PageBlockPreformatted.
|
|
const PageBlockPreformattedTypeID = 0xc070d93e
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockPreformatted) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockPreformatted.
|
|
var (
|
|
_ bin.Encoder = &PageBlockPreformatted{}
|
|
_ bin.Decoder = &PageBlockPreformatted{}
|
|
_ bin.BareEncoder = &PageBlockPreformatted{}
|
|
_ bin.BareDecoder = &PageBlockPreformatted{}
|
|
|
|
_ PageBlockClass = &PageBlockPreformatted{}
|
|
)
|
|
|
|
func (p *PageBlockPreformatted) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Text == nil) {
|
|
return false
|
|
}
|
|
if !(p.Language == "") {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockPreformatted) String() string {
|
|
if p == nil {
|
|
return "PageBlockPreformatted(nil)"
|
|
}
|
|
type Alias PageBlockPreformatted
|
|
return fmt.Sprintf("PageBlockPreformatted%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockPreformatted) TypeID() uint32 {
|
|
return PageBlockPreformattedTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockPreformatted) TypeName() string {
|
|
return "pageBlockPreformatted"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockPreformatted) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockPreformatted",
|
|
ID: PageBlockPreformattedTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Text",
|
|
SchemaName: "text",
|
|
},
|
|
{
|
|
Name: "Language",
|
|
SchemaName: "language",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockPreformatted) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockPreformatted#c070d93e as nil")
|
|
}
|
|
b.PutID(PageBlockPreformattedTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockPreformatted) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockPreformatted#c070d93e as nil")
|
|
}
|
|
if p.Text == nil {
|
|
return fmt.Errorf("unable to encode pageBlockPreformatted#c070d93e: field text is nil")
|
|
}
|
|
if err := p.Text.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockPreformatted#c070d93e: field text: %w", err)
|
|
}
|
|
b.PutString(p.Language)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockPreformatted) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockPreformatted#c070d93e to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockPreformattedTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockPreformatted#c070d93e: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockPreformatted) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockPreformatted#c070d93e to nil")
|
|
}
|
|
{
|
|
value, err := DecodeRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockPreformatted#c070d93e: field text: %w", err)
|
|
}
|
|
p.Text = value
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockPreformatted#c070d93e: field language: %w", err)
|
|
}
|
|
p.Language = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockPreformatted) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockPreformatted#c070d93e as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockPreformatted")
|
|
b.Comma()
|
|
b.FieldStart("text")
|
|
if p.Text == nil {
|
|
return fmt.Errorf("unable to encode pageBlockPreformatted#c070d93e: field text is nil")
|
|
}
|
|
if err := p.Text.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockPreformatted#c070d93e: field text: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("language")
|
|
b.PutString(p.Language)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockPreformatted) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockPreformatted#c070d93e to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockPreformatted"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockPreformatted#c070d93e: %w", err)
|
|
}
|
|
case "text":
|
|
value, err := DecodeTDLibJSONRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockPreformatted#c070d93e: field text: %w", err)
|
|
}
|
|
p.Text = value
|
|
case "language":
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockPreformatted#c070d93e: field language: %w", err)
|
|
}
|
|
p.Language = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetText returns value of Text field.
|
|
func (p *PageBlockPreformatted) GetText() (value RichTextClass) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Text
|
|
}
|
|
|
|
// GetLanguage returns value of Language field.
|
|
func (p *PageBlockPreformatted) GetLanguage() (value string) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Language
|
|
}
|
|
|
|
// PageBlockFooter represents TL type `pageBlockFooter#34d5d728`.
|
|
type PageBlockFooter struct {
|
|
// Footer
|
|
Footer RichTextClass
|
|
}
|
|
|
|
// PageBlockFooterTypeID is TL type id of PageBlockFooter.
|
|
const PageBlockFooterTypeID = 0x34d5d728
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockFooter) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockFooter.
|
|
var (
|
|
_ bin.Encoder = &PageBlockFooter{}
|
|
_ bin.Decoder = &PageBlockFooter{}
|
|
_ bin.BareEncoder = &PageBlockFooter{}
|
|
_ bin.BareDecoder = &PageBlockFooter{}
|
|
|
|
_ PageBlockClass = &PageBlockFooter{}
|
|
)
|
|
|
|
func (p *PageBlockFooter) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Footer == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockFooter) String() string {
|
|
if p == nil {
|
|
return "PageBlockFooter(nil)"
|
|
}
|
|
type Alias PageBlockFooter
|
|
return fmt.Sprintf("PageBlockFooter%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockFooter) TypeID() uint32 {
|
|
return PageBlockFooterTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockFooter) TypeName() string {
|
|
return "pageBlockFooter"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockFooter) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockFooter",
|
|
ID: PageBlockFooterTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Footer",
|
|
SchemaName: "footer",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockFooter) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockFooter#34d5d728 as nil")
|
|
}
|
|
b.PutID(PageBlockFooterTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockFooter) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockFooter#34d5d728 as nil")
|
|
}
|
|
if p.Footer == nil {
|
|
return fmt.Errorf("unable to encode pageBlockFooter#34d5d728: field footer is nil")
|
|
}
|
|
if err := p.Footer.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockFooter#34d5d728: field footer: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockFooter) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockFooter#34d5d728 to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockFooterTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockFooter#34d5d728: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockFooter) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockFooter#34d5d728 to nil")
|
|
}
|
|
{
|
|
value, err := DecodeRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockFooter#34d5d728: field footer: %w", err)
|
|
}
|
|
p.Footer = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockFooter) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockFooter#34d5d728 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockFooter")
|
|
b.Comma()
|
|
b.FieldStart("footer")
|
|
if p.Footer == nil {
|
|
return fmt.Errorf("unable to encode pageBlockFooter#34d5d728: field footer is nil")
|
|
}
|
|
if err := p.Footer.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockFooter#34d5d728: field footer: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockFooter) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockFooter#34d5d728 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockFooter"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockFooter#34d5d728: %w", err)
|
|
}
|
|
case "footer":
|
|
value, err := DecodeTDLibJSONRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockFooter#34d5d728: field footer: %w", err)
|
|
}
|
|
p.Footer = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetFooter returns value of Footer field.
|
|
func (p *PageBlockFooter) GetFooter() (value RichTextClass) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Footer
|
|
}
|
|
|
|
// PageBlockDivider represents TL type `pageBlockDivider#db20b188`.
|
|
type PageBlockDivider struct {
|
|
}
|
|
|
|
// PageBlockDividerTypeID is TL type id of PageBlockDivider.
|
|
const PageBlockDividerTypeID = 0xdb20b188
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockDivider) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockDivider.
|
|
var (
|
|
_ bin.Encoder = &PageBlockDivider{}
|
|
_ bin.Decoder = &PageBlockDivider{}
|
|
_ bin.BareEncoder = &PageBlockDivider{}
|
|
_ bin.BareDecoder = &PageBlockDivider{}
|
|
|
|
_ PageBlockClass = &PageBlockDivider{}
|
|
)
|
|
|
|
func (p *PageBlockDivider) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockDivider) String() string {
|
|
if p == nil {
|
|
return "PageBlockDivider(nil)"
|
|
}
|
|
type Alias PageBlockDivider
|
|
return fmt.Sprintf("PageBlockDivider%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockDivider) TypeID() uint32 {
|
|
return PageBlockDividerTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockDivider) TypeName() string {
|
|
return "pageBlockDivider"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockDivider) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockDivider",
|
|
ID: PageBlockDividerTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockDivider) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockDivider#db20b188 as nil")
|
|
}
|
|
b.PutID(PageBlockDividerTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockDivider) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockDivider#db20b188 as nil")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockDivider) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockDivider#db20b188 to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockDividerTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockDivider#db20b188: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockDivider) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockDivider#db20b188 to nil")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockDivider) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockDivider#db20b188 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockDivider")
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockDivider) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockDivider#db20b188 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockDivider"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockDivider#db20b188: %w", err)
|
|
}
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// PageBlockAnchor represents TL type `pageBlockAnchor#ce0d37b0`.
|
|
type PageBlockAnchor struct {
|
|
// Name of the anchor
|
|
Name string
|
|
}
|
|
|
|
// PageBlockAnchorTypeID is TL type id of PageBlockAnchor.
|
|
const PageBlockAnchorTypeID = 0xce0d37b0
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockAnchor) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockAnchor.
|
|
var (
|
|
_ bin.Encoder = &PageBlockAnchor{}
|
|
_ bin.Decoder = &PageBlockAnchor{}
|
|
_ bin.BareEncoder = &PageBlockAnchor{}
|
|
_ bin.BareDecoder = &PageBlockAnchor{}
|
|
|
|
_ PageBlockClass = &PageBlockAnchor{}
|
|
)
|
|
|
|
func (p *PageBlockAnchor) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Name == "") {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockAnchor) String() string {
|
|
if p == nil {
|
|
return "PageBlockAnchor(nil)"
|
|
}
|
|
type Alias PageBlockAnchor
|
|
return fmt.Sprintf("PageBlockAnchor%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockAnchor) TypeID() uint32 {
|
|
return PageBlockAnchorTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockAnchor) TypeName() string {
|
|
return "pageBlockAnchor"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockAnchor) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockAnchor",
|
|
ID: PageBlockAnchorTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Name",
|
|
SchemaName: "name",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockAnchor) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockAnchor#ce0d37b0 as nil")
|
|
}
|
|
b.PutID(PageBlockAnchorTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockAnchor) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockAnchor#ce0d37b0 as nil")
|
|
}
|
|
b.PutString(p.Name)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockAnchor) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockAnchor#ce0d37b0 to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockAnchorTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAnchor#ce0d37b0: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockAnchor) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockAnchor#ce0d37b0 to nil")
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAnchor#ce0d37b0: field name: %w", err)
|
|
}
|
|
p.Name = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockAnchor) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockAnchor#ce0d37b0 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockAnchor")
|
|
b.Comma()
|
|
b.FieldStart("name")
|
|
b.PutString(p.Name)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockAnchor) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockAnchor#ce0d37b0 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockAnchor"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAnchor#ce0d37b0: %w", err)
|
|
}
|
|
case "name":
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAnchor#ce0d37b0: field name: %w", err)
|
|
}
|
|
p.Name = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetName returns value of Name field.
|
|
func (p *PageBlockAnchor) GetName() (value string) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Name
|
|
}
|
|
|
|
// PageBlockList represents TL type `pageBlockList#584af35a`.
|
|
type PageBlockList struct {
|
|
// The items of the list
|
|
Items []PageBlockListItem
|
|
}
|
|
|
|
// PageBlockListTypeID is TL type id of PageBlockList.
|
|
const PageBlockListTypeID = 0x584af35a
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockList) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockList.
|
|
var (
|
|
_ bin.Encoder = &PageBlockList{}
|
|
_ bin.Decoder = &PageBlockList{}
|
|
_ bin.BareEncoder = &PageBlockList{}
|
|
_ bin.BareDecoder = &PageBlockList{}
|
|
|
|
_ PageBlockClass = &PageBlockList{}
|
|
)
|
|
|
|
func (p *PageBlockList) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Items == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockList) String() string {
|
|
if p == nil {
|
|
return "PageBlockList(nil)"
|
|
}
|
|
type Alias PageBlockList
|
|
return fmt.Sprintf("PageBlockList%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockList) TypeID() uint32 {
|
|
return PageBlockListTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockList) TypeName() string {
|
|
return "pageBlockList"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockList) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockList",
|
|
ID: PageBlockListTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Items",
|
|
SchemaName: "items",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockList) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockList#584af35a as nil")
|
|
}
|
|
b.PutID(PageBlockListTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockList) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockList#584af35a as nil")
|
|
}
|
|
b.PutInt(len(p.Items))
|
|
for idx, v := range p.Items {
|
|
if err := v.EncodeBare(b); err != nil {
|
|
return fmt.Errorf("unable to encode bare pageBlockList#584af35a: field items element with index %d: %w", idx, err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockList) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockList#584af35a to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockListTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockList#584af35a: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockList) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockList#584af35a to nil")
|
|
}
|
|
{
|
|
headerLen, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockList#584af35a: field items: %w", err)
|
|
}
|
|
|
|
if headerLen > 0 {
|
|
p.Items = make([]PageBlockListItem, 0, headerLen%bin.PreallocateLimit)
|
|
}
|
|
for idx := 0; idx < headerLen; idx++ {
|
|
var value PageBlockListItem
|
|
if err := value.DecodeBare(b); err != nil {
|
|
return fmt.Errorf("unable to decode bare pageBlockList#584af35a: field items: %w", err)
|
|
}
|
|
p.Items = append(p.Items, value)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockList) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockList#584af35a as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockList")
|
|
b.Comma()
|
|
b.FieldStart("items")
|
|
b.ArrStart()
|
|
for idx, v := range p.Items {
|
|
if err := v.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockList#584af35a: field items element with index %d: %w", idx, err)
|
|
}
|
|
b.Comma()
|
|
}
|
|
b.StripComma()
|
|
b.ArrEnd()
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockList) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockList#584af35a to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockList"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockList#584af35a: %w", err)
|
|
}
|
|
case "items":
|
|
if err := b.Arr(func(b tdjson.Decoder) error {
|
|
var value PageBlockListItem
|
|
if err := value.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockList#584af35a: field items: %w", err)
|
|
}
|
|
p.Items = append(p.Items, value)
|
|
return nil
|
|
}); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockList#584af35a: field items: %w", err)
|
|
}
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetItems returns value of Items field.
|
|
func (p *PageBlockList) GetItems() (value []PageBlockListItem) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Items
|
|
}
|
|
|
|
// PageBlockBlockQuote represents TL type `pageBlockBlockQuote#62d08a9e`.
|
|
type PageBlockBlockQuote struct {
|
|
// Quote text
|
|
Text RichTextClass
|
|
// Quote credit
|
|
Credit RichTextClass
|
|
}
|
|
|
|
// PageBlockBlockQuoteTypeID is TL type id of PageBlockBlockQuote.
|
|
const PageBlockBlockQuoteTypeID = 0x62d08a9e
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockBlockQuote) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockBlockQuote.
|
|
var (
|
|
_ bin.Encoder = &PageBlockBlockQuote{}
|
|
_ bin.Decoder = &PageBlockBlockQuote{}
|
|
_ bin.BareEncoder = &PageBlockBlockQuote{}
|
|
_ bin.BareDecoder = &PageBlockBlockQuote{}
|
|
|
|
_ PageBlockClass = &PageBlockBlockQuote{}
|
|
)
|
|
|
|
func (p *PageBlockBlockQuote) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Text == nil) {
|
|
return false
|
|
}
|
|
if !(p.Credit == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockBlockQuote) String() string {
|
|
if p == nil {
|
|
return "PageBlockBlockQuote(nil)"
|
|
}
|
|
type Alias PageBlockBlockQuote
|
|
return fmt.Sprintf("PageBlockBlockQuote%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockBlockQuote) TypeID() uint32 {
|
|
return PageBlockBlockQuoteTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockBlockQuote) TypeName() string {
|
|
return "pageBlockBlockQuote"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockBlockQuote) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockBlockQuote",
|
|
ID: PageBlockBlockQuoteTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Text",
|
|
SchemaName: "text",
|
|
},
|
|
{
|
|
Name: "Credit",
|
|
SchemaName: "credit",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockBlockQuote) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockBlockQuote#62d08a9e as nil")
|
|
}
|
|
b.PutID(PageBlockBlockQuoteTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockBlockQuote) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockBlockQuote#62d08a9e as nil")
|
|
}
|
|
if p.Text == nil {
|
|
return fmt.Errorf("unable to encode pageBlockBlockQuote#62d08a9e: field text is nil")
|
|
}
|
|
if err := p.Text.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockBlockQuote#62d08a9e: field text: %w", err)
|
|
}
|
|
if p.Credit == nil {
|
|
return fmt.Errorf("unable to encode pageBlockBlockQuote#62d08a9e: field credit is nil")
|
|
}
|
|
if err := p.Credit.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockBlockQuote#62d08a9e: field credit: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockBlockQuote) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockBlockQuote#62d08a9e to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockBlockQuoteTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockBlockQuote#62d08a9e: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockBlockQuote) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockBlockQuote#62d08a9e to nil")
|
|
}
|
|
{
|
|
value, err := DecodeRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockBlockQuote#62d08a9e: field text: %w", err)
|
|
}
|
|
p.Text = value
|
|
}
|
|
{
|
|
value, err := DecodeRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockBlockQuote#62d08a9e: field credit: %w", err)
|
|
}
|
|
p.Credit = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockBlockQuote) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockBlockQuote#62d08a9e as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockBlockQuote")
|
|
b.Comma()
|
|
b.FieldStart("text")
|
|
if p.Text == nil {
|
|
return fmt.Errorf("unable to encode pageBlockBlockQuote#62d08a9e: field text is nil")
|
|
}
|
|
if err := p.Text.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockBlockQuote#62d08a9e: field text: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("credit")
|
|
if p.Credit == nil {
|
|
return fmt.Errorf("unable to encode pageBlockBlockQuote#62d08a9e: field credit is nil")
|
|
}
|
|
if err := p.Credit.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockBlockQuote#62d08a9e: field credit: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockBlockQuote) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockBlockQuote#62d08a9e to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockBlockQuote"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockBlockQuote#62d08a9e: %w", err)
|
|
}
|
|
case "text":
|
|
value, err := DecodeTDLibJSONRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockBlockQuote#62d08a9e: field text: %w", err)
|
|
}
|
|
p.Text = value
|
|
case "credit":
|
|
value, err := DecodeTDLibJSONRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockBlockQuote#62d08a9e: field credit: %w", err)
|
|
}
|
|
p.Credit = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetText returns value of Text field.
|
|
func (p *PageBlockBlockQuote) GetText() (value RichTextClass) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Text
|
|
}
|
|
|
|
// GetCredit returns value of Credit field.
|
|
func (p *PageBlockBlockQuote) GetCredit() (value RichTextClass) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Credit
|
|
}
|
|
|
|
// PageBlockPullQuote represents TL type `pageBlockPullQuote#1d38810d`.
|
|
type PageBlockPullQuote struct {
|
|
// Quote text
|
|
Text RichTextClass
|
|
// Quote credit
|
|
Credit RichTextClass
|
|
}
|
|
|
|
// PageBlockPullQuoteTypeID is TL type id of PageBlockPullQuote.
|
|
const PageBlockPullQuoteTypeID = 0x1d38810d
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockPullQuote) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockPullQuote.
|
|
var (
|
|
_ bin.Encoder = &PageBlockPullQuote{}
|
|
_ bin.Decoder = &PageBlockPullQuote{}
|
|
_ bin.BareEncoder = &PageBlockPullQuote{}
|
|
_ bin.BareDecoder = &PageBlockPullQuote{}
|
|
|
|
_ PageBlockClass = &PageBlockPullQuote{}
|
|
)
|
|
|
|
func (p *PageBlockPullQuote) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Text == nil) {
|
|
return false
|
|
}
|
|
if !(p.Credit == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockPullQuote) String() string {
|
|
if p == nil {
|
|
return "PageBlockPullQuote(nil)"
|
|
}
|
|
type Alias PageBlockPullQuote
|
|
return fmt.Sprintf("PageBlockPullQuote%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockPullQuote) TypeID() uint32 {
|
|
return PageBlockPullQuoteTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockPullQuote) TypeName() string {
|
|
return "pageBlockPullQuote"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockPullQuote) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockPullQuote",
|
|
ID: PageBlockPullQuoteTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Text",
|
|
SchemaName: "text",
|
|
},
|
|
{
|
|
Name: "Credit",
|
|
SchemaName: "credit",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockPullQuote) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockPullQuote#1d38810d as nil")
|
|
}
|
|
b.PutID(PageBlockPullQuoteTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockPullQuote) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockPullQuote#1d38810d as nil")
|
|
}
|
|
if p.Text == nil {
|
|
return fmt.Errorf("unable to encode pageBlockPullQuote#1d38810d: field text is nil")
|
|
}
|
|
if err := p.Text.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockPullQuote#1d38810d: field text: %w", err)
|
|
}
|
|
if p.Credit == nil {
|
|
return fmt.Errorf("unable to encode pageBlockPullQuote#1d38810d: field credit is nil")
|
|
}
|
|
if err := p.Credit.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockPullQuote#1d38810d: field credit: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockPullQuote) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockPullQuote#1d38810d to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockPullQuoteTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockPullQuote#1d38810d: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockPullQuote) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockPullQuote#1d38810d to nil")
|
|
}
|
|
{
|
|
value, err := DecodeRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockPullQuote#1d38810d: field text: %w", err)
|
|
}
|
|
p.Text = value
|
|
}
|
|
{
|
|
value, err := DecodeRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockPullQuote#1d38810d: field credit: %w", err)
|
|
}
|
|
p.Credit = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockPullQuote) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockPullQuote#1d38810d as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockPullQuote")
|
|
b.Comma()
|
|
b.FieldStart("text")
|
|
if p.Text == nil {
|
|
return fmt.Errorf("unable to encode pageBlockPullQuote#1d38810d: field text is nil")
|
|
}
|
|
if err := p.Text.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockPullQuote#1d38810d: field text: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("credit")
|
|
if p.Credit == nil {
|
|
return fmt.Errorf("unable to encode pageBlockPullQuote#1d38810d: field credit is nil")
|
|
}
|
|
if err := p.Credit.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockPullQuote#1d38810d: field credit: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockPullQuote) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockPullQuote#1d38810d to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockPullQuote"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockPullQuote#1d38810d: %w", err)
|
|
}
|
|
case "text":
|
|
value, err := DecodeTDLibJSONRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockPullQuote#1d38810d: field text: %w", err)
|
|
}
|
|
p.Text = value
|
|
case "credit":
|
|
value, err := DecodeTDLibJSONRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockPullQuote#1d38810d: field credit: %w", err)
|
|
}
|
|
p.Credit = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetText returns value of Text field.
|
|
func (p *PageBlockPullQuote) GetText() (value RichTextClass) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Text
|
|
}
|
|
|
|
// GetCredit returns value of Credit field.
|
|
func (p *PageBlockPullQuote) GetCredit() (value RichTextClass) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Credit
|
|
}
|
|
|
|
// PageBlockAnimation represents TL type `pageBlockAnimation#50cde009`.
|
|
type PageBlockAnimation struct {
|
|
// Animation file; may be null
|
|
Animation Animation
|
|
// Animation caption
|
|
Caption PageBlockCaption
|
|
// True, if the animation must be played automatically
|
|
NeedAutoplay bool
|
|
}
|
|
|
|
// PageBlockAnimationTypeID is TL type id of PageBlockAnimation.
|
|
const PageBlockAnimationTypeID = 0x50cde009
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockAnimation) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockAnimation.
|
|
var (
|
|
_ bin.Encoder = &PageBlockAnimation{}
|
|
_ bin.Decoder = &PageBlockAnimation{}
|
|
_ bin.BareEncoder = &PageBlockAnimation{}
|
|
_ bin.BareDecoder = &PageBlockAnimation{}
|
|
|
|
_ PageBlockClass = &PageBlockAnimation{}
|
|
)
|
|
|
|
func (p *PageBlockAnimation) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Animation.Zero()) {
|
|
return false
|
|
}
|
|
if !(p.Caption.Zero()) {
|
|
return false
|
|
}
|
|
if !(p.NeedAutoplay == false) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockAnimation) String() string {
|
|
if p == nil {
|
|
return "PageBlockAnimation(nil)"
|
|
}
|
|
type Alias PageBlockAnimation
|
|
return fmt.Sprintf("PageBlockAnimation%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockAnimation) TypeID() uint32 {
|
|
return PageBlockAnimationTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockAnimation) TypeName() string {
|
|
return "pageBlockAnimation"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockAnimation) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockAnimation",
|
|
ID: PageBlockAnimationTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Animation",
|
|
SchemaName: "animation",
|
|
},
|
|
{
|
|
Name: "Caption",
|
|
SchemaName: "caption",
|
|
},
|
|
{
|
|
Name: "NeedAutoplay",
|
|
SchemaName: "need_autoplay",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockAnimation) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockAnimation#50cde009 as nil")
|
|
}
|
|
b.PutID(PageBlockAnimationTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockAnimation) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockAnimation#50cde009 as nil")
|
|
}
|
|
if err := p.Animation.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockAnimation#50cde009: field animation: %w", err)
|
|
}
|
|
if err := p.Caption.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockAnimation#50cde009: field caption: %w", err)
|
|
}
|
|
b.PutBool(p.NeedAutoplay)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockAnimation) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockAnimation#50cde009 to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockAnimationTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAnimation#50cde009: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockAnimation) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockAnimation#50cde009 to nil")
|
|
}
|
|
{
|
|
if err := p.Animation.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAnimation#50cde009: field animation: %w", err)
|
|
}
|
|
}
|
|
{
|
|
if err := p.Caption.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAnimation#50cde009: field caption: %w", err)
|
|
}
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAnimation#50cde009: field need_autoplay: %w", err)
|
|
}
|
|
p.NeedAutoplay = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockAnimation) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockAnimation#50cde009 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockAnimation")
|
|
b.Comma()
|
|
b.FieldStart("animation")
|
|
if err := p.Animation.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockAnimation#50cde009: field animation: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("caption")
|
|
if err := p.Caption.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockAnimation#50cde009: field caption: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("need_autoplay")
|
|
b.PutBool(p.NeedAutoplay)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockAnimation) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockAnimation#50cde009 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockAnimation"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAnimation#50cde009: %w", err)
|
|
}
|
|
case "animation":
|
|
if err := p.Animation.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAnimation#50cde009: field animation: %w", err)
|
|
}
|
|
case "caption":
|
|
if err := p.Caption.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAnimation#50cde009: field caption: %w", err)
|
|
}
|
|
case "need_autoplay":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAnimation#50cde009: field need_autoplay: %w", err)
|
|
}
|
|
p.NeedAutoplay = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetAnimation returns value of Animation field.
|
|
func (p *PageBlockAnimation) GetAnimation() (value Animation) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Animation
|
|
}
|
|
|
|
// GetCaption returns value of Caption field.
|
|
func (p *PageBlockAnimation) GetCaption() (value PageBlockCaption) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Caption
|
|
}
|
|
|
|
// GetNeedAutoplay returns value of NeedAutoplay field.
|
|
func (p *PageBlockAnimation) GetNeedAutoplay() (value bool) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.NeedAutoplay
|
|
}
|
|
|
|
// PageBlockAudio represents TL type `pageBlockAudio#fc390813`.
|
|
type PageBlockAudio struct {
|
|
// Audio file; may be null
|
|
Audio Audio
|
|
// Audio file caption
|
|
Caption PageBlockCaption
|
|
}
|
|
|
|
// PageBlockAudioTypeID is TL type id of PageBlockAudio.
|
|
const PageBlockAudioTypeID = 0xfc390813
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockAudio) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockAudio.
|
|
var (
|
|
_ bin.Encoder = &PageBlockAudio{}
|
|
_ bin.Decoder = &PageBlockAudio{}
|
|
_ bin.BareEncoder = &PageBlockAudio{}
|
|
_ bin.BareDecoder = &PageBlockAudio{}
|
|
|
|
_ PageBlockClass = &PageBlockAudio{}
|
|
)
|
|
|
|
func (p *PageBlockAudio) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Audio.Zero()) {
|
|
return false
|
|
}
|
|
if !(p.Caption.Zero()) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockAudio) String() string {
|
|
if p == nil {
|
|
return "PageBlockAudio(nil)"
|
|
}
|
|
type Alias PageBlockAudio
|
|
return fmt.Sprintf("PageBlockAudio%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockAudio) TypeID() uint32 {
|
|
return PageBlockAudioTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockAudio) TypeName() string {
|
|
return "pageBlockAudio"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockAudio) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockAudio",
|
|
ID: PageBlockAudioTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Audio",
|
|
SchemaName: "audio",
|
|
},
|
|
{
|
|
Name: "Caption",
|
|
SchemaName: "caption",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockAudio) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockAudio#fc390813 as nil")
|
|
}
|
|
b.PutID(PageBlockAudioTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockAudio) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockAudio#fc390813 as nil")
|
|
}
|
|
if err := p.Audio.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockAudio#fc390813: field audio: %w", err)
|
|
}
|
|
if err := p.Caption.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockAudio#fc390813: field caption: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockAudio) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockAudio#fc390813 to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockAudioTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAudio#fc390813: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockAudio) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockAudio#fc390813 to nil")
|
|
}
|
|
{
|
|
if err := p.Audio.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAudio#fc390813: field audio: %w", err)
|
|
}
|
|
}
|
|
{
|
|
if err := p.Caption.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAudio#fc390813: field caption: %w", err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockAudio) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockAudio#fc390813 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockAudio")
|
|
b.Comma()
|
|
b.FieldStart("audio")
|
|
if err := p.Audio.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockAudio#fc390813: field audio: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("caption")
|
|
if err := p.Caption.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockAudio#fc390813: field caption: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockAudio) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockAudio#fc390813 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockAudio"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAudio#fc390813: %w", err)
|
|
}
|
|
case "audio":
|
|
if err := p.Audio.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAudio#fc390813: field audio: %w", err)
|
|
}
|
|
case "caption":
|
|
if err := p.Caption.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockAudio#fc390813: field caption: %w", err)
|
|
}
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetAudio returns value of Audio field.
|
|
func (p *PageBlockAudio) GetAudio() (value Audio) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Audio
|
|
}
|
|
|
|
// GetCaption returns value of Caption field.
|
|
func (p *PageBlockAudio) GetCaption() (value PageBlockCaption) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Caption
|
|
}
|
|
|
|
// PageBlockPhoto represents TL type `pageBlockPhoto#18e41684`.
|
|
type PageBlockPhoto struct {
|
|
// Photo file; may be null
|
|
Photo Photo
|
|
// Photo caption
|
|
Caption PageBlockCaption
|
|
// URL that needs to be opened when the photo is clicked
|
|
URL string
|
|
}
|
|
|
|
// PageBlockPhotoTypeID is TL type id of PageBlockPhoto.
|
|
const PageBlockPhotoTypeID = 0x18e41684
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockPhoto) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockPhoto.
|
|
var (
|
|
_ bin.Encoder = &PageBlockPhoto{}
|
|
_ bin.Decoder = &PageBlockPhoto{}
|
|
_ bin.BareEncoder = &PageBlockPhoto{}
|
|
_ bin.BareDecoder = &PageBlockPhoto{}
|
|
|
|
_ PageBlockClass = &PageBlockPhoto{}
|
|
)
|
|
|
|
func (p *PageBlockPhoto) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Photo.Zero()) {
|
|
return false
|
|
}
|
|
if !(p.Caption.Zero()) {
|
|
return false
|
|
}
|
|
if !(p.URL == "") {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockPhoto) String() string {
|
|
if p == nil {
|
|
return "PageBlockPhoto(nil)"
|
|
}
|
|
type Alias PageBlockPhoto
|
|
return fmt.Sprintf("PageBlockPhoto%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockPhoto) TypeID() uint32 {
|
|
return PageBlockPhotoTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockPhoto) TypeName() string {
|
|
return "pageBlockPhoto"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockPhoto) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockPhoto",
|
|
ID: PageBlockPhotoTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Photo",
|
|
SchemaName: "photo",
|
|
},
|
|
{
|
|
Name: "Caption",
|
|
SchemaName: "caption",
|
|
},
|
|
{
|
|
Name: "URL",
|
|
SchemaName: "url",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockPhoto) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockPhoto#18e41684 as nil")
|
|
}
|
|
b.PutID(PageBlockPhotoTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockPhoto) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockPhoto#18e41684 as nil")
|
|
}
|
|
if err := p.Photo.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockPhoto#18e41684: field photo: %w", err)
|
|
}
|
|
if err := p.Caption.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockPhoto#18e41684: field caption: %w", err)
|
|
}
|
|
b.PutString(p.URL)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockPhoto) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockPhoto#18e41684 to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockPhotoTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockPhoto#18e41684: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockPhoto) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockPhoto#18e41684 to nil")
|
|
}
|
|
{
|
|
if err := p.Photo.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockPhoto#18e41684: field photo: %w", err)
|
|
}
|
|
}
|
|
{
|
|
if err := p.Caption.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockPhoto#18e41684: field caption: %w", err)
|
|
}
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockPhoto#18e41684: field url: %w", err)
|
|
}
|
|
p.URL = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockPhoto) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockPhoto#18e41684 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockPhoto")
|
|
b.Comma()
|
|
b.FieldStart("photo")
|
|
if err := p.Photo.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockPhoto#18e41684: field photo: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("caption")
|
|
if err := p.Caption.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockPhoto#18e41684: field caption: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("url")
|
|
b.PutString(p.URL)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockPhoto) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockPhoto#18e41684 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockPhoto"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockPhoto#18e41684: %w", err)
|
|
}
|
|
case "photo":
|
|
if err := p.Photo.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockPhoto#18e41684: field photo: %w", err)
|
|
}
|
|
case "caption":
|
|
if err := p.Caption.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockPhoto#18e41684: field caption: %w", err)
|
|
}
|
|
case "url":
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockPhoto#18e41684: field url: %w", err)
|
|
}
|
|
p.URL = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetPhoto returns value of Photo field.
|
|
func (p *PageBlockPhoto) GetPhoto() (value Photo) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Photo
|
|
}
|
|
|
|
// GetCaption returns value of Caption field.
|
|
func (p *PageBlockPhoto) GetCaption() (value PageBlockCaption) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Caption
|
|
}
|
|
|
|
// GetURL returns value of URL field.
|
|
func (p *PageBlockPhoto) GetURL() (value string) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.URL
|
|
}
|
|
|
|
// PageBlockVideo represents TL type `pageBlockVideo#1e669d32`.
|
|
type PageBlockVideo struct {
|
|
// Video file; may be null
|
|
Video Video
|
|
// Video caption
|
|
Caption PageBlockCaption
|
|
// True, if the video must be played automatically
|
|
NeedAutoplay bool
|
|
// True, if the video must be looped
|
|
IsLooped bool
|
|
}
|
|
|
|
// PageBlockVideoTypeID is TL type id of PageBlockVideo.
|
|
const PageBlockVideoTypeID = 0x1e669d32
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockVideo) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockVideo.
|
|
var (
|
|
_ bin.Encoder = &PageBlockVideo{}
|
|
_ bin.Decoder = &PageBlockVideo{}
|
|
_ bin.BareEncoder = &PageBlockVideo{}
|
|
_ bin.BareDecoder = &PageBlockVideo{}
|
|
|
|
_ PageBlockClass = &PageBlockVideo{}
|
|
)
|
|
|
|
func (p *PageBlockVideo) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Video.Zero()) {
|
|
return false
|
|
}
|
|
if !(p.Caption.Zero()) {
|
|
return false
|
|
}
|
|
if !(p.NeedAutoplay == false) {
|
|
return false
|
|
}
|
|
if !(p.IsLooped == false) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockVideo) String() string {
|
|
if p == nil {
|
|
return "PageBlockVideo(nil)"
|
|
}
|
|
type Alias PageBlockVideo
|
|
return fmt.Sprintf("PageBlockVideo%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockVideo) TypeID() uint32 {
|
|
return PageBlockVideoTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockVideo) TypeName() string {
|
|
return "pageBlockVideo"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockVideo) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockVideo",
|
|
ID: PageBlockVideoTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Video",
|
|
SchemaName: "video",
|
|
},
|
|
{
|
|
Name: "Caption",
|
|
SchemaName: "caption",
|
|
},
|
|
{
|
|
Name: "NeedAutoplay",
|
|
SchemaName: "need_autoplay",
|
|
},
|
|
{
|
|
Name: "IsLooped",
|
|
SchemaName: "is_looped",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockVideo) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockVideo#1e669d32 as nil")
|
|
}
|
|
b.PutID(PageBlockVideoTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockVideo) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockVideo#1e669d32 as nil")
|
|
}
|
|
if err := p.Video.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockVideo#1e669d32: field video: %w", err)
|
|
}
|
|
if err := p.Caption.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockVideo#1e669d32: field caption: %w", err)
|
|
}
|
|
b.PutBool(p.NeedAutoplay)
|
|
b.PutBool(p.IsLooped)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockVideo) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockVideo#1e669d32 to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockVideoTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockVideo#1e669d32: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockVideo) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockVideo#1e669d32 to nil")
|
|
}
|
|
{
|
|
if err := p.Video.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockVideo#1e669d32: field video: %w", err)
|
|
}
|
|
}
|
|
{
|
|
if err := p.Caption.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockVideo#1e669d32: field caption: %w", err)
|
|
}
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockVideo#1e669d32: field need_autoplay: %w", err)
|
|
}
|
|
p.NeedAutoplay = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockVideo#1e669d32: field is_looped: %w", err)
|
|
}
|
|
p.IsLooped = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockVideo) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockVideo#1e669d32 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockVideo")
|
|
b.Comma()
|
|
b.FieldStart("video")
|
|
if err := p.Video.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockVideo#1e669d32: field video: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("caption")
|
|
if err := p.Caption.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockVideo#1e669d32: field caption: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("need_autoplay")
|
|
b.PutBool(p.NeedAutoplay)
|
|
b.Comma()
|
|
b.FieldStart("is_looped")
|
|
b.PutBool(p.IsLooped)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockVideo) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockVideo#1e669d32 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockVideo"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockVideo#1e669d32: %w", err)
|
|
}
|
|
case "video":
|
|
if err := p.Video.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockVideo#1e669d32: field video: %w", err)
|
|
}
|
|
case "caption":
|
|
if err := p.Caption.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockVideo#1e669d32: field caption: %w", err)
|
|
}
|
|
case "need_autoplay":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockVideo#1e669d32: field need_autoplay: %w", err)
|
|
}
|
|
p.NeedAutoplay = value
|
|
case "is_looped":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockVideo#1e669d32: field is_looped: %w", err)
|
|
}
|
|
p.IsLooped = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetVideo returns value of Video field.
|
|
func (p *PageBlockVideo) GetVideo() (value Video) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Video
|
|
}
|
|
|
|
// GetCaption returns value of Caption field.
|
|
func (p *PageBlockVideo) GetCaption() (value PageBlockCaption) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Caption
|
|
}
|
|
|
|
// GetNeedAutoplay returns value of NeedAutoplay field.
|
|
func (p *PageBlockVideo) GetNeedAutoplay() (value bool) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.NeedAutoplay
|
|
}
|
|
|
|
// GetIsLooped returns value of IsLooped field.
|
|
func (p *PageBlockVideo) GetIsLooped() (value bool) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.IsLooped
|
|
}
|
|
|
|
// PageBlockVoiceNote represents TL type `pageBlockVoiceNote#6cad827f`.
|
|
type PageBlockVoiceNote struct {
|
|
// Voice note; may be null
|
|
VoiceNote VoiceNote
|
|
// Voice note caption
|
|
Caption PageBlockCaption
|
|
}
|
|
|
|
// PageBlockVoiceNoteTypeID is TL type id of PageBlockVoiceNote.
|
|
const PageBlockVoiceNoteTypeID = 0x6cad827f
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockVoiceNote) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockVoiceNote.
|
|
var (
|
|
_ bin.Encoder = &PageBlockVoiceNote{}
|
|
_ bin.Decoder = &PageBlockVoiceNote{}
|
|
_ bin.BareEncoder = &PageBlockVoiceNote{}
|
|
_ bin.BareDecoder = &PageBlockVoiceNote{}
|
|
|
|
_ PageBlockClass = &PageBlockVoiceNote{}
|
|
)
|
|
|
|
func (p *PageBlockVoiceNote) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.VoiceNote.Zero()) {
|
|
return false
|
|
}
|
|
if !(p.Caption.Zero()) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockVoiceNote) String() string {
|
|
if p == nil {
|
|
return "PageBlockVoiceNote(nil)"
|
|
}
|
|
type Alias PageBlockVoiceNote
|
|
return fmt.Sprintf("PageBlockVoiceNote%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockVoiceNote) TypeID() uint32 {
|
|
return PageBlockVoiceNoteTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockVoiceNote) TypeName() string {
|
|
return "pageBlockVoiceNote"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockVoiceNote) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockVoiceNote",
|
|
ID: PageBlockVoiceNoteTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "VoiceNote",
|
|
SchemaName: "voice_note",
|
|
},
|
|
{
|
|
Name: "Caption",
|
|
SchemaName: "caption",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockVoiceNote) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockVoiceNote#6cad827f as nil")
|
|
}
|
|
b.PutID(PageBlockVoiceNoteTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockVoiceNote) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockVoiceNote#6cad827f as nil")
|
|
}
|
|
if err := p.VoiceNote.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockVoiceNote#6cad827f: field voice_note: %w", err)
|
|
}
|
|
if err := p.Caption.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockVoiceNote#6cad827f: field caption: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockVoiceNote) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockVoiceNote#6cad827f to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockVoiceNoteTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockVoiceNote#6cad827f: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockVoiceNote) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockVoiceNote#6cad827f to nil")
|
|
}
|
|
{
|
|
if err := p.VoiceNote.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockVoiceNote#6cad827f: field voice_note: %w", err)
|
|
}
|
|
}
|
|
{
|
|
if err := p.Caption.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockVoiceNote#6cad827f: field caption: %w", err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockVoiceNote) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockVoiceNote#6cad827f as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockVoiceNote")
|
|
b.Comma()
|
|
b.FieldStart("voice_note")
|
|
if err := p.VoiceNote.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockVoiceNote#6cad827f: field voice_note: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("caption")
|
|
if err := p.Caption.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockVoiceNote#6cad827f: field caption: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockVoiceNote) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockVoiceNote#6cad827f to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockVoiceNote"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockVoiceNote#6cad827f: %w", err)
|
|
}
|
|
case "voice_note":
|
|
if err := p.VoiceNote.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockVoiceNote#6cad827f: field voice_note: %w", err)
|
|
}
|
|
case "caption":
|
|
if err := p.Caption.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockVoiceNote#6cad827f: field caption: %w", err)
|
|
}
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetVoiceNote returns value of VoiceNote field.
|
|
func (p *PageBlockVoiceNote) GetVoiceNote() (value VoiceNote) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.VoiceNote
|
|
}
|
|
|
|
// GetCaption returns value of Caption field.
|
|
func (p *PageBlockVoiceNote) GetCaption() (value PageBlockCaption) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Caption
|
|
}
|
|
|
|
// PageBlockCover represents TL type `pageBlockCover#39f23300`.
|
|
type PageBlockCover struct {
|
|
// Cover
|
|
Cover PageBlockClass
|
|
}
|
|
|
|
// PageBlockCoverTypeID is TL type id of PageBlockCover.
|
|
const PageBlockCoverTypeID = 0x39f23300
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockCover) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockCover.
|
|
var (
|
|
_ bin.Encoder = &PageBlockCover{}
|
|
_ bin.Decoder = &PageBlockCover{}
|
|
_ bin.BareEncoder = &PageBlockCover{}
|
|
_ bin.BareDecoder = &PageBlockCover{}
|
|
|
|
_ PageBlockClass = &PageBlockCover{}
|
|
)
|
|
|
|
func (p *PageBlockCover) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Cover == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockCover) String() string {
|
|
if p == nil {
|
|
return "PageBlockCover(nil)"
|
|
}
|
|
type Alias PageBlockCover
|
|
return fmt.Sprintf("PageBlockCover%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockCover) TypeID() uint32 {
|
|
return PageBlockCoverTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockCover) TypeName() string {
|
|
return "pageBlockCover"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockCover) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockCover",
|
|
ID: PageBlockCoverTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Cover",
|
|
SchemaName: "cover",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockCover) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockCover#39f23300 as nil")
|
|
}
|
|
b.PutID(PageBlockCoverTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockCover) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockCover#39f23300 as nil")
|
|
}
|
|
if p.Cover == nil {
|
|
return fmt.Errorf("unable to encode pageBlockCover#39f23300: field cover is nil")
|
|
}
|
|
if err := p.Cover.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockCover#39f23300: field cover: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockCover) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockCover#39f23300 to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockCoverTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockCover#39f23300: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockCover) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockCover#39f23300 to nil")
|
|
}
|
|
{
|
|
value, err := DecodePageBlock(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockCover#39f23300: field cover: %w", err)
|
|
}
|
|
p.Cover = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockCover) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockCover#39f23300 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockCover")
|
|
b.Comma()
|
|
b.FieldStart("cover")
|
|
if p.Cover == nil {
|
|
return fmt.Errorf("unable to encode pageBlockCover#39f23300: field cover is nil")
|
|
}
|
|
if err := p.Cover.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockCover#39f23300: field cover: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockCover) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockCover#39f23300 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockCover"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockCover#39f23300: %w", err)
|
|
}
|
|
case "cover":
|
|
value, err := DecodeTDLibJSONPageBlock(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockCover#39f23300: field cover: %w", err)
|
|
}
|
|
p.Cover = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetCover returns value of Cover field.
|
|
func (p *PageBlockCover) GetCover() (value PageBlockClass) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Cover
|
|
}
|
|
|
|
// PageBlockEmbedded represents TL type `pageBlockEmbedded#8c369d9d`.
|
|
type PageBlockEmbedded struct {
|
|
// URL of the embedded page, if available
|
|
URL string
|
|
// HTML-markup of the embedded page
|
|
HTML string
|
|
// Poster photo, if available; may be null
|
|
PosterPhoto Photo
|
|
// Block width; 0 if unknown
|
|
Width int32
|
|
// Block height; 0 if unknown
|
|
Height int32
|
|
// Block caption
|
|
Caption PageBlockCaption
|
|
// True, if the block must be full width
|
|
IsFullWidth bool
|
|
// True, if scrolling needs to be allowed
|
|
AllowScrolling bool
|
|
}
|
|
|
|
// PageBlockEmbeddedTypeID is TL type id of PageBlockEmbedded.
|
|
const PageBlockEmbeddedTypeID = 0x8c369d9d
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockEmbedded) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockEmbedded.
|
|
var (
|
|
_ bin.Encoder = &PageBlockEmbedded{}
|
|
_ bin.Decoder = &PageBlockEmbedded{}
|
|
_ bin.BareEncoder = &PageBlockEmbedded{}
|
|
_ bin.BareDecoder = &PageBlockEmbedded{}
|
|
|
|
_ PageBlockClass = &PageBlockEmbedded{}
|
|
)
|
|
|
|
func (p *PageBlockEmbedded) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.URL == "") {
|
|
return false
|
|
}
|
|
if !(p.HTML == "") {
|
|
return false
|
|
}
|
|
if !(p.PosterPhoto.Zero()) {
|
|
return false
|
|
}
|
|
if !(p.Width == 0) {
|
|
return false
|
|
}
|
|
if !(p.Height == 0) {
|
|
return false
|
|
}
|
|
if !(p.Caption.Zero()) {
|
|
return false
|
|
}
|
|
if !(p.IsFullWidth == false) {
|
|
return false
|
|
}
|
|
if !(p.AllowScrolling == false) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockEmbedded) String() string {
|
|
if p == nil {
|
|
return "PageBlockEmbedded(nil)"
|
|
}
|
|
type Alias PageBlockEmbedded
|
|
return fmt.Sprintf("PageBlockEmbedded%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockEmbedded) TypeID() uint32 {
|
|
return PageBlockEmbeddedTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockEmbedded) TypeName() string {
|
|
return "pageBlockEmbedded"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockEmbedded) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockEmbedded",
|
|
ID: PageBlockEmbeddedTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "URL",
|
|
SchemaName: "url",
|
|
},
|
|
{
|
|
Name: "HTML",
|
|
SchemaName: "html",
|
|
},
|
|
{
|
|
Name: "PosterPhoto",
|
|
SchemaName: "poster_photo",
|
|
},
|
|
{
|
|
Name: "Width",
|
|
SchemaName: "width",
|
|
},
|
|
{
|
|
Name: "Height",
|
|
SchemaName: "height",
|
|
},
|
|
{
|
|
Name: "Caption",
|
|
SchemaName: "caption",
|
|
},
|
|
{
|
|
Name: "IsFullWidth",
|
|
SchemaName: "is_full_width",
|
|
},
|
|
{
|
|
Name: "AllowScrolling",
|
|
SchemaName: "allow_scrolling",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockEmbedded) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockEmbedded#8c369d9d as nil")
|
|
}
|
|
b.PutID(PageBlockEmbeddedTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockEmbedded) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockEmbedded#8c369d9d as nil")
|
|
}
|
|
b.PutString(p.URL)
|
|
b.PutString(p.HTML)
|
|
if err := p.PosterPhoto.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockEmbedded#8c369d9d: field poster_photo: %w", err)
|
|
}
|
|
b.PutInt32(p.Width)
|
|
b.PutInt32(p.Height)
|
|
if err := p.Caption.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockEmbedded#8c369d9d: field caption: %w", err)
|
|
}
|
|
b.PutBool(p.IsFullWidth)
|
|
b.PutBool(p.AllowScrolling)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockEmbedded) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockEmbedded#8c369d9d to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockEmbeddedTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbedded#8c369d9d: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockEmbedded) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockEmbedded#8c369d9d to nil")
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbedded#8c369d9d: field url: %w", err)
|
|
}
|
|
p.URL = value
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbedded#8c369d9d: field html: %w", err)
|
|
}
|
|
p.HTML = value
|
|
}
|
|
{
|
|
if err := p.PosterPhoto.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbedded#8c369d9d: field poster_photo: %w", err)
|
|
}
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbedded#8c369d9d: field width: %w", err)
|
|
}
|
|
p.Width = value
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbedded#8c369d9d: field height: %w", err)
|
|
}
|
|
p.Height = value
|
|
}
|
|
{
|
|
if err := p.Caption.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbedded#8c369d9d: field caption: %w", err)
|
|
}
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbedded#8c369d9d: field is_full_width: %w", err)
|
|
}
|
|
p.IsFullWidth = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbedded#8c369d9d: field allow_scrolling: %w", err)
|
|
}
|
|
p.AllowScrolling = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockEmbedded) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockEmbedded#8c369d9d as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockEmbedded")
|
|
b.Comma()
|
|
b.FieldStart("url")
|
|
b.PutString(p.URL)
|
|
b.Comma()
|
|
b.FieldStart("html")
|
|
b.PutString(p.HTML)
|
|
b.Comma()
|
|
b.FieldStart("poster_photo")
|
|
if err := p.PosterPhoto.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockEmbedded#8c369d9d: field poster_photo: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("width")
|
|
b.PutInt32(p.Width)
|
|
b.Comma()
|
|
b.FieldStart("height")
|
|
b.PutInt32(p.Height)
|
|
b.Comma()
|
|
b.FieldStart("caption")
|
|
if err := p.Caption.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockEmbedded#8c369d9d: field caption: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("is_full_width")
|
|
b.PutBool(p.IsFullWidth)
|
|
b.Comma()
|
|
b.FieldStart("allow_scrolling")
|
|
b.PutBool(p.AllowScrolling)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockEmbedded) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockEmbedded#8c369d9d to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockEmbedded"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbedded#8c369d9d: %w", err)
|
|
}
|
|
case "url":
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbedded#8c369d9d: field url: %w", err)
|
|
}
|
|
p.URL = value
|
|
case "html":
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbedded#8c369d9d: field html: %w", err)
|
|
}
|
|
p.HTML = value
|
|
case "poster_photo":
|
|
if err := p.PosterPhoto.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbedded#8c369d9d: field poster_photo: %w", err)
|
|
}
|
|
case "width":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbedded#8c369d9d: field width: %w", err)
|
|
}
|
|
p.Width = value
|
|
case "height":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbedded#8c369d9d: field height: %w", err)
|
|
}
|
|
p.Height = value
|
|
case "caption":
|
|
if err := p.Caption.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbedded#8c369d9d: field caption: %w", err)
|
|
}
|
|
case "is_full_width":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbedded#8c369d9d: field is_full_width: %w", err)
|
|
}
|
|
p.IsFullWidth = value
|
|
case "allow_scrolling":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbedded#8c369d9d: field allow_scrolling: %w", err)
|
|
}
|
|
p.AllowScrolling = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetURL returns value of URL field.
|
|
func (p *PageBlockEmbedded) GetURL() (value string) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.URL
|
|
}
|
|
|
|
// GetHTML returns value of HTML field.
|
|
func (p *PageBlockEmbedded) GetHTML() (value string) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.HTML
|
|
}
|
|
|
|
// GetPosterPhoto returns value of PosterPhoto field.
|
|
func (p *PageBlockEmbedded) GetPosterPhoto() (value Photo) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.PosterPhoto
|
|
}
|
|
|
|
// GetWidth returns value of Width field.
|
|
func (p *PageBlockEmbedded) GetWidth() (value int32) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Width
|
|
}
|
|
|
|
// GetHeight returns value of Height field.
|
|
func (p *PageBlockEmbedded) GetHeight() (value int32) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Height
|
|
}
|
|
|
|
// GetCaption returns value of Caption field.
|
|
func (p *PageBlockEmbedded) GetCaption() (value PageBlockCaption) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Caption
|
|
}
|
|
|
|
// GetIsFullWidth returns value of IsFullWidth field.
|
|
func (p *PageBlockEmbedded) GetIsFullWidth() (value bool) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.IsFullWidth
|
|
}
|
|
|
|
// GetAllowScrolling returns value of AllowScrolling field.
|
|
func (p *PageBlockEmbedded) GetAllowScrolling() (value bool) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.AllowScrolling
|
|
}
|
|
|
|
// PageBlockEmbeddedPost represents TL type `pageBlockEmbeddedPost#bc57cdf5`.
|
|
type PageBlockEmbeddedPost struct {
|
|
// URL of the embedded post
|
|
URL string
|
|
// Post author
|
|
Author string
|
|
// Post author photo; may be null
|
|
AuthorPhoto Photo
|
|
// Point in time (Unix timestamp) when the post was created; 0 if unknown
|
|
Date int32
|
|
// Post content
|
|
PageBlocks []PageBlockClass
|
|
// Post caption
|
|
Caption PageBlockCaption
|
|
}
|
|
|
|
// PageBlockEmbeddedPostTypeID is TL type id of PageBlockEmbeddedPost.
|
|
const PageBlockEmbeddedPostTypeID = 0xbc57cdf5
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockEmbeddedPost) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockEmbeddedPost.
|
|
var (
|
|
_ bin.Encoder = &PageBlockEmbeddedPost{}
|
|
_ bin.Decoder = &PageBlockEmbeddedPost{}
|
|
_ bin.BareEncoder = &PageBlockEmbeddedPost{}
|
|
_ bin.BareDecoder = &PageBlockEmbeddedPost{}
|
|
|
|
_ PageBlockClass = &PageBlockEmbeddedPost{}
|
|
)
|
|
|
|
func (p *PageBlockEmbeddedPost) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.URL == "") {
|
|
return false
|
|
}
|
|
if !(p.Author == "") {
|
|
return false
|
|
}
|
|
if !(p.AuthorPhoto.Zero()) {
|
|
return false
|
|
}
|
|
if !(p.Date == 0) {
|
|
return false
|
|
}
|
|
if !(p.PageBlocks == nil) {
|
|
return false
|
|
}
|
|
if !(p.Caption.Zero()) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockEmbeddedPost) String() string {
|
|
if p == nil {
|
|
return "PageBlockEmbeddedPost(nil)"
|
|
}
|
|
type Alias PageBlockEmbeddedPost
|
|
return fmt.Sprintf("PageBlockEmbeddedPost%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockEmbeddedPost) TypeID() uint32 {
|
|
return PageBlockEmbeddedPostTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockEmbeddedPost) TypeName() string {
|
|
return "pageBlockEmbeddedPost"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockEmbeddedPost) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockEmbeddedPost",
|
|
ID: PageBlockEmbeddedPostTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "URL",
|
|
SchemaName: "url",
|
|
},
|
|
{
|
|
Name: "Author",
|
|
SchemaName: "author",
|
|
},
|
|
{
|
|
Name: "AuthorPhoto",
|
|
SchemaName: "author_photo",
|
|
},
|
|
{
|
|
Name: "Date",
|
|
SchemaName: "date",
|
|
},
|
|
{
|
|
Name: "PageBlocks",
|
|
SchemaName: "page_blocks",
|
|
},
|
|
{
|
|
Name: "Caption",
|
|
SchemaName: "caption",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockEmbeddedPost) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockEmbeddedPost#bc57cdf5 as nil")
|
|
}
|
|
b.PutID(PageBlockEmbeddedPostTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockEmbeddedPost) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockEmbeddedPost#bc57cdf5 as nil")
|
|
}
|
|
b.PutString(p.URL)
|
|
b.PutString(p.Author)
|
|
if err := p.AuthorPhoto.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockEmbeddedPost#bc57cdf5: field author_photo: %w", err)
|
|
}
|
|
b.PutInt32(p.Date)
|
|
b.PutInt(len(p.PageBlocks))
|
|
for idx, v := range p.PageBlocks {
|
|
if v == nil {
|
|
return fmt.Errorf("unable to encode pageBlockEmbeddedPost#bc57cdf5: field page_blocks element with index %d is nil", idx)
|
|
}
|
|
if err := v.EncodeBare(b); err != nil {
|
|
return fmt.Errorf("unable to encode bare pageBlockEmbeddedPost#bc57cdf5: field page_blocks element with index %d: %w", idx, err)
|
|
}
|
|
}
|
|
if err := p.Caption.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockEmbeddedPost#bc57cdf5: field caption: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockEmbeddedPost) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockEmbeddedPost#bc57cdf5 to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockEmbeddedPostTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbeddedPost#bc57cdf5: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockEmbeddedPost) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockEmbeddedPost#bc57cdf5 to nil")
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbeddedPost#bc57cdf5: field url: %w", err)
|
|
}
|
|
p.URL = value
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbeddedPost#bc57cdf5: field author: %w", err)
|
|
}
|
|
p.Author = value
|
|
}
|
|
{
|
|
if err := p.AuthorPhoto.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbeddedPost#bc57cdf5: field author_photo: %w", err)
|
|
}
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbeddedPost#bc57cdf5: field date: %w", err)
|
|
}
|
|
p.Date = value
|
|
}
|
|
{
|
|
headerLen, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbeddedPost#bc57cdf5: field page_blocks: %w", err)
|
|
}
|
|
|
|
if headerLen > 0 {
|
|
p.PageBlocks = make([]PageBlockClass, 0, headerLen%bin.PreallocateLimit)
|
|
}
|
|
for idx := 0; idx < headerLen; idx++ {
|
|
value, err := DecodePageBlock(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbeddedPost#bc57cdf5: field page_blocks: %w", err)
|
|
}
|
|
p.PageBlocks = append(p.PageBlocks, value)
|
|
}
|
|
}
|
|
{
|
|
if err := p.Caption.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbeddedPost#bc57cdf5: field caption: %w", err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockEmbeddedPost) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockEmbeddedPost#bc57cdf5 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockEmbeddedPost")
|
|
b.Comma()
|
|
b.FieldStart("url")
|
|
b.PutString(p.URL)
|
|
b.Comma()
|
|
b.FieldStart("author")
|
|
b.PutString(p.Author)
|
|
b.Comma()
|
|
b.FieldStart("author_photo")
|
|
if err := p.AuthorPhoto.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockEmbeddedPost#bc57cdf5: field author_photo: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("date")
|
|
b.PutInt32(p.Date)
|
|
b.Comma()
|
|
b.FieldStart("page_blocks")
|
|
b.ArrStart()
|
|
for idx, v := range p.PageBlocks {
|
|
if v == nil {
|
|
return fmt.Errorf("unable to encode pageBlockEmbeddedPost#bc57cdf5: field page_blocks element with index %d is nil", idx)
|
|
}
|
|
if err := v.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockEmbeddedPost#bc57cdf5: field page_blocks element with index %d: %w", idx, err)
|
|
}
|
|
b.Comma()
|
|
}
|
|
b.StripComma()
|
|
b.ArrEnd()
|
|
b.Comma()
|
|
b.FieldStart("caption")
|
|
if err := p.Caption.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockEmbeddedPost#bc57cdf5: field caption: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockEmbeddedPost) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockEmbeddedPost#bc57cdf5 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockEmbeddedPost"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbeddedPost#bc57cdf5: %w", err)
|
|
}
|
|
case "url":
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbeddedPost#bc57cdf5: field url: %w", err)
|
|
}
|
|
p.URL = value
|
|
case "author":
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbeddedPost#bc57cdf5: field author: %w", err)
|
|
}
|
|
p.Author = value
|
|
case "author_photo":
|
|
if err := p.AuthorPhoto.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbeddedPost#bc57cdf5: field author_photo: %w", err)
|
|
}
|
|
case "date":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbeddedPost#bc57cdf5: field date: %w", err)
|
|
}
|
|
p.Date = value
|
|
case "page_blocks":
|
|
if err := b.Arr(func(b tdjson.Decoder) error {
|
|
value, err := DecodeTDLibJSONPageBlock(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbeddedPost#bc57cdf5: field page_blocks: %w", err)
|
|
}
|
|
p.PageBlocks = append(p.PageBlocks, value)
|
|
return nil
|
|
}); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbeddedPost#bc57cdf5: field page_blocks: %w", err)
|
|
}
|
|
case "caption":
|
|
if err := p.Caption.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockEmbeddedPost#bc57cdf5: field caption: %w", err)
|
|
}
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetURL returns value of URL field.
|
|
func (p *PageBlockEmbeddedPost) GetURL() (value string) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.URL
|
|
}
|
|
|
|
// GetAuthor returns value of Author field.
|
|
func (p *PageBlockEmbeddedPost) GetAuthor() (value string) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Author
|
|
}
|
|
|
|
// GetAuthorPhoto returns value of AuthorPhoto field.
|
|
func (p *PageBlockEmbeddedPost) GetAuthorPhoto() (value Photo) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.AuthorPhoto
|
|
}
|
|
|
|
// GetDate returns value of Date field.
|
|
func (p *PageBlockEmbeddedPost) GetDate() (value int32) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Date
|
|
}
|
|
|
|
// GetPageBlocks returns value of PageBlocks field.
|
|
func (p *PageBlockEmbeddedPost) GetPageBlocks() (value []PageBlockClass) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.PageBlocks
|
|
}
|
|
|
|
// GetCaption returns value of Caption field.
|
|
func (p *PageBlockEmbeddedPost) GetCaption() (value PageBlockCaption) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Caption
|
|
}
|
|
|
|
// PageBlockCollage represents TL type `pageBlockCollage#40bcaaf0`.
|
|
type PageBlockCollage struct {
|
|
// Collage item contents
|
|
PageBlocks []PageBlockClass
|
|
// Block caption
|
|
Caption PageBlockCaption
|
|
}
|
|
|
|
// PageBlockCollageTypeID is TL type id of PageBlockCollage.
|
|
const PageBlockCollageTypeID = 0x40bcaaf0
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockCollage) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockCollage.
|
|
var (
|
|
_ bin.Encoder = &PageBlockCollage{}
|
|
_ bin.Decoder = &PageBlockCollage{}
|
|
_ bin.BareEncoder = &PageBlockCollage{}
|
|
_ bin.BareDecoder = &PageBlockCollage{}
|
|
|
|
_ PageBlockClass = &PageBlockCollage{}
|
|
)
|
|
|
|
func (p *PageBlockCollage) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.PageBlocks == nil) {
|
|
return false
|
|
}
|
|
if !(p.Caption.Zero()) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockCollage) String() string {
|
|
if p == nil {
|
|
return "PageBlockCollage(nil)"
|
|
}
|
|
type Alias PageBlockCollage
|
|
return fmt.Sprintf("PageBlockCollage%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockCollage) TypeID() uint32 {
|
|
return PageBlockCollageTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockCollage) TypeName() string {
|
|
return "pageBlockCollage"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockCollage) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockCollage",
|
|
ID: PageBlockCollageTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "PageBlocks",
|
|
SchemaName: "page_blocks",
|
|
},
|
|
{
|
|
Name: "Caption",
|
|
SchemaName: "caption",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockCollage) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockCollage#40bcaaf0 as nil")
|
|
}
|
|
b.PutID(PageBlockCollageTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockCollage) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockCollage#40bcaaf0 as nil")
|
|
}
|
|
b.PutInt(len(p.PageBlocks))
|
|
for idx, v := range p.PageBlocks {
|
|
if v == nil {
|
|
return fmt.Errorf("unable to encode pageBlockCollage#40bcaaf0: field page_blocks element with index %d is nil", idx)
|
|
}
|
|
if err := v.EncodeBare(b); err != nil {
|
|
return fmt.Errorf("unable to encode bare pageBlockCollage#40bcaaf0: field page_blocks element with index %d: %w", idx, err)
|
|
}
|
|
}
|
|
if err := p.Caption.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockCollage#40bcaaf0: field caption: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockCollage) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockCollage#40bcaaf0 to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockCollageTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockCollage#40bcaaf0: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockCollage) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockCollage#40bcaaf0 to nil")
|
|
}
|
|
{
|
|
headerLen, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockCollage#40bcaaf0: field page_blocks: %w", err)
|
|
}
|
|
|
|
if headerLen > 0 {
|
|
p.PageBlocks = make([]PageBlockClass, 0, headerLen%bin.PreallocateLimit)
|
|
}
|
|
for idx := 0; idx < headerLen; idx++ {
|
|
value, err := DecodePageBlock(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockCollage#40bcaaf0: field page_blocks: %w", err)
|
|
}
|
|
p.PageBlocks = append(p.PageBlocks, value)
|
|
}
|
|
}
|
|
{
|
|
if err := p.Caption.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockCollage#40bcaaf0: field caption: %w", err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockCollage) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockCollage#40bcaaf0 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockCollage")
|
|
b.Comma()
|
|
b.FieldStart("page_blocks")
|
|
b.ArrStart()
|
|
for idx, v := range p.PageBlocks {
|
|
if v == nil {
|
|
return fmt.Errorf("unable to encode pageBlockCollage#40bcaaf0: field page_blocks element with index %d is nil", idx)
|
|
}
|
|
if err := v.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockCollage#40bcaaf0: field page_blocks element with index %d: %w", idx, err)
|
|
}
|
|
b.Comma()
|
|
}
|
|
b.StripComma()
|
|
b.ArrEnd()
|
|
b.Comma()
|
|
b.FieldStart("caption")
|
|
if err := p.Caption.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockCollage#40bcaaf0: field caption: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockCollage) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockCollage#40bcaaf0 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockCollage"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockCollage#40bcaaf0: %w", err)
|
|
}
|
|
case "page_blocks":
|
|
if err := b.Arr(func(b tdjson.Decoder) error {
|
|
value, err := DecodeTDLibJSONPageBlock(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockCollage#40bcaaf0: field page_blocks: %w", err)
|
|
}
|
|
p.PageBlocks = append(p.PageBlocks, value)
|
|
return nil
|
|
}); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockCollage#40bcaaf0: field page_blocks: %w", err)
|
|
}
|
|
case "caption":
|
|
if err := p.Caption.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockCollage#40bcaaf0: field caption: %w", err)
|
|
}
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetPageBlocks returns value of PageBlocks field.
|
|
func (p *PageBlockCollage) GetPageBlocks() (value []PageBlockClass) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.PageBlocks
|
|
}
|
|
|
|
// GetCaption returns value of Caption field.
|
|
func (p *PageBlockCollage) GetCaption() (value PageBlockCaption) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Caption
|
|
}
|
|
|
|
// PageBlockSlideshow represents TL type `pageBlockSlideshow#1107d496`.
|
|
type PageBlockSlideshow struct {
|
|
// Slideshow item contents
|
|
PageBlocks []PageBlockClass
|
|
// Block caption
|
|
Caption PageBlockCaption
|
|
}
|
|
|
|
// PageBlockSlideshowTypeID is TL type id of PageBlockSlideshow.
|
|
const PageBlockSlideshowTypeID = 0x1107d496
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockSlideshow) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockSlideshow.
|
|
var (
|
|
_ bin.Encoder = &PageBlockSlideshow{}
|
|
_ bin.Decoder = &PageBlockSlideshow{}
|
|
_ bin.BareEncoder = &PageBlockSlideshow{}
|
|
_ bin.BareDecoder = &PageBlockSlideshow{}
|
|
|
|
_ PageBlockClass = &PageBlockSlideshow{}
|
|
)
|
|
|
|
func (p *PageBlockSlideshow) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.PageBlocks == nil) {
|
|
return false
|
|
}
|
|
if !(p.Caption.Zero()) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockSlideshow) String() string {
|
|
if p == nil {
|
|
return "PageBlockSlideshow(nil)"
|
|
}
|
|
type Alias PageBlockSlideshow
|
|
return fmt.Sprintf("PageBlockSlideshow%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockSlideshow) TypeID() uint32 {
|
|
return PageBlockSlideshowTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockSlideshow) TypeName() string {
|
|
return "pageBlockSlideshow"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockSlideshow) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockSlideshow",
|
|
ID: PageBlockSlideshowTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "PageBlocks",
|
|
SchemaName: "page_blocks",
|
|
},
|
|
{
|
|
Name: "Caption",
|
|
SchemaName: "caption",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockSlideshow) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockSlideshow#1107d496 as nil")
|
|
}
|
|
b.PutID(PageBlockSlideshowTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockSlideshow) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockSlideshow#1107d496 as nil")
|
|
}
|
|
b.PutInt(len(p.PageBlocks))
|
|
for idx, v := range p.PageBlocks {
|
|
if v == nil {
|
|
return fmt.Errorf("unable to encode pageBlockSlideshow#1107d496: field page_blocks element with index %d is nil", idx)
|
|
}
|
|
if err := v.EncodeBare(b); err != nil {
|
|
return fmt.Errorf("unable to encode bare pageBlockSlideshow#1107d496: field page_blocks element with index %d: %w", idx, err)
|
|
}
|
|
}
|
|
if err := p.Caption.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockSlideshow#1107d496: field caption: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockSlideshow) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockSlideshow#1107d496 to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockSlideshowTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockSlideshow#1107d496: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockSlideshow) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockSlideshow#1107d496 to nil")
|
|
}
|
|
{
|
|
headerLen, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockSlideshow#1107d496: field page_blocks: %w", err)
|
|
}
|
|
|
|
if headerLen > 0 {
|
|
p.PageBlocks = make([]PageBlockClass, 0, headerLen%bin.PreallocateLimit)
|
|
}
|
|
for idx := 0; idx < headerLen; idx++ {
|
|
value, err := DecodePageBlock(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockSlideshow#1107d496: field page_blocks: %w", err)
|
|
}
|
|
p.PageBlocks = append(p.PageBlocks, value)
|
|
}
|
|
}
|
|
{
|
|
if err := p.Caption.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockSlideshow#1107d496: field caption: %w", err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockSlideshow) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockSlideshow#1107d496 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockSlideshow")
|
|
b.Comma()
|
|
b.FieldStart("page_blocks")
|
|
b.ArrStart()
|
|
for idx, v := range p.PageBlocks {
|
|
if v == nil {
|
|
return fmt.Errorf("unable to encode pageBlockSlideshow#1107d496: field page_blocks element with index %d is nil", idx)
|
|
}
|
|
if err := v.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockSlideshow#1107d496: field page_blocks element with index %d: %w", idx, err)
|
|
}
|
|
b.Comma()
|
|
}
|
|
b.StripComma()
|
|
b.ArrEnd()
|
|
b.Comma()
|
|
b.FieldStart("caption")
|
|
if err := p.Caption.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockSlideshow#1107d496: field caption: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockSlideshow) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockSlideshow#1107d496 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockSlideshow"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockSlideshow#1107d496: %w", err)
|
|
}
|
|
case "page_blocks":
|
|
if err := b.Arr(func(b tdjson.Decoder) error {
|
|
value, err := DecodeTDLibJSONPageBlock(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockSlideshow#1107d496: field page_blocks: %w", err)
|
|
}
|
|
p.PageBlocks = append(p.PageBlocks, value)
|
|
return nil
|
|
}); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockSlideshow#1107d496: field page_blocks: %w", err)
|
|
}
|
|
case "caption":
|
|
if err := p.Caption.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockSlideshow#1107d496: field caption: %w", err)
|
|
}
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetPageBlocks returns value of PageBlocks field.
|
|
func (p *PageBlockSlideshow) GetPageBlocks() (value []PageBlockClass) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.PageBlocks
|
|
}
|
|
|
|
// GetCaption returns value of Caption field.
|
|
func (p *PageBlockSlideshow) GetCaption() (value PageBlockCaption) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Caption
|
|
}
|
|
|
|
// PageBlockChatLink represents TL type `pageBlockChatLink#621ed8bb`.
|
|
type PageBlockChatLink struct {
|
|
// Chat title
|
|
Title string
|
|
// Chat photo; may be null
|
|
Photo ChatPhotoInfo
|
|
// Identifier of the accent color for chat title and background of chat photo
|
|
AccentColorID int32
|
|
// Chat username by which all other information about the chat can be resolved
|
|
Username string
|
|
}
|
|
|
|
// PageBlockChatLinkTypeID is TL type id of PageBlockChatLink.
|
|
const PageBlockChatLinkTypeID = 0x621ed8bb
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockChatLink) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockChatLink.
|
|
var (
|
|
_ bin.Encoder = &PageBlockChatLink{}
|
|
_ bin.Decoder = &PageBlockChatLink{}
|
|
_ bin.BareEncoder = &PageBlockChatLink{}
|
|
_ bin.BareDecoder = &PageBlockChatLink{}
|
|
|
|
_ PageBlockClass = &PageBlockChatLink{}
|
|
)
|
|
|
|
func (p *PageBlockChatLink) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Title == "") {
|
|
return false
|
|
}
|
|
if !(p.Photo.Zero()) {
|
|
return false
|
|
}
|
|
if !(p.AccentColorID == 0) {
|
|
return false
|
|
}
|
|
if !(p.Username == "") {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockChatLink) String() string {
|
|
if p == nil {
|
|
return "PageBlockChatLink(nil)"
|
|
}
|
|
type Alias PageBlockChatLink
|
|
return fmt.Sprintf("PageBlockChatLink%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockChatLink) TypeID() uint32 {
|
|
return PageBlockChatLinkTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockChatLink) TypeName() string {
|
|
return "pageBlockChatLink"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockChatLink) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockChatLink",
|
|
ID: PageBlockChatLinkTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Title",
|
|
SchemaName: "title",
|
|
},
|
|
{
|
|
Name: "Photo",
|
|
SchemaName: "photo",
|
|
},
|
|
{
|
|
Name: "AccentColorID",
|
|
SchemaName: "accent_color_id",
|
|
},
|
|
{
|
|
Name: "Username",
|
|
SchemaName: "username",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockChatLink) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockChatLink#621ed8bb as nil")
|
|
}
|
|
b.PutID(PageBlockChatLinkTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockChatLink) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockChatLink#621ed8bb as nil")
|
|
}
|
|
b.PutString(p.Title)
|
|
if err := p.Photo.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockChatLink#621ed8bb: field photo: %w", err)
|
|
}
|
|
b.PutInt32(p.AccentColorID)
|
|
b.PutString(p.Username)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockChatLink) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockChatLink#621ed8bb to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockChatLinkTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockChatLink#621ed8bb: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockChatLink) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockChatLink#621ed8bb to nil")
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockChatLink#621ed8bb: field title: %w", err)
|
|
}
|
|
p.Title = value
|
|
}
|
|
{
|
|
if err := p.Photo.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockChatLink#621ed8bb: field photo: %w", err)
|
|
}
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockChatLink#621ed8bb: field accent_color_id: %w", err)
|
|
}
|
|
p.AccentColorID = value
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockChatLink#621ed8bb: field username: %w", err)
|
|
}
|
|
p.Username = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockChatLink) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockChatLink#621ed8bb as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockChatLink")
|
|
b.Comma()
|
|
b.FieldStart("title")
|
|
b.PutString(p.Title)
|
|
b.Comma()
|
|
b.FieldStart("photo")
|
|
if err := p.Photo.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockChatLink#621ed8bb: field photo: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("accent_color_id")
|
|
b.PutInt32(p.AccentColorID)
|
|
b.Comma()
|
|
b.FieldStart("username")
|
|
b.PutString(p.Username)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockChatLink) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockChatLink#621ed8bb to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockChatLink"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockChatLink#621ed8bb: %w", err)
|
|
}
|
|
case "title":
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockChatLink#621ed8bb: field title: %w", err)
|
|
}
|
|
p.Title = value
|
|
case "photo":
|
|
if err := p.Photo.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockChatLink#621ed8bb: field photo: %w", err)
|
|
}
|
|
case "accent_color_id":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockChatLink#621ed8bb: field accent_color_id: %w", err)
|
|
}
|
|
p.AccentColorID = value
|
|
case "username":
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockChatLink#621ed8bb: field username: %w", err)
|
|
}
|
|
p.Username = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetTitle returns value of Title field.
|
|
func (p *PageBlockChatLink) GetTitle() (value string) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Title
|
|
}
|
|
|
|
// GetPhoto returns value of Photo field.
|
|
func (p *PageBlockChatLink) GetPhoto() (value ChatPhotoInfo) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Photo
|
|
}
|
|
|
|
// GetAccentColorID returns value of AccentColorID field.
|
|
func (p *PageBlockChatLink) GetAccentColorID() (value int32) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.AccentColorID
|
|
}
|
|
|
|
// GetUsername returns value of Username field.
|
|
func (p *PageBlockChatLink) GetUsername() (value string) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Username
|
|
}
|
|
|
|
// PageBlockTable represents TL type `pageBlockTable#cc6352c3`.
|
|
type PageBlockTable struct {
|
|
// Table caption
|
|
Caption RichTextClass
|
|
// Table cells
|
|
Cells [][]PageBlockTableCell
|
|
// True, if the table is bordered
|
|
IsBordered bool
|
|
// True, if the table is striped
|
|
IsStriped bool
|
|
}
|
|
|
|
// PageBlockTableTypeID is TL type id of PageBlockTable.
|
|
const PageBlockTableTypeID = 0xcc6352c3
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockTable) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockTable.
|
|
var (
|
|
_ bin.Encoder = &PageBlockTable{}
|
|
_ bin.Decoder = &PageBlockTable{}
|
|
_ bin.BareEncoder = &PageBlockTable{}
|
|
_ bin.BareDecoder = &PageBlockTable{}
|
|
|
|
_ PageBlockClass = &PageBlockTable{}
|
|
)
|
|
|
|
func (p *PageBlockTable) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Caption == nil) {
|
|
return false
|
|
}
|
|
if !(p.Cells == nil) {
|
|
return false
|
|
}
|
|
if !(p.IsBordered == false) {
|
|
return false
|
|
}
|
|
if !(p.IsStriped == false) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockTable) String() string {
|
|
if p == nil {
|
|
return "PageBlockTable(nil)"
|
|
}
|
|
type Alias PageBlockTable
|
|
return fmt.Sprintf("PageBlockTable%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockTable) TypeID() uint32 {
|
|
return PageBlockTableTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockTable) TypeName() string {
|
|
return "pageBlockTable"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockTable) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockTable",
|
|
ID: PageBlockTableTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Caption",
|
|
SchemaName: "caption",
|
|
},
|
|
{
|
|
Name: "Cells",
|
|
SchemaName: "cells",
|
|
},
|
|
{
|
|
Name: "IsBordered",
|
|
SchemaName: "is_bordered",
|
|
},
|
|
{
|
|
Name: "IsStriped",
|
|
SchemaName: "is_striped",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockTable) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockTable#cc6352c3 as nil")
|
|
}
|
|
b.PutID(PageBlockTableTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockTable) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockTable#cc6352c3 as nil")
|
|
}
|
|
if p.Caption == nil {
|
|
return fmt.Errorf("unable to encode pageBlockTable#cc6352c3: field caption is nil")
|
|
}
|
|
if err := p.Caption.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockTable#cc6352c3: field caption: %w", err)
|
|
}
|
|
b.PutInt(len(p.Cells))
|
|
for idx, row := range p.Cells {
|
|
b.PutVectorHeader(len(row))
|
|
for _, v := range row {
|
|
if err := v.EncodeBare(b); err != nil {
|
|
return fmt.Errorf("unable to encode bare pageBlockTable#cc6352c3: field cells element with index %d: %w", idx, err)
|
|
}
|
|
}
|
|
}
|
|
b.PutBool(p.IsBordered)
|
|
b.PutBool(p.IsStriped)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockTable) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockTable#cc6352c3 to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockTableTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockTable#cc6352c3: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockTable) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockTable#cc6352c3 to nil")
|
|
}
|
|
{
|
|
value, err := DecodeRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockTable#cc6352c3: field caption: %w", err)
|
|
}
|
|
p.Caption = value
|
|
}
|
|
{
|
|
headerLen, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockTable#cc6352c3: field cells: %w", err)
|
|
}
|
|
|
|
if headerLen > 0 {
|
|
p.Cells = make([][]PageBlockTableCell, 0, headerLen%bin.PreallocateLimit)
|
|
}
|
|
for idx := 0; idx < headerLen; idx++ {
|
|
innerLen, err := b.VectorHeader()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockTable#cc6352c3: field cells: %w", err)
|
|
}
|
|
|
|
var row []PageBlockTableCell
|
|
if innerLen > 0 {
|
|
row = make([]PageBlockTableCell, 0, innerLen%bin.PreallocateLimit)
|
|
}
|
|
for innerIndex := 0; innerIndex < innerLen; innerLen++ {
|
|
var value PageBlockTableCell
|
|
if err := value.DecodeBare(b); err != nil {
|
|
return fmt.Errorf("unable to decode bare pageBlockTable#cc6352c3: field cells: %w", err)
|
|
}
|
|
row = append(row, value)
|
|
}
|
|
p.Cells = append(p.Cells, row)
|
|
}
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockTable#cc6352c3: field is_bordered: %w", err)
|
|
}
|
|
p.IsBordered = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockTable#cc6352c3: field is_striped: %w", err)
|
|
}
|
|
p.IsStriped = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockTable) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockTable#cc6352c3 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockTable")
|
|
b.Comma()
|
|
b.FieldStart("caption")
|
|
if p.Caption == nil {
|
|
return fmt.Errorf("unable to encode pageBlockTable#cc6352c3: field caption is nil")
|
|
}
|
|
if err := p.Caption.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockTable#cc6352c3: field caption: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("cells")
|
|
b.ArrStart()
|
|
for idx, row := range p.Cells {
|
|
b.ArrStart()
|
|
for _, v := range row {
|
|
if err := v.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockTable#cc6352c3: field cells element with index %d: %w", idx, err)
|
|
}
|
|
b.Comma()
|
|
}
|
|
b.StripComma()
|
|
b.ArrEnd()
|
|
b.Comma()
|
|
}
|
|
b.StripComma()
|
|
b.ArrEnd()
|
|
b.Comma()
|
|
b.FieldStart("is_bordered")
|
|
b.PutBool(p.IsBordered)
|
|
b.Comma()
|
|
b.FieldStart("is_striped")
|
|
b.PutBool(p.IsStriped)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockTable) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockTable#cc6352c3 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockTable"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockTable#cc6352c3: %w", err)
|
|
}
|
|
case "caption":
|
|
value, err := DecodeTDLibJSONRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockTable#cc6352c3: field caption: %w", err)
|
|
}
|
|
p.Caption = value
|
|
case "cells":
|
|
if err := b.Arr(func(b tdjson.Decoder) error {
|
|
var row []PageBlockTableCell
|
|
if err := b.Arr(func(b tdjson.Decoder) error {
|
|
var value PageBlockTableCell
|
|
if err := value.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockTable#cc6352c3: field cells: %w", err)
|
|
}
|
|
row = append(row, value)
|
|
return nil
|
|
}); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockTable#cc6352c3: field cells: %w", err)
|
|
}
|
|
p.Cells = append(p.Cells, row)
|
|
return nil
|
|
}); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockTable#cc6352c3: field cells: %w", err)
|
|
}
|
|
case "is_bordered":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockTable#cc6352c3: field is_bordered: %w", err)
|
|
}
|
|
p.IsBordered = value
|
|
case "is_striped":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockTable#cc6352c3: field is_striped: %w", err)
|
|
}
|
|
p.IsStriped = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetCaption returns value of Caption field.
|
|
func (p *PageBlockTable) GetCaption() (value RichTextClass) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Caption
|
|
}
|
|
|
|
// GetCells returns value of Cells field.
|
|
func (p *PageBlockTable) GetCells() (value [][]PageBlockTableCell) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Cells
|
|
}
|
|
|
|
// GetIsBordered returns value of IsBordered field.
|
|
func (p *PageBlockTable) GetIsBordered() (value bool) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.IsBordered
|
|
}
|
|
|
|
// GetIsStriped returns value of IsStriped field.
|
|
func (p *PageBlockTable) GetIsStriped() (value bool) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.IsStriped
|
|
}
|
|
|
|
// PageBlockDetails represents TL type `pageBlockDetails#990a0c0b`.
|
|
type PageBlockDetails struct {
|
|
// Always visible heading for the block
|
|
Header RichTextClass
|
|
// Block contents
|
|
PageBlocks []PageBlockClass
|
|
// True, if the block is open by default
|
|
IsOpen bool
|
|
}
|
|
|
|
// PageBlockDetailsTypeID is TL type id of PageBlockDetails.
|
|
const PageBlockDetailsTypeID = 0x990a0c0b
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockDetails) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockDetails.
|
|
var (
|
|
_ bin.Encoder = &PageBlockDetails{}
|
|
_ bin.Decoder = &PageBlockDetails{}
|
|
_ bin.BareEncoder = &PageBlockDetails{}
|
|
_ bin.BareDecoder = &PageBlockDetails{}
|
|
|
|
_ PageBlockClass = &PageBlockDetails{}
|
|
)
|
|
|
|
func (p *PageBlockDetails) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Header == nil) {
|
|
return false
|
|
}
|
|
if !(p.PageBlocks == nil) {
|
|
return false
|
|
}
|
|
if !(p.IsOpen == false) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockDetails) String() string {
|
|
if p == nil {
|
|
return "PageBlockDetails(nil)"
|
|
}
|
|
type Alias PageBlockDetails
|
|
return fmt.Sprintf("PageBlockDetails%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockDetails) TypeID() uint32 {
|
|
return PageBlockDetailsTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockDetails) TypeName() string {
|
|
return "pageBlockDetails"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockDetails) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockDetails",
|
|
ID: PageBlockDetailsTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Header",
|
|
SchemaName: "header",
|
|
},
|
|
{
|
|
Name: "PageBlocks",
|
|
SchemaName: "page_blocks",
|
|
},
|
|
{
|
|
Name: "IsOpen",
|
|
SchemaName: "is_open",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockDetails) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockDetails#990a0c0b as nil")
|
|
}
|
|
b.PutID(PageBlockDetailsTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockDetails) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockDetails#990a0c0b as nil")
|
|
}
|
|
if p.Header == nil {
|
|
return fmt.Errorf("unable to encode pageBlockDetails#990a0c0b: field header is nil")
|
|
}
|
|
if err := p.Header.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockDetails#990a0c0b: field header: %w", err)
|
|
}
|
|
b.PutInt(len(p.PageBlocks))
|
|
for idx, v := range p.PageBlocks {
|
|
if v == nil {
|
|
return fmt.Errorf("unable to encode pageBlockDetails#990a0c0b: field page_blocks element with index %d is nil", idx)
|
|
}
|
|
if err := v.EncodeBare(b); err != nil {
|
|
return fmt.Errorf("unable to encode bare pageBlockDetails#990a0c0b: field page_blocks element with index %d: %w", idx, err)
|
|
}
|
|
}
|
|
b.PutBool(p.IsOpen)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockDetails) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockDetails#990a0c0b to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockDetailsTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockDetails#990a0c0b: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockDetails) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockDetails#990a0c0b to nil")
|
|
}
|
|
{
|
|
value, err := DecodeRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockDetails#990a0c0b: field header: %w", err)
|
|
}
|
|
p.Header = value
|
|
}
|
|
{
|
|
headerLen, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockDetails#990a0c0b: field page_blocks: %w", err)
|
|
}
|
|
|
|
if headerLen > 0 {
|
|
p.PageBlocks = make([]PageBlockClass, 0, headerLen%bin.PreallocateLimit)
|
|
}
|
|
for idx := 0; idx < headerLen; idx++ {
|
|
value, err := DecodePageBlock(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockDetails#990a0c0b: field page_blocks: %w", err)
|
|
}
|
|
p.PageBlocks = append(p.PageBlocks, value)
|
|
}
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockDetails#990a0c0b: field is_open: %w", err)
|
|
}
|
|
p.IsOpen = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockDetails) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockDetails#990a0c0b as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockDetails")
|
|
b.Comma()
|
|
b.FieldStart("header")
|
|
if p.Header == nil {
|
|
return fmt.Errorf("unable to encode pageBlockDetails#990a0c0b: field header is nil")
|
|
}
|
|
if err := p.Header.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockDetails#990a0c0b: field header: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("page_blocks")
|
|
b.ArrStart()
|
|
for idx, v := range p.PageBlocks {
|
|
if v == nil {
|
|
return fmt.Errorf("unable to encode pageBlockDetails#990a0c0b: field page_blocks element with index %d is nil", idx)
|
|
}
|
|
if err := v.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockDetails#990a0c0b: field page_blocks element with index %d: %w", idx, err)
|
|
}
|
|
b.Comma()
|
|
}
|
|
b.StripComma()
|
|
b.ArrEnd()
|
|
b.Comma()
|
|
b.FieldStart("is_open")
|
|
b.PutBool(p.IsOpen)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockDetails) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockDetails#990a0c0b to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockDetails"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockDetails#990a0c0b: %w", err)
|
|
}
|
|
case "header":
|
|
value, err := DecodeTDLibJSONRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockDetails#990a0c0b: field header: %w", err)
|
|
}
|
|
p.Header = value
|
|
case "page_blocks":
|
|
if err := b.Arr(func(b tdjson.Decoder) error {
|
|
value, err := DecodeTDLibJSONPageBlock(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockDetails#990a0c0b: field page_blocks: %w", err)
|
|
}
|
|
p.PageBlocks = append(p.PageBlocks, value)
|
|
return nil
|
|
}); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockDetails#990a0c0b: field page_blocks: %w", err)
|
|
}
|
|
case "is_open":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockDetails#990a0c0b: field is_open: %w", err)
|
|
}
|
|
p.IsOpen = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetHeader returns value of Header field.
|
|
func (p *PageBlockDetails) GetHeader() (value RichTextClass) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Header
|
|
}
|
|
|
|
// GetPageBlocks returns value of PageBlocks field.
|
|
func (p *PageBlockDetails) GetPageBlocks() (value []PageBlockClass) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.PageBlocks
|
|
}
|
|
|
|
// GetIsOpen returns value of IsOpen field.
|
|
func (p *PageBlockDetails) GetIsOpen() (value bool) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.IsOpen
|
|
}
|
|
|
|
// PageBlockRelatedArticles represents TL type `pageBlockRelatedArticles#936d81e6`.
|
|
type PageBlockRelatedArticles struct {
|
|
// Block header
|
|
Header RichTextClass
|
|
// List of related articles
|
|
Articles []PageBlockRelatedArticle
|
|
}
|
|
|
|
// PageBlockRelatedArticlesTypeID is TL type id of PageBlockRelatedArticles.
|
|
const PageBlockRelatedArticlesTypeID = 0x936d81e6
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockRelatedArticles) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockRelatedArticles.
|
|
var (
|
|
_ bin.Encoder = &PageBlockRelatedArticles{}
|
|
_ bin.Decoder = &PageBlockRelatedArticles{}
|
|
_ bin.BareEncoder = &PageBlockRelatedArticles{}
|
|
_ bin.BareDecoder = &PageBlockRelatedArticles{}
|
|
|
|
_ PageBlockClass = &PageBlockRelatedArticles{}
|
|
)
|
|
|
|
func (p *PageBlockRelatedArticles) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Header == nil) {
|
|
return false
|
|
}
|
|
if !(p.Articles == nil) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockRelatedArticles) String() string {
|
|
if p == nil {
|
|
return "PageBlockRelatedArticles(nil)"
|
|
}
|
|
type Alias PageBlockRelatedArticles
|
|
return fmt.Sprintf("PageBlockRelatedArticles%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockRelatedArticles) TypeID() uint32 {
|
|
return PageBlockRelatedArticlesTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockRelatedArticles) TypeName() string {
|
|
return "pageBlockRelatedArticles"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockRelatedArticles) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockRelatedArticles",
|
|
ID: PageBlockRelatedArticlesTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Header",
|
|
SchemaName: "header",
|
|
},
|
|
{
|
|
Name: "Articles",
|
|
SchemaName: "articles",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockRelatedArticles) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockRelatedArticles#936d81e6 as nil")
|
|
}
|
|
b.PutID(PageBlockRelatedArticlesTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockRelatedArticles) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockRelatedArticles#936d81e6 as nil")
|
|
}
|
|
if p.Header == nil {
|
|
return fmt.Errorf("unable to encode pageBlockRelatedArticles#936d81e6: field header is nil")
|
|
}
|
|
if err := p.Header.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockRelatedArticles#936d81e6: field header: %w", err)
|
|
}
|
|
b.PutInt(len(p.Articles))
|
|
for idx, v := range p.Articles {
|
|
if err := v.EncodeBare(b); err != nil {
|
|
return fmt.Errorf("unable to encode bare pageBlockRelatedArticles#936d81e6: field articles element with index %d: %w", idx, err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockRelatedArticles) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockRelatedArticles#936d81e6 to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockRelatedArticlesTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockRelatedArticles#936d81e6: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockRelatedArticles) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockRelatedArticles#936d81e6 to nil")
|
|
}
|
|
{
|
|
value, err := DecodeRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockRelatedArticles#936d81e6: field header: %w", err)
|
|
}
|
|
p.Header = value
|
|
}
|
|
{
|
|
headerLen, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockRelatedArticles#936d81e6: field articles: %w", err)
|
|
}
|
|
|
|
if headerLen > 0 {
|
|
p.Articles = make([]PageBlockRelatedArticle, 0, headerLen%bin.PreallocateLimit)
|
|
}
|
|
for idx := 0; idx < headerLen; idx++ {
|
|
var value PageBlockRelatedArticle
|
|
if err := value.DecodeBare(b); err != nil {
|
|
return fmt.Errorf("unable to decode bare pageBlockRelatedArticles#936d81e6: field articles: %w", err)
|
|
}
|
|
p.Articles = append(p.Articles, value)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockRelatedArticles) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockRelatedArticles#936d81e6 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockRelatedArticles")
|
|
b.Comma()
|
|
b.FieldStart("header")
|
|
if p.Header == nil {
|
|
return fmt.Errorf("unable to encode pageBlockRelatedArticles#936d81e6: field header is nil")
|
|
}
|
|
if err := p.Header.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockRelatedArticles#936d81e6: field header: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("articles")
|
|
b.ArrStart()
|
|
for idx, v := range p.Articles {
|
|
if err := v.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockRelatedArticles#936d81e6: field articles element with index %d: %w", idx, err)
|
|
}
|
|
b.Comma()
|
|
}
|
|
b.StripComma()
|
|
b.ArrEnd()
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockRelatedArticles) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockRelatedArticles#936d81e6 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockRelatedArticles"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockRelatedArticles#936d81e6: %w", err)
|
|
}
|
|
case "header":
|
|
value, err := DecodeTDLibJSONRichText(b)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockRelatedArticles#936d81e6: field header: %w", err)
|
|
}
|
|
p.Header = value
|
|
case "articles":
|
|
if err := b.Arr(func(b tdjson.Decoder) error {
|
|
var value PageBlockRelatedArticle
|
|
if err := value.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockRelatedArticles#936d81e6: field articles: %w", err)
|
|
}
|
|
p.Articles = append(p.Articles, value)
|
|
return nil
|
|
}); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockRelatedArticles#936d81e6: field articles: %w", err)
|
|
}
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetHeader returns value of Header field.
|
|
func (p *PageBlockRelatedArticles) GetHeader() (value RichTextClass) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Header
|
|
}
|
|
|
|
// GetArticles returns value of Articles field.
|
|
func (p *PageBlockRelatedArticles) GetArticles() (value []PageBlockRelatedArticle) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Articles
|
|
}
|
|
|
|
// PageBlockMap represents TL type `pageBlockMap#5a0f7013`.
|
|
type PageBlockMap struct {
|
|
// Location of the map center
|
|
Location Location
|
|
// Map zoom level
|
|
Zoom int32
|
|
// Map width
|
|
Width int32
|
|
// Map height
|
|
Height int32
|
|
// Block caption
|
|
Caption PageBlockCaption
|
|
}
|
|
|
|
// PageBlockMapTypeID is TL type id of PageBlockMap.
|
|
const PageBlockMapTypeID = 0x5a0f7013
|
|
|
|
// construct implements constructor of PageBlockClass.
|
|
func (p PageBlockMap) construct() PageBlockClass { return &p }
|
|
|
|
// Ensuring interfaces in compile-time for PageBlockMap.
|
|
var (
|
|
_ bin.Encoder = &PageBlockMap{}
|
|
_ bin.Decoder = &PageBlockMap{}
|
|
_ bin.BareEncoder = &PageBlockMap{}
|
|
_ bin.BareDecoder = &PageBlockMap{}
|
|
|
|
_ PageBlockClass = &PageBlockMap{}
|
|
)
|
|
|
|
func (p *PageBlockMap) Zero() bool {
|
|
if p == nil {
|
|
return true
|
|
}
|
|
if !(p.Location.Zero()) {
|
|
return false
|
|
}
|
|
if !(p.Zoom == 0) {
|
|
return false
|
|
}
|
|
if !(p.Width == 0) {
|
|
return false
|
|
}
|
|
if !(p.Height == 0) {
|
|
return false
|
|
}
|
|
if !(p.Caption.Zero()) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (p *PageBlockMap) String() string {
|
|
if p == nil {
|
|
return "PageBlockMap(nil)"
|
|
}
|
|
type Alias PageBlockMap
|
|
return fmt.Sprintf("PageBlockMap%+v", Alias(*p))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*PageBlockMap) TypeID() uint32 {
|
|
return PageBlockMapTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*PageBlockMap) TypeName() string {
|
|
return "pageBlockMap"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (p *PageBlockMap) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "pageBlockMap",
|
|
ID: PageBlockMapTypeID,
|
|
}
|
|
if p == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Location",
|
|
SchemaName: "location",
|
|
},
|
|
{
|
|
Name: "Zoom",
|
|
SchemaName: "zoom",
|
|
},
|
|
{
|
|
Name: "Width",
|
|
SchemaName: "width",
|
|
},
|
|
{
|
|
Name: "Height",
|
|
SchemaName: "height",
|
|
},
|
|
{
|
|
Name: "Caption",
|
|
SchemaName: "caption",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (p *PageBlockMap) Encode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockMap#5a0f7013 as nil")
|
|
}
|
|
b.PutID(PageBlockMapTypeID)
|
|
return p.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (p *PageBlockMap) EncodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockMap#5a0f7013 as nil")
|
|
}
|
|
if err := p.Location.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockMap#5a0f7013: field location: %w", err)
|
|
}
|
|
b.PutInt32(p.Zoom)
|
|
b.PutInt32(p.Width)
|
|
b.PutInt32(p.Height)
|
|
if err := p.Caption.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockMap#5a0f7013: field caption: %w", err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (p *PageBlockMap) Decode(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockMap#5a0f7013 to nil")
|
|
}
|
|
if err := b.ConsumeID(PageBlockMapTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockMap#5a0f7013: %w", err)
|
|
}
|
|
return p.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (p *PageBlockMap) DecodeBare(b *bin.Buffer) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockMap#5a0f7013 to nil")
|
|
}
|
|
{
|
|
if err := p.Location.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockMap#5a0f7013: field location: %w", err)
|
|
}
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockMap#5a0f7013: field zoom: %w", err)
|
|
}
|
|
p.Zoom = value
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockMap#5a0f7013: field width: %w", err)
|
|
}
|
|
p.Width = value
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockMap#5a0f7013: field height: %w", err)
|
|
}
|
|
p.Height = value
|
|
}
|
|
{
|
|
if err := p.Caption.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockMap#5a0f7013: field caption: %w", err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (p *PageBlockMap) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't encode pageBlockMap#5a0f7013 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("pageBlockMap")
|
|
b.Comma()
|
|
b.FieldStart("location")
|
|
if err := p.Location.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockMap#5a0f7013: field location: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("zoom")
|
|
b.PutInt32(p.Zoom)
|
|
b.Comma()
|
|
b.FieldStart("width")
|
|
b.PutInt32(p.Width)
|
|
b.Comma()
|
|
b.FieldStart("height")
|
|
b.PutInt32(p.Height)
|
|
b.Comma()
|
|
b.FieldStart("caption")
|
|
if err := p.Caption.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode pageBlockMap#5a0f7013: field caption: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (p *PageBlockMap) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if p == nil {
|
|
return fmt.Errorf("can't decode pageBlockMap#5a0f7013 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("pageBlockMap"); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockMap#5a0f7013: %w", err)
|
|
}
|
|
case "location":
|
|
if err := p.Location.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockMap#5a0f7013: field location: %w", err)
|
|
}
|
|
case "zoom":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockMap#5a0f7013: field zoom: %w", err)
|
|
}
|
|
p.Zoom = value
|
|
case "width":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockMap#5a0f7013: field width: %w", err)
|
|
}
|
|
p.Width = value
|
|
case "height":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockMap#5a0f7013: field height: %w", err)
|
|
}
|
|
p.Height = value
|
|
case "caption":
|
|
if err := p.Caption.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode pageBlockMap#5a0f7013: field caption: %w", err)
|
|
}
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetLocation returns value of Location field.
|
|
func (p *PageBlockMap) GetLocation() (value Location) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Location
|
|
}
|
|
|
|
// GetZoom returns value of Zoom field.
|
|
func (p *PageBlockMap) GetZoom() (value int32) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Zoom
|
|
}
|
|
|
|
// GetWidth returns value of Width field.
|
|
func (p *PageBlockMap) GetWidth() (value int32) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Width
|
|
}
|
|
|
|
// GetHeight returns value of Height field.
|
|
func (p *PageBlockMap) GetHeight() (value int32) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Height
|
|
}
|
|
|
|
// GetCaption returns value of Caption field.
|
|
func (p *PageBlockMap) GetCaption() (value PageBlockCaption) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
return p.Caption
|
|
}
|
|
|
|
// PageBlockClassName is schema name of PageBlockClass.
|
|
const PageBlockClassName = "PageBlock"
|
|
|
|
// PageBlockClass represents PageBlock generic type.
|
|
//
|
|
// Example:
|
|
//
|
|
// g, err := tdapi.DecodePageBlock(buf)
|
|
// if err != nil {
|
|
// panic(err)
|
|
// }
|
|
// switch v := g.(type) {
|
|
// case *tdapi.PageBlockTitle: // pageBlockTitle#6122b610
|
|
// case *tdapi.PageBlockSubtitle: // pageBlockSubtitle#fc451e7
|
|
// case *tdapi.PageBlockAuthorDate: // pageBlockAuthorDate#4d7ff410
|
|
// case *tdapi.PageBlockHeader: // pageBlockHeader#539ddd9b
|
|
// case *tdapi.PageBlockSubheader: // pageBlockSubheader#4b567326
|
|
// case *tdapi.PageBlockKicker: // pageBlockKicker#5123864b
|
|
// case *tdapi.PageBlockParagraph: // pageBlockParagraph#467a0766
|
|
// case *tdapi.PageBlockPreformatted: // pageBlockPreformatted#c070d93e
|
|
// case *tdapi.PageBlockFooter: // pageBlockFooter#34d5d728
|
|
// case *tdapi.PageBlockDivider: // pageBlockDivider#db20b188
|
|
// case *tdapi.PageBlockAnchor: // pageBlockAnchor#ce0d37b0
|
|
// case *tdapi.PageBlockList: // pageBlockList#584af35a
|
|
// case *tdapi.PageBlockBlockQuote: // pageBlockBlockQuote#62d08a9e
|
|
// case *tdapi.PageBlockPullQuote: // pageBlockPullQuote#1d38810d
|
|
// case *tdapi.PageBlockAnimation: // pageBlockAnimation#50cde009
|
|
// case *tdapi.PageBlockAudio: // pageBlockAudio#fc390813
|
|
// case *tdapi.PageBlockPhoto: // pageBlockPhoto#18e41684
|
|
// case *tdapi.PageBlockVideo: // pageBlockVideo#1e669d32
|
|
// case *tdapi.PageBlockVoiceNote: // pageBlockVoiceNote#6cad827f
|
|
// case *tdapi.PageBlockCover: // pageBlockCover#39f23300
|
|
// case *tdapi.PageBlockEmbedded: // pageBlockEmbedded#8c369d9d
|
|
// case *tdapi.PageBlockEmbeddedPost: // pageBlockEmbeddedPost#bc57cdf5
|
|
// case *tdapi.PageBlockCollage: // pageBlockCollage#40bcaaf0
|
|
// case *tdapi.PageBlockSlideshow: // pageBlockSlideshow#1107d496
|
|
// case *tdapi.PageBlockChatLink: // pageBlockChatLink#621ed8bb
|
|
// case *tdapi.PageBlockTable: // pageBlockTable#cc6352c3
|
|
// case *tdapi.PageBlockDetails: // pageBlockDetails#990a0c0b
|
|
// case *tdapi.PageBlockRelatedArticles: // pageBlockRelatedArticles#936d81e6
|
|
// case *tdapi.PageBlockMap: // pageBlockMap#5a0f7013
|
|
// default: panic(v)
|
|
// }
|
|
type PageBlockClass interface {
|
|
bin.Encoder
|
|
bin.Decoder
|
|
bin.BareEncoder
|
|
bin.BareDecoder
|
|
construct() PageBlockClass
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
TypeID() uint32
|
|
// TypeName returns name of type in TL schema.
|
|
TypeName() string
|
|
// String implements fmt.Stringer.
|
|
String() string
|
|
// Zero returns true if current object has a zero value.
|
|
Zero() bool
|
|
|
|
EncodeTDLibJSON(b tdjson.Encoder) error
|
|
DecodeTDLibJSON(b tdjson.Decoder) error
|
|
}
|
|
|
|
// DecodePageBlock implements binary de-serialization for PageBlockClass.
|
|
func DecodePageBlock(buf *bin.Buffer) (PageBlockClass, error) {
|
|
id, err := buf.PeekID()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
switch id {
|
|
case PageBlockTitleTypeID:
|
|
// Decoding pageBlockTitle#6122b610.
|
|
v := PageBlockTitle{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockSubtitleTypeID:
|
|
// Decoding pageBlockSubtitle#fc451e7.
|
|
v := PageBlockSubtitle{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockAuthorDateTypeID:
|
|
// Decoding pageBlockAuthorDate#4d7ff410.
|
|
v := PageBlockAuthorDate{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockHeaderTypeID:
|
|
// Decoding pageBlockHeader#539ddd9b.
|
|
v := PageBlockHeader{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockSubheaderTypeID:
|
|
// Decoding pageBlockSubheader#4b567326.
|
|
v := PageBlockSubheader{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockKickerTypeID:
|
|
// Decoding pageBlockKicker#5123864b.
|
|
v := PageBlockKicker{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockParagraphTypeID:
|
|
// Decoding pageBlockParagraph#467a0766.
|
|
v := PageBlockParagraph{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockPreformattedTypeID:
|
|
// Decoding pageBlockPreformatted#c070d93e.
|
|
v := PageBlockPreformatted{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockFooterTypeID:
|
|
// Decoding pageBlockFooter#34d5d728.
|
|
v := PageBlockFooter{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockDividerTypeID:
|
|
// Decoding pageBlockDivider#db20b188.
|
|
v := PageBlockDivider{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockAnchorTypeID:
|
|
// Decoding pageBlockAnchor#ce0d37b0.
|
|
v := PageBlockAnchor{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockListTypeID:
|
|
// Decoding pageBlockList#584af35a.
|
|
v := PageBlockList{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockBlockQuoteTypeID:
|
|
// Decoding pageBlockBlockQuote#62d08a9e.
|
|
v := PageBlockBlockQuote{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockPullQuoteTypeID:
|
|
// Decoding pageBlockPullQuote#1d38810d.
|
|
v := PageBlockPullQuote{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockAnimationTypeID:
|
|
// Decoding pageBlockAnimation#50cde009.
|
|
v := PageBlockAnimation{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockAudioTypeID:
|
|
// Decoding pageBlockAudio#fc390813.
|
|
v := PageBlockAudio{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockPhotoTypeID:
|
|
// Decoding pageBlockPhoto#18e41684.
|
|
v := PageBlockPhoto{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockVideoTypeID:
|
|
// Decoding pageBlockVideo#1e669d32.
|
|
v := PageBlockVideo{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockVoiceNoteTypeID:
|
|
// Decoding pageBlockVoiceNote#6cad827f.
|
|
v := PageBlockVoiceNote{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockCoverTypeID:
|
|
// Decoding pageBlockCover#39f23300.
|
|
v := PageBlockCover{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockEmbeddedTypeID:
|
|
// Decoding pageBlockEmbedded#8c369d9d.
|
|
v := PageBlockEmbedded{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockEmbeddedPostTypeID:
|
|
// Decoding pageBlockEmbeddedPost#bc57cdf5.
|
|
v := PageBlockEmbeddedPost{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockCollageTypeID:
|
|
// Decoding pageBlockCollage#40bcaaf0.
|
|
v := PageBlockCollage{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockSlideshowTypeID:
|
|
// Decoding pageBlockSlideshow#1107d496.
|
|
v := PageBlockSlideshow{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockChatLinkTypeID:
|
|
// Decoding pageBlockChatLink#621ed8bb.
|
|
v := PageBlockChatLink{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockTableTypeID:
|
|
// Decoding pageBlockTable#cc6352c3.
|
|
v := PageBlockTable{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockDetailsTypeID:
|
|
// Decoding pageBlockDetails#990a0c0b.
|
|
v := PageBlockDetails{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockRelatedArticlesTypeID:
|
|
// Decoding pageBlockRelatedArticles#936d81e6.
|
|
v := PageBlockRelatedArticles{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case PageBlockMapTypeID:
|
|
// Decoding pageBlockMap#5a0f7013.
|
|
v := PageBlockMap{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
default:
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", bin.NewUnexpectedID(id))
|
|
}
|
|
}
|
|
|
|
// DecodeTDLibJSONPageBlock implements binary de-serialization for PageBlockClass.
|
|
func DecodeTDLibJSONPageBlock(buf tdjson.Decoder) (PageBlockClass, error) {
|
|
id, err := buf.FindTypeID()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
switch id {
|
|
case "pageBlockTitle":
|
|
// Decoding pageBlockTitle#6122b610.
|
|
v := PageBlockTitle{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockSubtitle":
|
|
// Decoding pageBlockSubtitle#fc451e7.
|
|
v := PageBlockSubtitle{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockAuthorDate":
|
|
// Decoding pageBlockAuthorDate#4d7ff410.
|
|
v := PageBlockAuthorDate{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockHeader":
|
|
// Decoding pageBlockHeader#539ddd9b.
|
|
v := PageBlockHeader{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockSubheader":
|
|
// Decoding pageBlockSubheader#4b567326.
|
|
v := PageBlockSubheader{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockKicker":
|
|
// Decoding pageBlockKicker#5123864b.
|
|
v := PageBlockKicker{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockParagraph":
|
|
// Decoding pageBlockParagraph#467a0766.
|
|
v := PageBlockParagraph{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockPreformatted":
|
|
// Decoding pageBlockPreformatted#c070d93e.
|
|
v := PageBlockPreformatted{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockFooter":
|
|
// Decoding pageBlockFooter#34d5d728.
|
|
v := PageBlockFooter{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockDivider":
|
|
// Decoding pageBlockDivider#db20b188.
|
|
v := PageBlockDivider{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockAnchor":
|
|
// Decoding pageBlockAnchor#ce0d37b0.
|
|
v := PageBlockAnchor{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockList":
|
|
// Decoding pageBlockList#584af35a.
|
|
v := PageBlockList{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockBlockQuote":
|
|
// Decoding pageBlockBlockQuote#62d08a9e.
|
|
v := PageBlockBlockQuote{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockPullQuote":
|
|
// Decoding pageBlockPullQuote#1d38810d.
|
|
v := PageBlockPullQuote{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockAnimation":
|
|
// Decoding pageBlockAnimation#50cde009.
|
|
v := PageBlockAnimation{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockAudio":
|
|
// Decoding pageBlockAudio#fc390813.
|
|
v := PageBlockAudio{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockPhoto":
|
|
// Decoding pageBlockPhoto#18e41684.
|
|
v := PageBlockPhoto{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockVideo":
|
|
// Decoding pageBlockVideo#1e669d32.
|
|
v := PageBlockVideo{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockVoiceNote":
|
|
// Decoding pageBlockVoiceNote#6cad827f.
|
|
v := PageBlockVoiceNote{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockCover":
|
|
// Decoding pageBlockCover#39f23300.
|
|
v := PageBlockCover{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockEmbedded":
|
|
// Decoding pageBlockEmbedded#8c369d9d.
|
|
v := PageBlockEmbedded{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockEmbeddedPost":
|
|
// Decoding pageBlockEmbeddedPost#bc57cdf5.
|
|
v := PageBlockEmbeddedPost{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockCollage":
|
|
// Decoding pageBlockCollage#40bcaaf0.
|
|
v := PageBlockCollage{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockSlideshow":
|
|
// Decoding pageBlockSlideshow#1107d496.
|
|
v := PageBlockSlideshow{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockChatLink":
|
|
// Decoding pageBlockChatLink#621ed8bb.
|
|
v := PageBlockChatLink{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockTable":
|
|
// Decoding pageBlockTable#cc6352c3.
|
|
v := PageBlockTable{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockDetails":
|
|
// Decoding pageBlockDetails#990a0c0b.
|
|
v := PageBlockDetails{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockRelatedArticles":
|
|
// Decoding pageBlockRelatedArticles#936d81e6.
|
|
v := PageBlockRelatedArticles{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "pageBlockMap":
|
|
// Decoding pageBlockMap#5a0f7013.
|
|
v := PageBlockMap{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
default:
|
|
return nil, fmt.Errorf("unable to decode PageBlockClass: %w", tdjson.NewUnexpectedID(id))
|
|
}
|
|
}
|
|
|
|
// PageBlock boxes the PageBlockClass providing a helper.
|
|
type PageBlockBox struct {
|
|
PageBlock PageBlockClass
|
|
}
|
|
|
|
// Decode implements bin.Decoder for PageBlockBox.
|
|
func (b *PageBlockBox) Decode(buf *bin.Buffer) error {
|
|
if b == nil {
|
|
return fmt.Errorf("unable to decode PageBlockBox to nil")
|
|
}
|
|
v, err := DecodePageBlock(buf)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode boxed value: %w", err)
|
|
}
|
|
b.PageBlock = v
|
|
return nil
|
|
}
|
|
|
|
// Encode implements bin.Encode for PageBlockBox.
|
|
func (b *PageBlockBox) Encode(buf *bin.Buffer) error {
|
|
if b == nil || b.PageBlock == nil {
|
|
return fmt.Errorf("unable to encode PageBlockClass as nil")
|
|
}
|
|
return b.PageBlock.Encode(buf)
|
|
}
|
|
|
|
// DecodeTDLibJSON implements bin.Decoder for PageBlockBox.
|
|
func (b *PageBlockBox) DecodeTDLibJSON(buf tdjson.Decoder) error {
|
|
if b == nil {
|
|
return fmt.Errorf("unable to decode PageBlockBox to nil")
|
|
}
|
|
v, err := DecodeTDLibJSONPageBlock(buf)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode boxed value: %w", err)
|
|
}
|
|
b.PageBlock = v
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements bin.Encode for PageBlockBox.
|
|
func (b *PageBlockBox) EncodeTDLibJSON(buf tdjson.Encoder) error {
|
|
if b == nil || b.PageBlock == nil {
|
|
return fmt.Errorf("unable to encode PageBlockClass as nil")
|
|
}
|
|
return b.PageBlock.EncodeTDLibJSON(buf)
|
|
}
|