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,228 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// GiftSettings represents TL type `giftSettings#2ba9880`.
|
||||
type GiftSettings struct {
|
||||
// True, if a button for sending a gift to the user or by the user must always be shown
|
||||
// in the input field
|
||||
ShowGiftButton bool
|
||||
// Types of gifts accepted by the user; for Telegram Premium users only
|
||||
AcceptedGiftTypes AcceptedGiftTypes
|
||||
}
|
||||
|
||||
// GiftSettingsTypeID is TL type id of GiftSettings.
|
||||
const GiftSettingsTypeID = 0x2ba9880
|
||||
|
||||
// Ensuring interfaces in compile-time for GiftSettings.
|
||||
var (
|
||||
_ bin.Encoder = &GiftSettings{}
|
||||
_ bin.Decoder = &GiftSettings{}
|
||||
_ bin.BareEncoder = &GiftSettings{}
|
||||
_ bin.BareDecoder = &GiftSettings{}
|
||||
)
|
||||
|
||||
func (g *GiftSettings) Zero() bool {
|
||||
if g == nil {
|
||||
return true
|
||||
}
|
||||
if !(g.ShowGiftButton == false) {
|
||||
return false
|
||||
}
|
||||
if !(g.AcceptedGiftTypes.Zero()) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (g *GiftSettings) String() string {
|
||||
if g == nil {
|
||||
return "GiftSettings(nil)"
|
||||
}
|
||||
type Alias GiftSettings
|
||||
return fmt.Sprintf("GiftSettings%+v", Alias(*g))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*GiftSettings) TypeID() uint32 {
|
||||
return GiftSettingsTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*GiftSettings) TypeName() string {
|
||||
return "giftSettings"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (g *GiftSettings) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "giftSettings",
|
||||
ID: GiftSettingsTypeID,
|
||||
}
|
||||
if g == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "ShowGiftButton",
|
||||
SchemaName: "show_gift_button",
|
||||
},
|
||||
{
|
||||
Name: "AcceptedGiftTypes",
|
||||
SchemaName: "accepted_gift_types",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (g *GiftSettings) Encode(b *bin.Buffer) error {
|
||||
if g == nil {
|
||||
return fmt.Errorf("can't encode giftSettings#2ba9880 as nil")
|
||||
}
|
||||
b.PutID(GiftSettingsTypeID)
|
||||
return g.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (g *GiftSettings) EncodeBare(b *bin.Buffer) error {
|
||||
if g == nil {
|
||||
return fmt.Errorf("can't encode giftSettings#2ba9880 as nil")
|
||||
}
|
||||
b.PutBool(g.ShowGiftButton)
|
||||
if err := g.AcceptedGiftTypes.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode giftSettings#2ba9880: field accepted_gift_types: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (g *GiftSettings) Decode(b *bin.Buffer) error {
|
||||
if g == nil {
|
||||
return fmt.Errorf("can't decode giftSettings#2ba9880 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(GiftSettingsTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode giftSettings#2ba9880: %w", err)
|
||||
}
|
||||
return g.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (g *GiftSettings) DecodeBare(b *bin.Buffer) error {
|
||||
if g == nil {
|
||||
return fmt.Errorf("can't decode giftSettings#2ba9880 to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.Bool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode giftSettings#2ba9880: field show_gift_button: %w", err)
|
||||
}
|
||||
g.ShowGiftButton = value
|
||||
}
|
||||
{
|
||||
if err := g.AcceptedGiftTypes.Decode(b); err != nil {
|
||||
return fmt.Errorf("unable to decode giftSettings#2ba9880: field accepted_gift_types: %w", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
||||
func (g *GiftSettings) EncodeTDLibJSON(b tdjson.Encoder) error {
|
||||
if g == nil {
|
||||
return fmt.Errorf("can't encode giftSettings#2ba9880 as nil")
|
||||
}
|
||||
b.ObjStart()
|
||||
b.PutID("giftSettings")
|
||||
b.Comma()
|
||||
b.FieldStart("show_gift_button")
|
||||
b.PutBool(g.ShowGiftButton)
|
||||
b.Comma()
|
||||
b.FieldStart("accepted_gift_types")
|
||||
if err := g.AcceptedGiftTypes.EncodeTDLibJSON(b); err != nil {
|
||||
return fmt.Errorf("unable to encode giftSettings#2ba9880: field accepted_gift_types: %w", err)
|
||||
}
|
||||
b.Comma()
|
||||
b.StripComma()
|
||||
b.ObjEnd()
|
||||
return nil
|
||||
}
|
||||
|
||||
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
||||
func (g *GiftSettings) DecodeTDLibJSON(b tdjson.Decoder) error {
|
||||
if g == nil {
|
||||
return fmt.Errorf("can't decode giftSettings#2ba9880 to nil")
|
||||
}
|
||||
|
||||
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
||||
switch string(key) {
|
||||
case tdjson.TypeField:
|
||||
if err := b.ConsumeID("giftSettings"); err != nil {
|
||||
return fmt.Errorf("unable to decode giftSettings#2ba9880: %w", err)
|
||||
}
|
||||
case "show_gift_button":
|
||||
value, err := b.Bool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode giftSettings#2ba9880: field show_gift_button: %w", err)
|
||||
}
|
||||
g.ShowGiftButton = value
|
||||
case "accepted_gift_types":
|
||||
if err := g.AcceptedGiftTypes.DecodeTDLibJSON(b); err != nil {
|
||||
return fmt.Errorf("unable to decode giftSettings#2ba9880: field accepted_gift_types: %w", err)
|
||||
}
|
||||
default:
|
||||
return b.Skip()
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// GetShowGiftButton returns value of ShowGiftButton field.
|
||||
func (g *GiftSettings) GetShowGiftButton() (value bool) {
|
||||
if g == nil {
|
||||
return
|
||||
}
|
||||
return g.ShowGiftButton
|
||||
}
|
||||
|
||||
// GetAcceptedGiftTypes returns value of AcceptedGiftTypes field.
|
||||
func (g *GiftSettings) GetAcceptedGiftTypes() (value AcceptedGiftTypes) {
|
||||
if g == nil {
|
||||
return
|
||||
}
|
||||
return g.AcceptedGiftTypes
|
||||
}
|
||||
Reference in New Issue
Block a user