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