move gotd fork into repo. (#111)
- 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
This commit is contained in:
@@ -0,0 +1,199 @@
|
||||
// Code generated by gotdgen, DO NOT EDIT.
|
||||
|
||||
package tg
|
||||
|
||||
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{}
|
||||
)
|
||||
|
||||
// PageCaption represents TL type `pageCaption#6f747657`.
|
||||
// Page caption
|
||||
//
|
||||
// See https://core.telegram.org/constructor/pageCaption for reference.
|
||||
type PageCaption struct {
|
||||
// Caption
|
||||
Text RichTextClass
|
||||
// Credits
|
||||
Credit RichTextClass
|
||||
}
|
||||
|
||||
// PageCaptionTypeID is TL type id of PageCaption.
|
||||
const PageCaptionTypeID = 0x6f747657
|
||||
|
||||
// Ensuring interfaces in compile-time for PageCaption.
|
||||
var (
|
||||
_ bin.Encoder = &PageCaption{}
|
||||
_ bin.Decoder = &PageCaption{}
|
||||
_ bin.BareEncoder = &PageCaption{}
|
||||
_ bin.BareDecoder = &PageCaption{}
|
||||
)
|
||||
|
||||
func (p *PageCaption) 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 *PageCaption) String() string {
|
||||
if p == nil {
|
||||
return "PageCaption(nil)"
|
||||
}
|
||||
type Alias PageCaption
|
||||
return fmt.Sprintf("PageCaption%+v", Alias(*p))
|
||||
}
|
||||
|
||||
// FillFrom fills PageCaption from given interface.
|
||||
func (p *PageCaption) FillFrom(from interface {
|
||||
GetText() (value RichTextClass)
|
||||
GetCredit() (value RichTextClass)
|
||||
}) {
|
||||
p.Text = from.GetText()
|
||||
p.Credit = from.GetCredit()
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*PageCaption) TypeID() uint32 {
|
||||
return PageCaptionTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*PageCaption) TypeName() string {
|
||||
return "pageCaption"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (p *PageCaption) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "pageCaption",
|
||||
ID: PageCaptionTypeID,
|
||||
}
|
||||
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 *PageCaption) Encode(b *bin.Buffer) error {
|
||||
if p == nil {
|
||||
return fmt.Errorf("can't encode pageCaption#6f747657 as nil")
|
||||
}
|
||||
b.PutID(PageCaptionTypeID)
|
||||
return p.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (p *PageCaption) EncodeBare(b *bin.Buffer) error {
|
||||
if p == nil {
|
||||
return fmt.Errorf("can't encode pageCaption#6f747657 as nil")
|
||||
}
|
||||
if p.Text == nil {
|
||||
return fmt.Errorf("unable to encode pageCaption#6f747657: field text is nil")
|
||||
}
|
||||
if err := p.Text.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode pageCaption#6f747657: field text: %w", err)
|
||||
}
|
||||
if p.Credit == nil {
|
||||
return fmt.Errorf("unable to encode pageCaption#6f747657: field credit is nil")
|
||||
}
|
||||
if err := p.Credit.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode pageCaption#6f747657: field credit: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (p *PageCaption) Decode(b *bin.Buffer) error {
|
||||
if p == nil {
|
||||
return fmt.Errorf("can't decode pageCaption#6f747657 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(PageCaptionTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode pageCaption#6f747657: %w", err)
|
||||
}
|
||||
return p.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (p *PageCaption) DecodeBare(b *bin.Buffer) error {
|
||||
if p == nil {
|
||||
return fmt.Errorf("can't decode pageCaption#6f747657 to nil")
|
||||
}
|
||||
{
|
||||
value, err := DecodeRichText(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode pageCaption#6f747657: field text: %w", err)
|
||||
}
|
||||
p.Text = value
|
||||
}
|
||||
{
|
||||
value, err := DecodeRichText(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode pageCaption#6f747657: field credit: %w", err)
|
||||
}
|
||||
p.Credit = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetText returns value of Text field.
|
||||
func (p *PageCaption) GetText() (value RichTextClass) {
|
||||
if p == nil {
|
||||
return
|
||||
}
|
||||
return p.Text
|
||||
}
|
||||
|
||||
// GetCredit returns value of Credit field.
|
||||
func (p *PageCaption) GetCredit() (value RichTextClass) {
|
||||
if p == nil {
|
||||
return
|
||||
}
|
||||
return p.Credit
|
||||
}
|
||||
Reference in New Issue
Block a user