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,241 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// AccountSaveRingtoneRequest represents TL type `account.saveRingtone#3dea5b03`.
|
||||
// Save or remove saved notification sound.
|
||||
// If the notification sound is already in MP3 format, account.savedRingtone¹ will be
|
||||
// returned.
|
||||
// Otherwise, it will be automatically converted and a account.savedRingtoneConverted²
|
||||
// will be returned, containing a new document³ object that should be used to refer to
|
||||
// the ringtone from now on (ie when deleting it using the unsave parameter, or when
|
||||
// downloading it).
|
||||
//
|
||||
// Links:
|
||||
// 1. https://core.telegram.org/constructor/account.savedRingtone
|
||||
// 2. https://core.telegram.org/constructor/account.savedRingtoneConverted
|
||||
// 3. https://core.telegram.org/constructor/document
|
||||
//
|
||||
// See https://core.telegram.org/method/account.saveRingtone for reference.
|
||||
type AccountSaveRingtoneRequest struct {
|
||||
// Notification sound uploaded using account.uploadRingtone¹
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/method/account.uploadRingtone
|
||||
ID InputDocumentClass
|
||||
// Whether to add or delete the notification sound
|
||||
Unsave bool
|
||||
}
|
||||
|
||||
// AccountSaveRingtoneRequestTypeID is TL type id of AccountSaveRingtoneRequest.
|
||||
const AccountSaveRingtoneRequestTypeID = 0x3dea5b03
|
||||
|
||||
// Ensuring interfaces in compile-time for AccountSaveRingtoneRequest.
|
||||
var (
|
||||
_ bin.Encoder = &AccountSaveRingtoneRequest{}
|
||||
_ bin.Decoder = &AccountSaveRingtoneRequest{}
|
||||
_ bin.BareEncoder = &AccountSaveRingtoneRequest{}
|
||||
_ bin.BareDecoder = &AccountSaveRingtoneRequest{}
|
||||
)
|
||||
|
||||
func (s *AccountSaveRingtoneRequest) Zero() bool {
|
||||
if s == nil {
|
||||
return true
|
||||
}
|
||||
if !(s.ID == nil) {
|
||||
return false
|
||||
}
|
||||
if !(s.Unsave == false) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (s *AccountSaveRingtoneRequest) String() string {
|
||||
if s == nil {
|
||||
return "AccountSaveRingtoneRequest(nil)"
|
||||
}
|
||||
type Alias AccountSaveRingtoneRequest
|
||||
return fmt.Sprintf("AccountSaveRingtoneRequest%+v", Alias(*s))
|
||||
}
|
||||
|
||||
// FillFrom fills AccountSaveRingtoneRequest from given interface.
|
||||
func (s *AccountSaveRingtoneRequest) FillFrom(from interface {
|
||||
GetID() (value InputDocumentClass)
|
||||
GetUnsave() (value bool)
|
||||
}) {
|
||||
s.ID = from.GetID()
|
||||
s.Unsave = from.GetUnsave()
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*AccountSaveRingtoneRequest) TypeID() uint32 {
|
||||
return AccountSaveRingtoneRequestTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*AccountSaveRingtoneRequest) TypeName() string {
|
||||
return "account.saveRingtone"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (s *AccountSaveRingtoneRequest) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "account.saveRingtone",
|
||||
ID: AccountSaveRingtoneRequestTypeID,
|
||||
}
|
||||
if s == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "ID",
|
||||
SchemaName: "id",
|
||||
},
|
||||
{
|
||||
Name: "Unsave",
|
||||
SchemaName: "unsave",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (s *AccountSaveRingtoneRequest) Encode(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode account.saveRingtone#3dea5b03 as nil")
|
||||
}
|
||||
b.PutID(AccountSaveRingtoneRequestTypeID)
|
||||
return s.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (s *AccountSaveRingtoneRequest) EncodeBare(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't encode account.saveRingtone#3dea5b03 as nil")
|
||||
}
|
||||
if s.ID == nil {
|
||||
return fmt.Errorf("unable to encode account.saveRingtone#3dea5b03: field id is nil")
|
||||
}
|
||||
if err := s.ID.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode account.saveRingtone#3dea5b03: field id: %w", err)
|
||||
}
|
||||
b.PutBool(s.Unsave)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (s *AccountSaveRingtoneRequest) Decode(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode account.saveRingtone#3dea5b03 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(AccountSaveRingtoneRequestTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode account.saveRingtone#3dea5b03: %w", err)
|
||||
}
|
||||
return s.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (s *AccountSaveRingtoneRequest) DecodeBare(b *bin.Buffer) error {
|
||||
if s == nil {
|
||||
return fmt.Errorf("can't decode account.saveRingtone#3dea5b03 to nil")
|
||||
}
|
||||
{
|
||||
value, err := DecodeInputDocument(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode account.saveRingtone#3dea5b03: field id: %w", err)
|
||||
}
|
||||
s.ID = value
|
||||
}
|
||||
{
|
||||
value, err := b.Bool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode account.saveRingtone#3dea5b03: field unsave: %w", err)
|
||||
}
|
||||
s.Unsave = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetID returns value of ID field.
|
||||
func (s *AccountSaveRingtoneRequest) GetID() (value InputDocumentClass) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
return s.ID
|
||||
}
|
||||
|
||||
// GetUnsave returns value of Unsave field.
|
||||
func (s *AccountSaveRingtoneRequest) GetUnsave() (value bool) {
|
||||
if s == nil {
|
||||
return
|
||||
}
|
||||
return s.Unsave
|
||||
}
|
||||
|
||||
// GetIDAsNotEmpty returns mapped value of ID field.
|
||||
func (s *AccountSaveRingtoneRequest) GetIDAsNotEmpty() (*InputDocument, bool) {
|
||||
return s.ID.AsNotEmpty()
|
||||
}
|
||||
|
||||
// AccountSaveRingtone invokes method account.saveRingtone#3dea5b03 returning error if any.
|
||||
// Save or remove saved notification sound.
|
||||
// If the notification sound is already in MP3 format, account.savedRingtone¹ will be
|
||||
// returned.
|
||||
// Otherwise, it will be automatically converted and a account.savedRingtoneConverted²
|
||||
// will be returned, containing a new document³ object that should be used to refer to
|
||||
// the ringtone from now on (ie when deleting it using the unsave parameter, or when
|
||||
// downloading it).
|
||||
//
|
||||
// Links:
|
||||
// 1. https://core.telegram.org/constructor/account.savedRingtone
|
||||
// 2. https://core.telegram.org/constructor/account.savedRingtoneConverted
|
||||
// 3. https://core.telegram.org/constructor/document
|
||||
//
|
||||
// Possible errors:
|
||||
//
|
||||
// 400 RINGTONE_INVALID: The specified ringtone is invalid.
|
||||
//
|
||||
// See https://core.telegram.org/method/account.saveRingtone for reference.
|
||||
func (c *Client) AccountSaveRingtone(ctx context.Context, request *AccountSaveRingtoneRequest) (AccountSavedRingtoneClass, error) {
|
||||
var result AccountSavedRingtoneBox
|
||||
|
||||
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.SavedRingtone, nil
|
||||
}
|
||||
Reference in New Issue
Block a user