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,195 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// LabeledPrice represents TL type `labeledPrice#cb296bf8`.
|
||||
// This object represents a portion of the price for goods or services.
|
||||
//
|
||||
// See https://core.telegram.org/constructor/labeledPrice for reference.
|
||||
type LabeledPrice struct {
|
||||
// Portion label
|
||||
Label string
|
||||
// Price of the product in the smallest units of the currency (integer, not float/double)
|
||||
// For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in
|
||||
// currencies.json¹, it shows the number of digits past the decimal point for each
|
||||
// currency (2 for the majority of currencies).
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/bots/payments/currencies.json
|
||||
Amount int64
|
||||
}
|
||||
|
||||
// LabeledPriceTypeID is TL type id of LabeledPrice.
|
||||
const LabeledPriceTypeID = 0xcb296bf8
|
||||
|
||||
// Ensuring interfaces in compile-time for LabeledPrice.
|
||||
var (
|
||||
_ bin.Encoder = &LabeledPrice{}
|
||||
_ bin.Decoder = &LabeledPrice{}
|
||||
_ bin.BareEncoder = &LabeledPrice{}
|
||||
_ bin.BareDecoder = &LabeledPrice{}
|
||||
)
|
||||
|
||||
func (l *LabeledPrice) Zero() bool {
|
||||
if l == nil {
|
||||
return true
|
||||
}
|
||||
if !(l.Label == "") {
|
||||
return false
|
||||
}
|
||||
if !(l.Amount == 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (l *LabeledPrice) String() string {
|
||||
if l == nil {
|
||||
return "LabeledPrice(nil)"
|
||||
}
|
||||
type Alias LabeledPrice
|
||||
return fmt.Sprintf("LabeledPrice%+v", Alias(*l))
|
||||
}
|
||||
|
||||
// FillFrom fills LabeledPrice from given interface.
|
||||
func (l *LabeledPrice) FillFrom(from interface {
|
||||
GetLabel() (value string)
|
||||
GetAmount() (value int64)
|
||||
}) {
|
||||
l.Label = from.GetLabel()
|
||||
l.Amount = from.GetAmount()
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*LabeledPrice) TypeID() uint32 {
|
||||
return LabeledPriceTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*LabeledPrice) TypeName() string {
|
||||
return "labeledPrice"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (l *LabeledPrice) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "labeledPrice",
|
||||
ID: LabeledPriceTypeID,
|
||||
}
|
||||
if l == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "Label",
|
||||
SchemaName: "label",
|
||||
},
|
||||
{
|
||||
Name: "Amount",
|
||||
SchemaName: "amount",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (l *LabeledPrice) Encode(b *bin.Buffer) error {
|
||||
if l == nil {
|
||||
return fmt.Errorf("can't encode labeledPrice#cb296bf8 as nil")
|
||||
}
|
||||
b.PutID(LabeledPriceTypeID)
|
||||
return l.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (l *LabeledPrice) EncodeBare(b *bin.Buffer) error {
|
||||
if l == nil {
|
||||
return fmt.Errorf("can't encode labeledPrice#cb296bf8 as nil")
|
||||
}
|
||||
b.PutString(l.Label)
|
||||
b.PutLong(l.Amount)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (l *LabeledPrice) Decode(b *bin.Buffer) error {
|
||||
if l == nil {
|
||||
return fmt.Errorf("can't decode labeledPrice#cb296bf8 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(LabeledPriceTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode labeledPrice#cb296bf8: %w", err)
|
||||
}
|
||||
return l.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (l *LabeledPrice) DecodeBare(b *bin.Buffer) error {
|
||||
if l == nil {
|
||||
return fmt.Errorf("can't decode labeledPrice#cb296bf8 to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode labeledPrice#cb296bf8: field label: %w", err)
|
||||
}
|
||||
l.Label = value
|
||||
}
|
||||
{
|
||||
value, err := b.Long()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode labeledPrice#cb296bf8: field amount: %w", err)
|
||||
}
|
||||
l.Amount = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetLabel returns value of Label field.
|
||||
func (l *LabeledPrice) GetLabel() (value string) {
|
||||
if l == nil {
|
||||
return
|
||||
}
|
||||
return l.Label
|
||||
}
|
||||
|
||||
// GetAmount returns value of Amount field.
|
||||
func (l *LabeledPrice) GetAmount() (value int64) {
|
||||
if l == nil {
|
||||
return
|
||||
}
|
||||
return l.Amount
|
||||
}
|
||||
Reference in New Issue
Block a user