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
331 lines
8.7 KiB
Go
331 lines
8.7 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{}
|
|
)
|
|
|
|
// StarRevenueStatus represents TL type `starRevenueStatus#779532e8`.
|
|
type StarRevenueStatus struct {
|
|
// Total amount of Telegram Stars earned
|
|
TotalAmount StarAmount
|
|
// The amount of Telegram Stars that aren't withdrawn yet
|
|
CurrentAmount StarAmount
|
|
// The amount of Telegram Stars that are available for withdrawal
|
|
AvailableAmount StarAmount
|
|
// True, if Telegram Stars can be withdrawn now or later
|
|
WithdrawalEnabled bool
|
|
// Time left before the next withdrawal can be started, in seconds; 0 if withdrawal can
|
|
// be started now
|
|
NextWithdrawalIn int32
|
|
}
|
|
|
|
// StarRevenueStatusTypeID is TL type id of StarRevenueStatus.
|
|
const StarRevenueStatusTypeID = 0x779532e8
|
|
|
|
// Ensuring interfaces in compile-time for StarRevenueStatus.
|
|
var (
|
|
_ bin.Encoder = &StarRevenueStatus{}
|
|
_ bin.Decoder = &StarRevenueStatus{}
|
|
_ bin.BareEncoder = &StarRevenueStatus{}
|
|
_ bin.BareDecoder = &StarRevenueStatus{}
|
|
)
|
|
|
|
func (s *StarRevenueStatus) Zero() bool {
|
|
if s == nil {
|
|
return true
|
|
}
|
|
if !(s.TotalAmount.Zero()) {
|
|
return false
|
|
}
|
|
if !(s.CurrentAmount.Zero()) {
|
|
return false
|
|
}
|
|
if !(s.AvailableAmount.Zero()) {
|
|
return false
|
|
}
|
|
if !(s.WithdrawalEnabled == false) {
|
|
return false
|
|
}
|
|
if !(s.NextWithdrawalIn == 0) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (s *StarRevenueStatus) String() string {
|
|
if s == nil {
|
|
return "StarRevenueStatus(nil)"
|
|
}
|
|
type Alias StarRevenueStatus
|
|
return fmt.Sprintf("StarRevenueStatus%+v", Alias(*s))
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*StarRevenueStatus) TypeID() uint32 {
|
|
return StarRevenueStatusTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*StarRevenueStatus) TypeName() string {
|
|
return "starRevenueStatus"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (s *StarRevenueStatus) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "starRevenueStatus",
|
|
ID: StarRevenueStatusTypeID,
|
|
}
|
|
if s == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "TotalAmount",
|
|
SchemaName: "total_amount",
|
|
},
|
|
{
|
|
Name: "CurrentAmount",
|
|
SchemaName: "current_amount",
|
|
},
|
|
{
|
|
Name: "AvailableAmount",
|
|
SchemaName: "available_amount",
|
|
},
|
|
{
|
|
Name: "WithdrawalEnabled",
|
|
SchemaName: "withdrawal_enabled",
|
|
},
|
|
{
|
|
Name: "NextWithdrawalIn",
|
|
SchemaName: "next_withdrawal_in",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (s *StarRevenueStatus) Encode(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode starRevenueStatus#779532e8 as nil")
|
|
}
|
|
b.PutID(StarRevenueStatusTypeID)
|
|
return s.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (s *StarRevenueStatus) EncodeBare(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode starRevenueStatus#779532e8 as nil")
|
|
}
|
|
if err := s.TotalAmount.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode starRevenueStatus#779532e8: field total_amount: %w", err)
|
|
}
|
|
if err := s.CurrentAmount.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode starRevenueStatus#779532e8: field current_amount: %w", err)
|
|
}
|
|
if err := s.AvailableAmount.Encode(b); err != nil {
|
|
return fmt.Errorf("unable to encode starRevenueStatus#779532e8: field available_amount: %w", err)
|
|
}
|
|
b.PutBool(s.WithdrawalEnabled)
|
|
b.PutInt32(s.NextWithdrawalIn)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (s *StarRevenueStatus) Decode(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode starRevenueStatus#779532e8 to nil")
|
|
}
|
|
if err := b.ConsumeID(StarRevenueStatusTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode starRevenueStatus#779532e8: %w", err)
|
|
}
|
|
return s.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (s *StarRevenueStatus) DecodeBare(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode starRevenueStatus#779532e8 to nil")
|
|
}
|
|
{
|
|
if err := s.TotalAmount.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode starRevenueStatus#779532e8: field total_amount: %w", err)
|
|
}
|
|
}
|
|
{
|
|
if err := s.CurrentAmount.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode starRevenueStatus#779532e8: field current_amount: %w", err)
|
|
}
|
|
}
|
|
{
|
|
if err := s.AvailableAmount.Decode(b); err != nil {
|
|
return fmt.Errorf("unable to decode starRevenueStatus#779532e8: field available_amount: %w", err)
|
|
}
|
|
}
|
|
{
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode starRevenueStatus#779532e8: field withdrawal_enabled: %w", err)
|
|
}
|
|
s.WithdrawalEnabled = value
|
|
}
|
|
{
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode starRevenueStatus#779532e8: field next_withdrawal_in: %w", err)
|
|
}
|
|
s.NextWithdrawalIn = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
|
func (s *StarRevenueStatus) EncodeTDLibJSON(b tdjson.Encoder) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode starRevenueStatus#779532e8 as nil")
|
|
}
|
|
b.ObjStart()
|
|
b.PutID("starRevenueStatus")
|
|
b.Comma()
|
|
b.FieldStart("total_amount")
|
|
if err := s.TotalAmount.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode starRevenueStatus#779532e8: field total_amount: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("current_amount")
|
|
if err := s.CurrentAmount.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode starRevenueStatus#779532e8: field current_amount: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("available_amount")
|
|
if err := s.AvailableAmount.EncodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to encode starRevenueStatus#779532e8: field available_amount: %w", err)
|
|
}
|
|
b.Comma()
|
|
b.FieldStart("withdrawal_enabled")
|
|
b.PutBool(s.WithdrawalEnabled)
|
|
b.Comma()
|
|
b.FieldStart("next_withdrawal_in")
|
|
b.PutInt32(s.NextWithdrawalIn)
|
|
b.Comma()
|
|
b.StripComma()
|
|
b.ObjEnd()
|
|
return nil
|
|
}
|
|
|
|
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
|
func (s *StarRevenueStatus) DecodeTDLibJSON(b tdjson.Decoder) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode starRevenueStatus#779532e8 to nil")
|
|
}
|
|
|
|
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
|
switch string(key) {
|
|
case tdjson.TypeField:
|
|
if err := b.ConsumeID("starRevenueStatus"); err != nil {
|
|
return fmt.Errorf("unable to decode starRevenueStatus#779532e8: %w", err)
|
|
}
|
|
case "total_amount":
|
|
if err := s.TotalAmount.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode starRevenueStatus#779532e8: field total_amount: %w", err)
|
|
}
|
|
case "current_amount":
|
|
if err := s.CurrentAmount.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode starRevenueStatus#779532e8: field current_amount: %w", err)
|
|
}
|
|
case "available_amount":
|
|
if err := s.AvailableAmount.DecodeTDLibJSON(b); err != nil {
|
|
return fmt.Errorf("unable to decode starRevenueStatus#779532e8: field available_amount: %w", err)
|
|
}
|
|
case "withdrawal_enabled":
|
|
value, err := b.Bool()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode starRevenueStatus#779532e8: field withdrawal_enabled: %w", err)
|
|
}
|
|
s.WithdrawalEnabled = value
|
|
case "next_withdrawal_in":
|
|
value, err := b.Int32()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode starRevenueStatus#779532e8: field next_withdrawal_in: %w", err)
|
|
}
|
|
s.NextWithdrawalIn = value
|
|
default:
|
|
return b.Skip()
|
|
}
|
|
return nil
|
|
})
|
|
}
|
|
|
|
// GetTotalAmount returns value of TotalAmount field.
|
|
func (s *StarRevenueStatus) GetTotalAmount() (value StarAmount) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.TotalAmount
|
|
}
|
|
|
|
// GetCurrentAmount returns value of CurrentAmount field.
|
|
func (s *StarRevenueStatus) GetCurrentAmount() (value StarAmount) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.CurrentAmount
|
|
}
|
|
|
|
// GetAvailableAmount returns value of AvailableAmount field.
|
|
func (s *StarRevenueStatus) GetAvailableAmount() (value StarAmount) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.AvailableAmount
|
|
}
|
|
|
|
// GetWithdrawalEnabled returns value of WithdrawalEnabled field.
|
|
func (s *StarRevenueStatus) GetWithdrawalEnabled() (value bool) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.WithdrawalEnabled
|
|
}
|
|
|
|
// GetNextWithdrawalIn returns value of NextWithdrawalIn field.
|
|
func (s *StarRevenueStatus) GetNextWithdrawalIn() (value int32) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.NextWithdrawalIn
|
|
}
|