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
189 lines
3.8 KiB
Go
189 lines
3.8 KiB
Go
// 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{}
|
|
)
|
|
|
|
// StarsAmount represents TL type `starsAmount#bbb6b4a3`.
|
|
//
|
|
// See https://core.telegram.org/constructor/starsAmount for reference.
|
|
type StarsAmount struct {
|
|
// Amount field of StarsAmount.
|
|
Amount int64
|
|
// Nanos field of StarsAmount.
|
|
Nanos int
|
|
}
|
|
|
|
// StarsAmountTypeID is TL type id of StarsAmount.
|
|
const StarsAmountTypeID = 0xbbb6b4a3
|
|
|
|
// Ensuring interfaces in compile-time for StarsAmount.
|
|
var (
|
|
_ bin.Encoder = &StarsAmount{}
|
|
_ bin.Decoder = &StarsAmount{}
|
|
_ bin.BareEncoder = &StarsAmount{}
|
|
_ bin.BareDecoder = &StarsAmount{}
|
|
)
|
|
|
|
func (s *StarsAmount) Zero() bool {
|
|
if s == nil {
|
|
return true
|
|
}
|
|
if !(s.Amount == 0) {
|
|
return false
|
|
}
|
|
if !(s.Nanos == 0) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
// String implements fmt.Stringer.
|
|
func (s *StarsAmount) String() string {
|
|
if s == nil {
|
|
return "StarsAmount(nil)"
|
|
}
|
|
type Alias StarsAmount
|
|
return fmt.Sprintf("StarsAmount%+v", Alias(*s))
|
|
}
|
|
|
|
// FillFrom fills StarsAmount from given interface.
|
|
func (s *StarsAmount) FillFrom(from interface {
|
|
GetAmount() (value int64)
|
|
GetNanos() (value int)
|
|
}) {
|
|
s.Amount = from.GetAmount()
|
|
s.Nanos = from.GetNanos()
|
|
}
|
|
|
|
// TypeID returns type id in TL schema.
|
|
//
|
|
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
|
func (*StarsAmount) TypeID() uint32 {
|
|
return StarsAmountTypeID
|
|
}
|
|
|
|
// TypeName returns name of type in TL schema.
|
|
func (*StarsAmount) TypeName() string {
|
|
return "starsAmount"
|
|
}
|
|
|
|
// TypeInfo returns info about TL type.
|
|
func (s *StarsAmount) TypeInfo() tdp.Type {
|
|
typ := tdp.Type{
|
|
Name: "starsAmount",
|
|
ID: StarsAmountTypeID,
|
|
}
|
|
if s == nil {
|
|
typ.Null = true
|
|
return typ
|
|
}
|
|
typ.Fields = []tdp.Field{
|
|
{
|
|
Name: "Amount",
|
|
SchemaName: "amount",
|
|
},
|
|
{
|
|
Name: "Nanos",
|
|
SchemaName: "nanos",
|
|
},
|
|
}
|
|
return typ
|
|
}
|
|
|
|
// Encode implements bin.Encoder.
|
|
func (s *StarsAmount) Encode(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode starsAmount#bbb6b4a3 as nil")
|
|
}
|
|
b.PutID(StarsAmountTypeID)
|
|
return s.EncodeBare(b)
|
|
}
|
|
|
|
// EncodeBare implements bin.BareEncoder.
|
|
func (s *StarsAmount) EncodeBare(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't encode starsAmount#bbb6b4a3 as nil")
|
|
}
|
|
b.PutLong(s.Amount)
|
|
b.PutInt(s.Nanos)
|
|
return nil
|
|
}
|
|
|
|
// Decode implements bin.Decoder.
|
|
func (s *StarsAmount) Decode(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode starsAmount#bbb6b4a3 to nil")
|
|
}
|
|
if err := b.ConsumeID(StarsAmountTypeID); err != nil {
|
|
return fmt.Errorf("unable to decode starsAmount#bbb6b4a3: %w", err)
|
|
}
|
|
return s.DecodeBare(b)
|
|
}
|
|
|
|
// DecodeBare implements bin.BareDecoder.
|
|
func (s *StarsAmount) DecodeBare(b *bin.Buffer) error {
|
|
if s == nil {
|
|
return fmt.Errorf("can't decode starsAmount#bbb6b4a3 to nil")
|
|
}
|
|
{
|
|
value, err := b.Long()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode starsAmount#bbb6b4a3: field amount: %w", err)
|
|
}
|
|
s.Amount = value
|
|
}
|
|
{
|
|
value, err := b.Int()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to decode starsAmount#bbb6b4a3: field nanos: %w", err)
|
|
}
|
|
s.Nanos = value
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetAmount returns value of Amount field.
|
|
func (s *StarsAmount) GetAmount() (value int64) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.Amount
|
|
}
|
|
|
|
// GetNanos returns value of Nanos field.
|
|
func (s *StarsAmount) GetNanos() (value int) {
|
|
if s == nil {
|
|
return
|
|
}
|
|
return s.Nanos
|
|
}
|