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
860 lines
22 KiB
Go
860 lines
22 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{}
|
|
)
|
|
|
|
// ChatBoostSourceGiftCode represents TL type `chatBoostSourceGiftCode#fa2412ba`.
|
|
type ChatBoostSourceGiftCode struct {
|
|
// Identifier of a user, for which the gift code was created
|
|
UserID int64
|
|
// The created Telegram Premium gift code, which is known only if this is a gift code for
|
|
// the current user, or it has already been claimed
|
|
GiftCode string
|
|
}
|
|
|
|
// ChatBoostSourceGiftCodeTypeID is TL type id of ChatBoostSourceGiftCode.
|
|
const ChatBoostSourceGiftCodeTypeID = 0xfa2412ba
|
|
|
|
// construct implements constructor of ChatBoostSourceClass.
|
|
func (c ChatBoostSourceGiftCode) construct() ChatBoostSourceClass { return &c }
|
|
|
|
// Ensuring interfaces in compile-time for ChatBoostSourceGiftCode.
|
|
var (
|
|
_ bin.Encoder = &ChatBoostSourceGiftCode{}
|
|
_ bin.Decoder = &ChatBoostSourceGiftCode{}
|
|
_ bin.BareEncoder = &ChatBoostSourceGiftCode{}
|
|
_ bin.BareDecoder = &ChatBoostSourceGiftCode{}
|
|
|
|
_ ChatBoostSourceClass = &ChatBoostSourceGiftCode{}
|
|
)
|
|
|
|
func (c *ChatBoostSourceGiftCode) Zero() bool {
|
|
if c == nil {
|
|
return true
|
|
}
|
|
if !(c.UserID == 0) {
|
|
return false
|
|
}
|
|
if !(c.GiftCode == "") {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (c *ChatBoostSourceGiftCode) String() string {
|
|
if c == nil {
|
|
return "ChatBoostSourceGiftCode(nil)"
|
|
}
|
|
type Alias ChatBoostSourceGiftCode
|
|
return fmt.Sprintf("ChatBoostSourceGiftCode%+v", Alias(*c))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*ChatBoostSourceGiftCode) TypeID() uint32 {
|
|
return ChatBoostSourceGiftCodeTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*ChatBoostSourceGiftCode) TypeName() string {
|
|
return "chatBoostSourceGiftCode"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (c *ChatBoostSourceGiftCode) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "chatBoostSourceGiftCode",
|
|
ID: ChatBoostSourceGiftCodeTypeID,
|
|
}
|
|
if c == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "UserID",
|
|
SchemaName: "user_id",
|
|
},
|
|
{
|
|
Name: "GiftCode",
|
|
SchemaName: "gift_code",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (c *ChatBoostSourceGiftCode) Encode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode chatBoostSourceGiftCode#fa2412ba as nil")
|
|
}
|
|
b.PutID(ChatBoostSourceGiftCodeTypeID)
|
|
return c.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (c *ChatBoostSourceGiftCode) EncodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode chatBoostSourceGiftCode#fa2412ba as nil")
|
|
}
|
|
b.PutInt53(c.UserID)
|
|
b.PutString(c.GiftCode)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (c *ChatBoostSourceGiftCode) Decode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode chatBoostSourceGiftCode#fa2412ba to nil")
|
|
}
|
|
if err := b.ConsumeID(ChatBoostSourceGiftCodeTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode chatBoostSourceGiftCode#fa2412ba: %w", err)
|
|
}
|
|
return c.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (c *ChatBoostSourceGiftCode) DecodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode chatBoostSourceGiftCode#fa2412ba to nil")
|
|
}
|
|
{
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatBoostSourceGiftCode#fa2412ba: field user_id: %w", err)
|
|
}
|
|
c.UserID = value
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatBoostSourceGiftCode#fa2412ba: field gift_code: %w", err)
|
|
}
|
|
c.GiftCode = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (c *ChatBoostSourceGiftCode) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode chatBoostSourceGiftCode#fa2412ba as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("chatBoostSourceGiftCode")
|
|
b.Comma()
|
|
b.FieldStart("user_id")
|
|
b.PutInt53(c.UserID)
|
|
b.Comma()
|
|
b.FieldStart("gift_code")
|
|
b.PutString(c.GiftCode)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (c *ChatBoostSourceGiftCode) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode chatBoostSourceGiftCode#fa2412ba to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("chatBoostSourceGiftCode"); err != nil {
|
|
return fmt.Errorf("unable to decode chatBoostSourceGiftCode#fa2412ba: %w", err)
|
|
}
|
|
case "user_id":
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatBoostSourceGiftCode#fa2412ba: field user_id: %w", err)
|
|
}
|
|
c.UserID = value
|
|
case "gift_code":
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatBoostSourceGiftCode#fa2412ba: field gift_code: %w", err)
|
|
}
|
|
c.GiftCode = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetUserID returns value of UserID field.
|
|
func (c *ChatBoostSourceGiftCode) GetUserID() (value int64) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.UserID
|
|
}
|
|
|
|
// GetGiftCode returns value of GiftCode field.
|
|
func (c *ChatBoostSourceGiftCode) GetGiftCode() (value string) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.GiftCode
|
|
}
|
|
|
|
// ChatBoostSourceGiveaway represents TL type `chatBoostSourceGiveaway#7254949a`.
|
|
type ChatBoostSourceGiveaway struct {
|
|
// Identifier of a user that won in the giveaway; 0 if none
|
|
UserID int64
|
|
// The created Telegram Premium gift code if it was used by the user or can be claimed by
|
|
// the current user; an empty string otherwise; for Telegram Premium giveways only
|
|
GiftCode string
|
|
// Number of Telegram Stars distributed among winners of the giveaway
|
|
StarCount int64
|
|
// Identifier of the corresponding giveaway message; can be an identifier of a deleted
|
|
// message
|
|
GiveawayMessageID int64
|
|
// True, if the winner for the corresponding giveaway prize wasn't chosen, because there
|
|
// were not enough participants
|
|
IsUnclaimed bool
|
|
}
|
|
|
|
// ChatBoostSourceGiveawayTypeID is TL type id of ChatBoostSourceGiveaway.
|
|
const ChatBoostSourceGiveawayTypeID = 0x7254949a
|
|
|
|
// construct implements constructor of ChatBoostSourceClass.
|
|
func (c ChatBoostSourceGiveaway) construct() ChatBoostSourceClass { return &c }
|
|
|
|
// Ensuring interfaces in compile-time for ChatBoostSourceGiveaway.
|
|
var (
|
|
_ bin.Encoder = &ChatBoostSourceGiveaway{}
|
|
_ bin.Decoder = &ChatBoostSourceGiveaway{}
|
|
_ bin.BareEncoder = &ChatBoostSourceGiveaway{}
|
|
_ bin.BareDecoder = &ChatBoostSourceGiveaway{}
|
|
|
|
_ ChatBoostSourceClass = &ChatBoostSourceGiveaway{}
|
|
)
|
|
|
|
func (c *ChatBoostSourceGiveaway) Zero() bool {
|
|
if c == nil {
|
|
return true
|
|
}
|
|
if !(c.UserID == 0) {
|
|
return false
|
|
}
|
|
if !(c.GiftCode == "") {
|
|
return false
|
|
}
|
|
if !(c.StarCount == 0) {
|
|
return false
|
|
}
|
|
if !(c.GiveawayMessageID == 0) {
|
|
return false
|
|
}
|
|
if !(c.IsUnclaimed == false) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (c *ChatBoostSourceGiveaway) String() string {
|
|
if c == nil {
|
|
return "ChatBoostSourceGiveaway(nil)"
|
|
}
|
|
type Alias ChatBoostSourceGiveaway
|
|
return fmt.Sprintf("ChatBoostSourceGiveaway%+v", Alias(*c))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*ChatBoostSourceGiveaway) TypeID() uint32 {
|
|
return ChatBoostSourceGiveawayTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*ChatBoostSourceGiveaway) TypeName() string {
|
|
return "chatBoostSourceGiveaway"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (c *ChatBoostSourceGiveaway) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "chatBoostSourceGiveaway",
|
|
ID: ChatBoostSourceGiveawayTypeID,
|
|
}
|
|
if c == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "UserID",
|
|
SchemaName: "user_id",
|
|
},
|
|
{
|
|
Name: "GiftCode",
|
|
SchemaName: "gift_code",
|
|
},
|
|
{
|
|
Name: "StarCount",
|
|
SchemaName: "star_count",
|
|
},
|
|
{
|
|
Name: "GiveawayMessageID",
|
|
SchemaName: "giveaway_message_id",
|
|
},
|
|
{
|
|
Name: "IsUnclaimed",
|
|
SchemaName: "is_unclaimed",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (c *ChatBoostSourceGiveaway) Encode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode chatBoostSourceGiveaway#7254949a as nil")
|
|
}
|
|
b.PutID(ChatBoostSourceGiveawayTypeID)
|
|
return c.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (c *ChatBoostSourceGiveaway) EncodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode chatBoostSourceGiveaway#7254949a as nil")
|
|
}
|
|
b.PutInt53(c.UserID)
|
|
b.PutString(c.GiftCode)
|
|
b.PutInt53(c.StarCount)
|
|
b.PutInt53(c.GiveawayMessageID)
|
|
b.PutBool(c.IsUnclaimed)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (c *ChatBoostSourceGiveaway) Decode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode chatBoostSourceGiveaway#7254949a to nil")
|
|
}
|
|
if err := b.ConsumeID(ChatBoostSourceGiveawayTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode chatBoostSourceGiveaway#7254949a: %w", err)
|
|
}
|
|
return c.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (c *ChatBoostSourceGiveaway) DecodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode chatBoostSourceGiveaway#7254949a to nil")
|
|
}
|
|
{
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatBoostSourceGiveaway#7254949a: field user_id: %w", err)
|
|
}
|
|
c.UserID = value
|
|
}
|
|
{
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatBoostSourceGiveaway#7254949a: field gift_code: %w", err)
|
|
}
|
|
c.GiftCode = value
|
|
}
|
|
{
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatBoostSourceGiveaway#7254949a: field star_count: %w", err)
|
|
}
|
|
c.StarCount = value
|
|
}
|
|
{
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatBoostSourceGiveaway#7254949a: field giveaway_message_id: %w", err)
|
|
}
|
|
c.GiveawayMessageID = value
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatBoostSourceGiveaway#7254949a: field is_unclaimed: %w", err)
|
|
}
|
|
c.IsUnclaimed = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (c *ChatBoostSourceGiveaway) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode chatBoostSourceGiveaway#7254949a as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("chatBoostSourceGiveaway")
|
|
b.Comma()
|
|
b.FieldStart("user_id")
|
|
b.PutInt53(c.UserID)
|
|
b.Comma()
|
|
b.FieldStart("gift_code")
|
|
b.PutString(c.GiftCode)
|
|
b.Comma()
|
|
b.FieldStart("star_count")
|
|
b.PutInt53(c.StarCount)
|
|
b.Comma()
|
|
b.FieldStart("giveaway_message_id")
|
|
b.PutInt53(c.GiveawayMessageID)
|
|
b.Comma()
|
|
b.FieldStart("is_unclaimed")
|
|
b.PutBool(c.IsUnclaimed)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (c *ChatBoostSourceGiveaway) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode chatBoostSourceGiveaway#7254949a to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("chatBoostSourceGiveaway"); err != nil {
|
|
return fmt.Errorf("unable to decode chatBoostSourceGiveaway#7254949a: %w", err)
|
|
}
|
|
case "user_id":
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatBoostSourceGiveaway#7254949a: field user_id: %w", err)
|
|
}
|
|
c.UserID = value
|
|
case "gift_code":
|
|
value, err := b.String()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatBoostSourceGiveaway#7254949a: field gift_code: %w", err)
|
|
}
|
|
c.GiftCode = value
|
|
case "star_count":
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatBoostSourceGiveaway#7254949a: field star_count: %w", err)
|
|
}
|
|
c.StarCount = value
|
|
case "giveaway_message_id":
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatBoostSourceGiveaway#7254949a: field giveaway_message_id: %w", err)
|
|
}
|
|
c.GiveawayMessageID = value
|
|
case "is_unclaimed":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatBoostSourceGiveaway#7254949a: field is_unclaimed: %w", err)
|
|
}
|
|
c.IsUnclaimed = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetUserID returns value of UserID field.
|
|
func (c *ChatBoostSourceGiveaway) GetUserID() (value int64) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.UserID
|
|
}
|
|
|
|
// GetGiftCode returns value of GiftCode field.
|
|
func (c *ChatBoostSourceGiveaway) GetGiftCode() (value string) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.GiftCode
|
|
}
|
|
|
|
// GetStarCount returns value of StarCount field.
|
|
func (c *ChatBoostSourceGiveaway) GetStarCount() (value int64) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.StarCount
|
|
}
|
|
|
|
// GetGiveawayMessageID returns value of GiveawayMessageID field.
|
|
func (c *ChatBoostSourceGiveaway) GetGiveawayMessageID() (value int64) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.GiveawayMessageID
|
|
}
|
|
|
|
// GetIsUnclaimed returns value of IsUnclaimed field.
|
|
func (c *ChatBoostSourceGiveaway) GetIsUnclaimed() (value bool) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.IsUnclaimed
|
|
}
|
|
|
|
// ChatBoostSourcePremium represents TL type `chatBoostSourcePremium#ed4eb`.
|
|
type ChatBoostSourcePremium struct {
|
|
// Identifier of the user
|
|
UserID int64
|
|
}
|
|
|
|
// ChatBoostSourcePremiumTypeID is TL type id of ChatBoostSourcePremium.
|
|
const ChatBoostSourcePremiumTypeID = 0xed4eb
|
|
|
|
// construct implements constructor of ChatBoostSourceClass.
|
|
func (c ChatBoostSourcePremium) construct() ChatBoostSourceClass { return &c }
|
|
|
|
// Ensuring interfaces in compile-time for ChatBoostSourcePremium.
|
|
var (
|
|
_ bin.Encoder = &ChatBoostSourcePremium{}
|
|
_ bin.Decoder = &ChatBoostSourcePremium{}
|
|
_ bin.BareEncoder = &ChatBoostSourcePremium{}
|
|
_ bin.BareDecoder = &ChatBoostSourcePremium{}
|
|
|
|
_ ChatBoostSourceClass = &ChatBoostSourcePremium{}
|
|
)
|
|
|
|
func (c *ChatBoostSourcePremium) Zero() bool {
|
|
if c == nil {
|
|
return true
|
|
}
|
|
if !(c.UserID == 0) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (c *ChatBoostSourcePremium) String() string {
|
|
if c == nil {
|
|
return "ChatBoostSourcePremium(nil)"
|
|
}
|
|
type Alias ChatBoostSourcePremium
|
|
return fmt.Sprintf("ChatBoostSourcePremium%+v", Alias(*c))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*ChatBoostSourcePremium) TypeID() uint32 {
|
|
return ChatBoostSourcePremiumTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*ChatBoostSourcePremium) TypeName() string {
|
|
return "chatBoostSourcePremium"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (c *ChatBoostSourcePremium) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "chatBoostSourcePremium",
|
|
ID: ChatBoostSourcePremiumTypeID,
|
|
}
|
|
if c == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "UserID",
|
|
SchemaName: "user_id",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (c *ChatBoostSourcePremium) Encode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode chatBoostSourcePremium#ed4eb as nil")
|
|
}
|
|
b.PutID(ChatBoostSourcePremiumTypeID)
|
|
return c.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (c *ChatBoostSourcePremium) EncodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode chatBoostSourcePremium#ed4eb as nil")
|
|
}
|
|
b.PutInt53(c.UserID)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (c *ChatBoostSourcePremium) Decode(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode chatBoostSourcePremium#ed4eb to nil")
|
|
}
|
|
if err := b.ConsumeID(ChatBoostSourcePremiumTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode chatBoostSourcePremium#ed4eb: %w", err)
|
|
}
|
|
return c.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (c *ChatBoostSourcePremium) DecodeBare(b *bin.Buffer) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode chatBoostSourcePremium#ed4eb to nil")
|
|
}
|
|
{
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatBoostSourcePremium#ed4eb: field user_id: %w", err)
|
|
}
|
|
c.UserID = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (c *ChatBoostSourcePremium) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't encode chatBoostSourcePremium#ed4eb as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("chatBoostSourcePremium")
|
|
b.Comma()
|
|
b.FieldStart("user_id")
|
|
b.PutInt53(c.UserID)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (c *ChatBoostSourcePremium) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if c == nil {
|
|
return fmt.Errorf("can't decode chatBoostSourcePremium#ed4eb to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("chatBoostSourcePremium"); err != nil {
|
|
return fmt.Errorf("unable to decode chatBoostSourcePremium#ed4eb: %w", err)
|
|
}
|
|
case "user_id":
|
|
value, err := b.Int53()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode chatBoostSourcePremium#ed4eb: field user_id: %w", err)
|
|
}
|
|
c.UserID = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetUserID returns value of UserID field.
|
|
func (c *ChatBoostSourcePremium) GetUserID() (value int64) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
return c.UserID
|
|
}
|
|
|
|
// ChatBoostSourceClassName is schema name of ChatBoostSourceClass.
|
|
const ChatBoostSourceClassName = "ChatBoostSource"
|
|
|
|
// ChatBoostSourceClass represents ChatBoostSource generic type.
|
|
//
|
|
// Example:
|
|
//
|
|
// g, err := tdapi.DecodeChatBoostSource(buf)
|
|
// if err != nil {
|
|
// panic(err)
|
|
// }
|
|
// switch v := g.(type) {
|
|
// case *tdapi.ChatBoostSourceGiftCode: // chatBoostSourceGiftCode#fa2412ba
|
|
// case *tdapi.ChatBoostSourceGiveaway: // chatBoostSourceGiveaway#7254949a
|
|
// case *tdapi.ChatBoostSourcePremium: // chatBoostSourcePremium#ed4eb
|
|
// default: panic(v)
|
|
// }
|
|
type ChatBoostSourceClass interface {
|
|
bin.Encoder
|
|
bin.Decoder
|
|
bin.BareEncoder
|
|
bin.BareDecoder
|
|
construct() ChatBoostSourceClass
|
|
|
|
// 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
|
|
|
|
// Identifier of a user, for which the gift code was created
|
|
GetUserID() (value int64)
|
|
}
|
|
|
|
// DecodeChatBoostSource implements binary de-serialization for ChatBoostSourceClass.
|
|
func DecodeChatBoostSource(buf *bin.Buffer) (ChatBoostSourceClass, error) {
|
|
id, err := buf.PeekID()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
switch id {
|
|
case ChatBoostSourceGiftCodeTypeID:
|
|
// Decoding chatBoostSourceGiftCode#fa2412ba.
|
|
v := ChatBoostSourceGiftCode{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode ChatBoostSourceClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case ChatBoostSourceGiveawayTypeID:
|
|
// Decoding chatBoostSourceGiveaway#7254949a.
|
|
v := ChatBoostSourceGiveaway{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode ChatBoostSourceClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case ChatBoostSourcePremiumTypeID:
|
|
// Decoding chatBoostSourcePremium#ed4eb.
|
|
v := ChatBoostSourcePremium{}
|
|
if err := v.Decode(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode ChatBoostSourceClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
default:
|
|
return nil, fmt.Errorf("unable to decode ChatBoostSourceClass: %w", bin.NewUnexpectedID(id))
|
|
}
|
|
}
|
|
|
|
// DecodeTDLibJSONChatBoostSource implements binary de-serialization for ChatBoostSourceClass.
|
|
func DecodeTDLibJSONChatBoostSource(buf tdjson.Decoder) (ChatBoostSourceClass, error) {
|
|
id, err := buf.FindTypeID()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
switch id {
|
|
case "chatBoostSourceGiftCode":
|
|
// Decoding chatBoostSourceGiftCode#fa2412ba.
|
|
v := ChatBoostSourceGiftCode{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode ChatBoostSourceClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "chatBoostSourceGiveaway":
|
|
// Decoding chatBoostSourceGiveaway#7254949a.
|
|
v := ChatBoostSourceGiveaway{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode ChatBoostSourceClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
case "chatBoostSourcePremium":
|
|
// Decoding chatBoostSourcePremium#ed4eb.
|
|
v := ChatBoostSourcePremium{}
|
|
if err := v.DecodeTDLibJSON(buf); err != nil {
|
|
return nil, fmt.Errorf("unable to decode ChatBoostSourceClass: %w", err)
|
|
}
|
|
return &v, nil
|
|
default:
|
|
return nil, fmt.Errorf("unable to decode ChatBoostSourceClass: %w", tdjson.NewUnexpectedID(id))
|
|
}
|
|
}
|
|
|
|
// ChatBoostSource boxes the ChatBoostSourceClass providing a helper.
|
|
type ChatBoostSourceBox struct {
|
|
ChatBoostSource ChatBoostSourceClass
|
|
}
|
|
|
|
// Decode implements bin.Decoder for ChatBoostSourceBox.
|
|
func (b *ChatBoostSourceBox) Decode(buf *bin.Buffer) error {
|
|
if b == nil {
|
|
return fmt.Errorf("unable to decode ChatBoostSourceBox to nil")
|
|
}
|
|
v, err := DecodeChatBoostSource(buf)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode boxed value: %w", err)
|
|
}
|
|
b.ChatBoostSource = v
|
|
return nil
|
|
}
|
|
|
|
// Encode implements bin.Encode for ChatBoostSourceBox.
|
|
func (b *ChatBoostSourceBox) Encode(buf *bin.Buffer) error {
|
|
if b == nil || b.ChatBoostSource == nil {
|
|
return fmt.Errorf("unable to encode ChatBoostSourceClass as nil")
|
|
}
|
|
return b.ChatBoostSource.Encode(buf)
|
|
}
|
|
|
|
// DecodeTDLibJSON implements bin.Decoder for ChatBoostSourceBox.
|
|
func (b *ChatBoostSourceBox) DecodeTDLibJSON(buf tdjson.Decoder) error {
|
|
if b == nil {
|
|
return fmt.Errorf("unable to decode ChatBoostSourceBox to nil")
|
|
}
|
|
v, err := DecodeTDLibJSONChatBoostSource(buf)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode boxed value: %w", err)
|
|
}
|
|
b.ChatBoostSource = v
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements bin.Encode for ChatBoostSourceBox.
|
|
func (b *ChatBoostSourceBox) EncodeTDLibJSON(buf tdjson.Encoder) error {
|
|
if b == nil || b.ChatBoostSource == nil {
|
|
return fmt.Errorf("unable to encode ChatBoostSourceClass as nil")
|
|
}
|
|
return b.ChatBoostSource.EncodeTDLibJSON(buf)
|
|
}
|