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,316 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// TransferGiftRequest represents TL type `transferGift#ba6c853a`.
|
||||
type TransferGiftRequest struct {
|
||||
// Unique identifier of business connection on behalf of which to send the request; for
|
||||
// bots only
|
||||
BusinessConnectionID string
|
||||
// Identifier of the gift
|
||||
ReceivedGiftID string
|
||||
// Identifier of the user or the channel chat that will receive the gift
|
||||
NewOwnerID MessageSenderClass
|
||||
// The amount of Telegram Stars required to pay for the transfer
|
||||
StarCount int64
|
||||
}
|
||||
|
||||
// TransferGiftRequestTypeID is TL type id of TransferGiftRequest.
|
||||
const TransferGiftRequestTypeID = 0xba6c853a
|
||||
|
||||
// Ensuring interfaces in compile-time for TransferGiftRequest.
|
||||
var (
|
||||
_ bin.Encoder = &TransferGiftRequest{}
|
||||
_ bin.Decoder = &TransferGiftRequest{}
|
||||
_ bin.BareEncoder = &TransferGiftRequest{}
|
||||
_ bin.BareDecoder = &TransferGiftRequest{}
|
||||
)
|
||||
|
||||
func (t *TransferGiftRequest) Zero() bool {
|
||||
if t == nil {
|
||||
return true
|
||||
}
|
||||
if !(t.BusinessConnectionID == "") {
|
||||
return false
|
||||
}
|
||||
if !(t.ReceivedGiftID == "") {
|
||||
return false
|
||||
}
|
||||
if !(t.NewOwnerID == nil) {
|
||||
return false
|
||||
}
|
||||
if !(t.StarCount == 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (t *TransferGiftRequest) String() string {
|
||||
if t == nil {
|
||||
return "TransferGiftRequest(nil)"
|
||||
}
|
||||
type Alias TransferGiftRequest
|
||||
return fmt.Sprintf("TransferGiftRequest%+v", Alias(*t))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*TransferGiftRequest) TypeID() uint32 {
|
||||
return TransferGiftRequestTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*TransferGiftRequest) TypeName() string {
|
||||
return "transferGift"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (t *TransferGiftRequest) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "transferGift",
|
||||
ID: TransferGiftRequestTypeID,
|
||||
}
|
||||
if t == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "BusinessConnectionID",
|
||||
SchemaName: "business_connection_id",
|
||||
},
|
||||
{
|
||||
Name: "ReceivedGiftID",
|
||||
SchemaName: "received_gift_id",
|
||||
},
|
||||
{
|
||||
Name: "NewOwnerID",
|
||||
SchemaName: "new_owner_id",
|
||||
},
|
||||
{
|
||||
Name: "StarCount",
|
||||
SchemaName: "star_count",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (t *TransferGiftRequest) Encode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode transferGift#ba6c853a as nil")
|
||||
}
|
||||
b.PutID(TransferGiftRequestTypeID)
|
||||
return t.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (t *TransferGiftRequest) EncodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode transferGift#ba6c853a as nil")
|
||||
}
|
||||
b.PutString(t.BusinessConnectionID)
|
||||
b.PutString(t.ReceivedGiftID)
|
||||
if t.NewOwnerID == nil {
|
||||
return fmt.Errorf("unable to encode transferGift#ba6c853a: field new_owner_id is nil")
|
||||
}
|
||||
if err := t.NewOwnerID.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode transferGift#ba6c853a: field new_owner_id: %w", err)
|
||||
}
|
||||
b.PutInt53(t.StarCount)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (t *TransferGiftRequest) Decode(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode transferGift#ba6c853a to nil")
|
||||
}
|
||||
if err := b.ConsumeID(TransferGiftRequestTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode transferGift#ba6c853a: %w", err)
|
||||
}
|
||||
return t.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (t *TransferGiftRequest) DecodeBare(b *bin.Buffer) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode transferGift#ba6c853a to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode transferGift#ba6c853a: field business_connection_id: %w", err)
|
||||
}
|
||||
t.BusinessConnectionID = value
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode transferGift#ba6c853a: field received_gift_id: %w", err)
|
||||
}
|
||||
t.ReceivedGiftID = value
|
||||
}
|
||||
{
|
||||
value, err := DecodeMessageSender(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode transferGift#ba6c853a: field new_owner_id: %w", err)
|
||||
}
|
||||
t.NewOwnerID = value
|
||||
}
|
||||
{
|
||||
value, err := b.Int53()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode transferGift#ba6c853a: field star_count: %w", err)
|
||||
}
|
||||
t.StarCount = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
||||
func (t *TransferGiftRequest) EncodeTDLibJSON(b tdjson.Encoder) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't encode transferGift#ba6c853a as nil")
|
||||
}
|
||||
b.ObjStart()
|
||||
b.PutID("transferGift")
|
||||
b.Comma()
|
||||
b.FieldStart("business_connection_id")
|
||||
b.PutString(t.BusinessConnectionID)
|
||||
b.Comma()
|
||||
b.FieldStart("received_gift_id")
|
||||
b.PutString(t.ReceivedGiftID)
|
||||
b.Comma()
|
||||
b.FieldStart("new_owner_id")
|
||||
if t.NewOwnerID == nil {
|
||||
return fmt.Errorf("unable to encode transferGift#ba6c853a: field new_owner_id is nil")
|
||||
}
|
||||
if err := t.NewOwnerID.EncodeTDLibJSON(b); err != nil {
|
||||
return fmt.Errorf("unable to encode transferGift#ba6c853a: field new_owner_id: %w", err)
|
||||
}
|
||||
b.Comma()
|
||||
b.FieldStart("star_count")
|
||||
b.PutInt53(t.StarCount)
|
||||
b.Comma()
|
||||
b.StripComma()
|
||||
b.ObjEnd()
|
||||
return nil
|
||||
}
|
||||
|
||||
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
||||
func (t *TransferGiftRequest) DecodeTDLibJSON(b tdjson.Decoder) error {
|
||||
if t == nil {
|
||||
return fmt.Errorf("can't decode transferGift#ba6c853a to nil")
|
||||
}
|
||||
|
||||
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
||||
switch string(key) {
|
||||
case tdjson.TypeField:
|
||||
if err := b.ConsumeID("transferGift"); err != nil {
|
||||
return fmt.Errorf("unable to decode transferGift#ba6c853a: %w", err)
|
||||
}
|
||||
case "business_connection_id":
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode transferGift#ba6c853a: field business_connection_id: %w", err)
|
||||
}
|
||||
t.BusinessConnectionID = value
|
||||
case "received_gift_id":
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode transferGift#ba6c853a: field received_gift_id: %w", err)
|
||||
}
|
||||
t.ReceivedGiftID = value
|
||||
case "new_owner_id":
|
||||
value, err := DecodeTDLibJSONMessageSender(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode transferGift#ba6c853a: field new_owner_id: %w", err)
|
||||
}
|
||||
t.NewOwnerID = value
|
||||
case "star_count":
|
||||
value, err := b.Int53()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode transferGift#ba6c853a: field star_count: %w", err)
|
||||
}
|
||||
t.StarCount = value
|
||||
default:
|
||||
return b.Skip()
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// GetBusinessConnectionID returns value of BusinessConnectionID field.
|
||||
func (t *TransferGiftRequest) GetBusinessConnectionID() (value string) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.BusinessConnectionID
|
||||
}
|
||||
|
||||
// GetReceivedGiftID returns value of ReceivedGiftID field.
|
||||
func (t *TransferGiftRequest) GetReceivedGiftID() (value string) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.ReceivedGiftID
|
||||
}
|
||||
|
||||
// GetNewOwnerID returns value of NewOwnerID field.
|
||||
func (t *TransferGiftRequest) GetNewOwnerID() (value MessageSenderClass) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.NewOwnerID
|
||||
}
|
||||
|
||||
// GetStarCount returns value of StarCount field.
|
||||
func (t *TransferGiftRequest) GetStarCount() (value int64) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
return t.StarCount
|
||||
}
|
||||
|
||||
// TransferGift invokes method transferGift#ba6c853a returning error if any.
|
||||
func (c *Client) TransferGift(ctx context.Context, request *TransferGiftRequest) error {
|
||||
var ok Ok
|
||||
|
||||
if err := c.rpc.Invoke(ctx, request, &ok); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user