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,317 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// AccountUploadThemeRequest represents TL type `account.uploadTheme#1c3db333`.
|
||||
// Upload theme
|
||||
//
|
||||
// See https://core.telegram.org/method/account.uploadTheme for reference.
|
||||
type AccountUploadThemeRequest struct {
|
||||
// Flags, see TL conditional fields¹
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
|
||||
Flags bin.Fields
|
||||
// Previously uploaded¹ theme file with platform-specific colors for UI components, can
|
||||
// be left unset when creating themes that only modify the wallpaper or accent colors.
|
||||
//
|
||||
// Links:
|
||||
// 1) https://core.telegram.org/api/themes#uploading-theme-files
|
||||
File InputFileClass
|
||||
// Thumbnail
|
||||
//
|
||||
// Use SetThumb and GetThumb helpers.
|
||||
Thumb InputFileClass
|
||||
// File name
|
||||
FileName string
|
||||
// MIME type, must be application/x-tgtheme-{format}, where format depends on the client
|
||||
MimeType string
|
||||
}
|
||||
|
||||
// AccountUploadThemeRequestTypeID is TL type id of AccountUploadThemeRequest.
|
||||
const AccountUploadThemeRequestTypeID = 0x1c3db333
|
||||
|
||||
// Ensuring interfaces in compile-time for AccountUploadThemeRequest.
|
||||
var (
|
||||
_ bin.Encoder = &AccountUploadThemeRequest{}
|
||||
_ bin.Decoder = &AccountUploadThemeRequest{}
|
||||
_ bin.BareEncoder = &AccountUploadThemeRequest{}
|
||||
_ bin.BareDecoder = &AccountUploadThemeRequest{}
|
||||
)
|
||||
|
||||
func (u *AccountUploadThemeRequest) Zero() bool {
|
||||
if u == nil {
|
||||
return true
|
||||
}
|
||||
if !(u.Flags.Zero()) {
|
||||
return false
|
||||
}
|
||||
if !(u.File == nil) {
|
||||
return false
|
||||
}
|
||||
if !(u.Thumb == nil) {
|
||||
return false
|
||||
}
|
||||
if !(u.FileName == "") {
|
||||
return false
|
||||
}
|
||||
if !(u.MimeType == "") {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (u *AccountUploadThemeRequest) String() string {
|
||||
if u == nil {
|
||||
return "AccountUploadThemeRequest(nil)"
|
||||
}
|
||||
type Alias AccountUploadThemeRequest
|
||||
return fmt.Sprintf("AccountUploadThemeRequest%+v", Alias(*u))
|
||||
}
|
||||
|
||||
// FillFrom fills AccountUploadThemeRequest from given interface.
|
||||
func (u *AccountUploadThemeRequest) FillFrom(from interface {
|
||||
GetFile() (value InputFileClass)
|
||||
GetThumb() (value InputFileClass, ok bool)
|
||||
GetFileName() (value string)
|
||||
GetMimeType() (value string)
|
||||
}) {
|
||||
u.File = from.GetFile()
|
||||
if val, ok := from.GetThumb(); ok {
|
||||
u.Thumb = val
|
||||
}
|
||||
|
||||
u.FileName = from.GetFileName()
|
||||
u.MimeType = from.GetMimeType()
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*AccountUploadThemeRequest) TypeID() uint32 {
|
||||
return AccountUploadThemeRequestTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*AccountUploadThemeRequest) TypeName() string {
|
||||
return "account.uploadTheme"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (u *AccountUploadThemeRequest) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "account.uploadTheme",
|
||||
ID: AccountUploadThemeRequestTypeID,
|
||||
}
|
||||
if u == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "File",
|
||||
SchemaName: "file",
|
||||
},
|
||||
{
|
||||
Name: "Thumb",
|
||||
SchemaName: "thumb",
|
||||
Null: !u.Flags.Has(0),
|
||||
},
|
||||
{
|
||||
Name: "FileName",
|
||||
SchemaName: "file_name",
|
||||
},
|
||||
{
|
||||
Name: "MimeType",
|
||||
SchemaName: "mime_type",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// SetFlags sets flags for non-zero fields.
|
||||
func (u *AccountUploadThemeRequest) SetFlags() {
|
||||
if !(u.Thumb == nil) {
|
||||
u.Flags.Set(0)
|
||||
}
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (u *AccountUploadThemeRequest) Encode(b *bin.Buffer) error {
|
||||
if u == nil {
|
||||
return fmt.Errorf("can't encode account.uploadTheme#1c3db333 as nil")
|
||||
}
|
||||
b.PutID(AccountUploadThemeRequestTypeID)
|
||||
return u.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (u *AccountUploadThemeRequest) EncodeBare(b *bin.Buffer) error {
|
||||
if u == nil {
|
||||
return fmt.Errorf("can't encode account.uploadTheme#1c3db333 as nil")
|
||||
}
|
||||
u.SetFlags()
|
||||
if err := u.Flags.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode account.uploadTheme#1c3db333: field flags: %w", err)
|
||||
}
|
||||
if u.File == nil {
|
||||
return fmt.Errorf("unable to encode account.uploadTheme#1c3db333: field file is nil")
|
||||
}
|
||||
if err := u.File.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode account.uploadTheme#1c3db333: field file: %w", err)
|
||||
}
|
||||
if u.Flags.Has(0) {
|
||||
if u.Thumb == nil {
|
||||
return fmt.Errorf("unable to encode account.uploadTheme#1c3db333: field thumb is nil")
|
||||
}
|
||||
if err := u.Thumb.Encode(b); err != nil {
|
||||
return fmt.Errorf("unable to encode account.uploadTheme#1c3db333: field thumb: %w", err)
|
||||
}
|
||||
}
|
||||
b.PutString(u.FileName)
|
||||
b.PutString(u.MimeType)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (u *AccountUploadThemeRequest) Decode(b *bin.Buffer) error {
|
||||
if u == nil {
|
||||
return fmt.Errorf("can't decode account.uploadTheme#1c3db333 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(AccountUploadThemeRequestTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode account.uploadTheme#1c3db333: %w", err)
|
||||
}
|
||||
return u.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (u *AccountUploadThemeRequest) DecodeBare(b *bin.Buffer) error {
|
||||
if u == nil {
|
||||
return fmt.Errorf("can't decode account.uploadTheme#1c3db333 to nil")
|
||||
}
|
||||
{
|
||||
if err := u.Flags.Decode(b); err != nil {
|
||||
return fmt.Errorf("unable to decode account.uploadTheme#1c3db333: field flags: %w", err)
|
||||
}
|
||||
}
|
||||
{
|
||||
value, err := DecodeInputFile(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode account.uploadTheme#1c3db333: field file: %w", err)
|
||||
}
|
||||
u.File = value
|
||||
}
|
||||
if u.Flags.Has(0) {
|
||||
value, err := DecodeInputFile(b)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode account.uploadTheme#1c3db333: field thumb: %w", err)
|
||||
}
|
||||
u.Thumb = value
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode account.uploadTheme#1c3db333: field file_name: %w", err)
|
||||
}
|
||||
u.FileName = value
|
||||
}
|
||||
{
|
||||
value, err := b.String()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode account.uploadTheme#1c3db333: field mime_type: %w", err)
|
||||
}
|
||||
u.MimeType = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetFile returns value of File field.
|
||||
func (u *AccountUploadThemeRequest) GetFile() (value InputFileClass) {
|
||||
if u == nil {
|
||||
return
|
||||
}
|
||||
return u.File
|
||||
}
|
||||
|
||||
// SetThumb sets value of Thumb conditional field.
|
||||
func (u *AccountUploadThemeRequest) SetThumb(value InputFileClass) {
|
||||
u.Flags.Set(0)
|
||||
u.Thumb = value
|
||||
}
|
||||
|
||||
// GetThumb returns value of Thumb conditional field and
|
||||
// boolean which is true if field was set.
|
||||
func (u *AccountUploadThemeRequest) GetThumb() (value InputFileClass, ok bool) {
|
||||
if u == nil {
|
||||
return
|
||||
}
|
||||
if !u.Flags.Has(0) {
|
||||
return value, false
|
||||
}
|
||||
return u.Thumb, true
|
||||
}
|
||||
|
||||
// GetFileName returns value of FileName field.
|
||||
func (u *AccountUploadThemeRequest) GetFileName() (value string) {
|
||||
if u == nil {
|
||||
return
|
||||
}
|
||||
return u.FileName
|
||||
}
|
||||
|
||||
// GetMimeType returns value of MimeType field.
|
||||
func (u *AccountUploadThemeRequest) GetMimeType() (value string) {
|
||||
if u == nil {
|
||||
return
|
||||
}
|
||||
return u.MimeType
|
||||
}
|
||||
|
||||
// AccountUploadTheme invokes method account.uploadTheme#1c3db333 returning error if any.
|
||||
// Upload theme
|
||||
//
|
||||
// Possible errors:
|
||||
//
|
||||
// 400 THEME_FILE_INVALID: Invalid theme file provided.
|
||||
// 400 THEME_MIME_INVALID: The theme's MIME type is invalid.
|
||||
//
|
||||
// See https://core.telegram.org/method/account.uploadTheme for reference.
|
||||
func (c *Client) AccountUploadTheme(ctx context.Context, request *AccountUploadThemeRequest) (DocumentClass, error) {
|
||||
var result DocumentBox
|
||||
|
||||
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.Document, nil
|
||||
}
|
||||
Reference in New Issue
Block a user