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,284 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// BusinessIntro represents TL type `businessIntro#5a0a066d`.
|
||||
// Telegram Business introduction »¹.
|
||||
//
|
||||
// Links:
|
||||
// 1. https://core.telegram.org/api/business#business-introduction
|
||||
//
|
||||
// See https://core.telegram.org/constructor/businessIntro for reference.
|
||||
type BusinessIntro struct {
|
||||
// Flags, see TL conditional fields¹
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
|
||||
Flags bin.Fields
|
||||
// Title of the introduction message (max intro_title_length_limit »¹ UTF-8 characters).
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/api/config#intro-title-length-limit
|
||||
Title string
|
||||
// Profile introduction (max intro_description_length_limit »¹ UTF-8 characters).
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/api/config#intro-description-length-limit
|
||||
Description string
|
||||
// Optional introduction sticker¹.
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/api/stickers
|
||||
//
|
||||
// Use SetSticker and GetSticker helpers.
|
||||
Sticker DocumentClass
|
||||
}
|
||||
|
||||
// BusinessIntroTypeID is TL type id of BusinessIntro.
|
||||
const BusinessIntroTypeID = 0x5a0a066d
|
||||
|
||||
// Ensuring interfaces in compile-time for BusinessIntro.
|
||||
var (
|
||||
_ bin.Encoder = &BusinessIntro{}
|
||||
_ bin.Decoder = &BusinessIntro{}
|
||||
_ bin.BareEncoder = &BusinessIntro{}
|
||||
_ bin.BareDecoder = &BusinessIntro{}
|
||||
)
|
||||
|
||||
func (b *BusinessIntro) Zero() bool {
|
||||
if b == nil {
|
||||
return true
|
||||
}
|
||||
if !(b.Flags.Zero()) {
|
||||
return false
|
||||
}
|
||||
if !(b.Title == "") {
|
||||
return false
|
||||
}
|
||||
if !(b.Description == "") {
|
||||
return false
|
||||
}
|
||||
if !(b.Sticker == nil) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (b *BusinessIntro) String() string {
|
||||
if b == nil {
|
||||
return "BusinessIntro(nil)"
|
||||
}
|
||||
type Alias BusinessIntro
|
||||
return fmt.Sprintf("BusinessIntro%+v", Alias(*b))
|
||||
}
|
||||
|
||||
// FillFrom fills BusinessIntro from given interface.
|
||||
func (b *BusinessIntro) FillFrom(from interface {
|
||||
GetTitle() (value string)
|
||||
GetDescription() (value string)
|
||||
GetSticker() (value DocumentClass, ok bool)
|
||||
}) {
|
||||
b.Title = from.GetTitle()
|
||||
b.Description = from.GetDescription()
|
||||
if val, ok := from.GetSticker(); ok {
|
||||
b.Sticker = val
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*BusinessIntro) TypeID() uint32 {
|
||||
return BusinessIntroTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*BusinessIntro) TypeName() string {
|
||||
return "businessIntro"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (b *BusinessIntro) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "businessIntro",
|
||||
ID: BusinessIntroTypeID,
|
||||
}
|
||||
if b == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Title",
|
||||
SchemaName: "title",
|
||||
},
|
||||
{
|
||||
Name: "Description",
|
||||
SchemaName: "description",
|
||||
},
|
||||
{
|
||||
Name: "Sticker",
|
||||
SchemaName: "sticker",
|
||||
Null: !b.Flags.Has(0),
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// SetFlags sets flags for non-zero fields.
|
||||
func (b *BusinessIntro) SetFlags() {
|
||||
if !(b.Sticker == nil) {
|
||||
b.Flags.Set(0)
|
||||
}
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (b *BusinessIntro) Encode(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("can't encode businessIntro#5a0a066d as nil")
|
||||
}
|
||||
buf.PutID(BusinessIntroTypeID)
|
||||
return b.EncodeBare(buf)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (b *BusinessIntro) EncodeBare(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("can't encode businessIntro#5a0a066d as nil")
|
||||
}
|
||||
b.SetFlags()
|
||||
if err := b.Flags.Encode(buf); err != nil {
|
||||
return fmt.Errorf("unable to encode businessIntro#5a0a066d: field flags: %w", err)
|
||||
}
|
||||
buf.PutString(b.Title)
|
||||
buf.PutString(b.Description)
|
||||
if b.Flags.Has(0) {
|
||||
if b.Sticker == nil {
|
||||
return fmt.Errorf("unable to encode businessIntro#5a0a066d: field sticker is nil")
|
||||
}
|
||||
if err := b.Sticker.Encode(buf); err != nil {
|
||||
return fmt.Errorf("unable to encode businessIntro#5a0a066d: field sticker: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (b *BusinessIntro) Decode(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("can't decode businessIntro#5a0a066d to nil")
|
||||
}
|
||||
if err := buf.ConsumeID(BusinessIntroTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode businessIntro#5a0a066d: %w", err)
|
||||
}
|
||||
return b.DecodeBare(buf)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (b *BusinessIntro) DecodeBare(buf *bin.Buffer) error {
|
||||
if b == nil {
|
||||
return fmt.Errorf("can't decode businessIntro#5a0a066d to nil")
|
||||
}
|
||||
{
|
||||
if err := b.Flags.Decode(buf); err != nil {
|
||||
return fmt.Errorf("unable to decode businessIntro#5a0a066d: field flags: %w", err)
|
||||
}
|
||||
}
|
||||
{
|
||||
value, err := buf.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode businessIntro#5a0a066d: field title: %w", err)
|
||||
}
|
||||
b.Title = value
|
||||
}
|
||||
{
|
||||
value, err := buf.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode businessIntro#5a0a066d: field description: %w", err)
|
||||
}
|
||||
b.Description = value
|
||||
}
|
||||
if b.Flags.Has(0) {
|
||||
value, err := DecodeDocument(buf)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode businessIntro#5a0a066d: field sticker: %w", err)
|
||||
}
|
||||
b.Sticker = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetTitle returns value of Title field.
|
||||
func (b *BusinessIntro) GetTitle() (value string) {
|
||||
if b == nil {
|
||||
return
|
||||
}
|
||||
return b.Title
|
||||
}
|
||||
|
||||
// GetDescription returns value of Description field.
|
||||
func (b *BusinessIntro) GetDescription() (value string) {
|
||||
if b == nil {
|
||||
return
|
||||
}
|
||||
return b.Description
|
||||
}
|
||||
|
||||
// SetSticker sets value of Sticker conditional field.
|
||||
func (b *BusinessIntro) SetSticker(value DocumentClass) {
|
||||
b.Flags.Set(0)
|
||||
b.Sticker = value
|
||||
}
|
||||
|
||||
// GetSticker returns value of Sticker conditional field and
|
||||
// boolean which is true if field was set.
|
||||
func (b *BusinessIntro) GetSticker() (value DocumentClass, ok bool) {
|
||||
if b == nil {
|
||||
return
|
||||
}
|
||||
if !b.Flags.Has(0) {
|
||||
return value, false
|
||||
}
|
||||
return b.Sticker, true
|
||||
}
|
||||
|
||||
// GetStickerAsNotEmpty returns mapped value of Sticker conditional field and
|
||||
// boolean which is true if field was set.
|
||||
func (b *BusinessIntro) GetStickerAsNotEmpty() (*Document, bool) {
|
||||
if value, ok := b.GetSticker(); ok {
|
||||
return value.AsNotEmpty()
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
Reference in New Issue
Block a user