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,466 @@
|
||||
// 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{}
|
||||
)
|
||||
|
||||
// AutoDownloadSettings represents TL type `autoDownloadSettings#3b1813e0`.
|
||||
type AutoDownloadSettings struct {
|
||||
// True, if the auto-download is enabled
|
||||
IsAutoDownloadEnabled bool
|
||||
// The maximum size of a photo file to be auto-downloaded, in bytes
|
||||
MaxPhotoFileSize int32
|
||||
// The maximum size of a video file to be auto-downloaded, in bytes
|
||||
MaxVideoFileSize int64
|
||||
// The maximum size of other file types to be auto-downloaded, in bytes
|
||||
MaxOtherFileSize int64
|
||||
// The maximum suggested bitrate for uploaded videos, in kbit/s
|
||||
VideoUploadBitrate int32
|
||||
// True, if the beginning of video files needs to be preloaded for instant playback
|
||||
PreloadLargeVideos bool
|
||||
// True, if the next audio track needs to be preloaded while the user is listening to an
|
||||
// audio file
|
||||
PreloadNextAudio bool
|
||||
// True, if stories needs to be preloaded
|
||||
PreloadStories bool
|
||||
// True, if "use less data for calls" option needs to be enabled
|
||||
UseLessDataForCalls bool
|
||||
}
|
||||
|
||||
// AutoDownloadSettingsTypeID is TL type id of AutoDownloadSettings.
|
||||
const AutoDownloadSettingsTypeID = 0x3b1813e0
|
||||
|
||||
// Ensuring interfaces in compile-time for AutoDownloadSettings.
|
||||
var (
|
||||
_ bin.Encoder = &AutoDownloadSettings{}
|
||||
_ bin.Decoder = &AutoDownloadSettings{}
|
||||
_ bin.BareEncoder = &AutoDownloadSettings{}
|
||||
_ bin.BareDecoder = &AutoDownloadSettings{}
|
||||
)
|
||||
|
||||
func (a *AutoDownloadSettings) Zero() bool {
|
||||
if a == nil {
|
||||
return true
|
||||
}
|
||||
if !(a.IsAutoDownloadEnabled == false) {
|
||||
return false
|
||||
}
|
||||
if !(a.MaxPhotoFileSize == 0) {
|
||||
return false
|
||||
}
|
||||
if !(a.MaxVideoFileSize == 0) {
|
||||
return false
|
||||
}
|
||||
if !(a.MaxOtherFileSize == 0) {
|
||||
return false
|
||||
}
|
||||
if !(a.VideoUploadBitrate == 0) {
|
||||
return false
|
||||
}
|
||||
if !(a.PreloadLargeVideos == false) {
|
||||
return false
|
||||
}
|
||||
if !(a.PreloadNextAudio == false) {
|
||||
return false
|
||||
}
|
||||
if !(a.PreloadStories == false) {
|
||||
return false
|
||||
}
|
||||
if !(a.UseLessDataForCalls == false) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// String implements fmt.Stringer.
|
||||
func (a *AutoDownloadSettings) String() string {
|
||||
if a == nil {
|
||||
return "AutoDownloadSettings(nil)"
|
||||
}
|
||||
type Alias AutoDownloadSettings
|
||||
return fmt.Sprintf("AutoDownloadSettings%+v", Alias(*a))
|
||||
}
|
||||
|
||||
// TypeID returns type id in TL schema.
|
||||
//
|
||||
// See https://core.telegram.org/mtproto/TL-tl#remarks.
|
||||
func (*AutoDownloadSettings) TypeID() uint32 {
|
||||
return AutoDownloadSettingsTypeID
|
||||
}
|
||||
|
||||
// TypeName returns name of type in TL schema.
|
||||
func (*AutoDownloadSettings) TypeName() string {
|
||||
return "autoDownloadSettings"
|
||||
}
|
||||
|
||||
// TypeInfo returns info about TL type.
|
||||
func (a *AutoDownloadSettings) TypeInfo() tdp.Type {
|
||||
typ := tdp.Type{
|
||||
Name: "autoDownloadSettings",
|
||||
ID: AutoDownloadSettingsTypeID,
|
||||
}
|
||||
if a == nil {
|
||||
typ.Null = true
|
||||
return typ
|
||||
}
|
||||
typ.Fields = []tdp.Field{
|
||||
{
|
||||
Name: "IsAutoDownloadEnabled",
|
||||
SchemaName: "is_auto_download_enabled",
|
||||
},
|
||||
{
|
||||
Name: "MaxPhotoFileSize",
|
||||
SchemaName: "max_photo_file_size",
|
||||
},
|
||||
{
|
||||
Name: "MaxVideoFileSize",
|
||||
SchemaName: "max_video_file_size",
|
||||
},
|
||||
{
|
||||
Name: "MaxOtherFileSize",
|
||||
SchemaName: "max_other_file_size",
|
||||
},
|
||||
{
|
||||
Name: "VideoUploadBitrate",
|
||||
SchemaName: "video_upload_bitrate",
|
||||
},
|
||||
{
|
||||
Name: "PreloadLargeVideos",
|
||||
SchemaName: "preload_large_videos",
|
||||
},
|
||||
{
|
||||
Name: "PreloadNextAudio",
|
||||
SchemaName: "preload_next_audio",
|
||||
},
|
||||
{
|
||||
Name: "PreloadStories",
|
||||
SchemaName: "preload_stories",
|
||||
},
|
||||
{
|
||||
Name: "UseLessDataForCalls",
|
||||
SchemaName: "use_less_data_for_calls",
|
||||
},
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
||||
// Encode implements bin.Encoder.
|
||||
func (a *AutoDownloadSettings) Encode(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't encode autoDownloadSettings#3b1813e0 as nil")
|
||||
}
|
||||
b.PutID(AutoDownloadSettingsTypeID)
|
||||
return a.EncodeBare(b)
|
||||
}
|
||||
|
||||
// EncodeBare implements bin.BareEncoder.
|
||||
func (a *AutoDownloadSettings) EncodeBare(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't encode autoDownloadSettings#3b1813e0 as nil")
|
||||
}
|
||||
b.PutBool(a.IsAutoDownloadEnabled)
|
||||
b.PutInt32(a.MaxPhotoFileSize)
|
||||
b.PutInt53(a.MaxVideoFileSize)
|
||||
b.PutInt53(a.MaxOtherFileSize)
|
||||
b.PutInt32(a.VideoUploadBitrate)
|
||||
b.PutBool(a.PreloadLargeVideos)
|
||||
b.PutBool(a.PreloadNextAudio)
|
||||
b.PutBool(a.PreloadStories)
|
||||
b.PutBool(a.UseLessDataForCalls)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Decode implements bin.Decoder.
|
||||
func (a *AutoDownloadSettings) Decode(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't decode autoDownloadSettings#3b1813e0 to nil")
|
||||
}
|
||||
if err := b.ConsumeID(AutoDownloadSettingsTypeID); err != nil {
|
||||
return fmt.Errorf("unable to decode autoDownloadSettings#3b1813e0: %w", err)
|
||||
}
|
||||
return a.DecodeBare(b)
|
||||
}
|
||||
|
||||
// DecodeBare implements bin.BareDecoder.
|
||||
func (a *AutoDownloadSettings) DecodeBare(b *bin.Buffer) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't decode autoDownloadSettings#3b1813e0 to nil")
|
||||
}
|
||||
{
|
||||
value, err := b.Bool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode autoDownloadSettings#3b1813e0: field is_auto_download_enabled: %w", err)
|
||||
}
|
||||
a.IsAutoDownloadEnabled = value
|
||||
}
|
||||
{
|
||||
value, err := b.Int32()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode autoDownloadSettings#3b1813e0: field max_photo_file_size: %w", err)
|
||||
}
|
||||
a.MaxPhotoFileSize = value
|
||||
}
|
||||
{
|
||||
value, err := b.Int53()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode autoDownloadSettings#3b1813e0: field max_video_file_size: %w", err)
|
||||
}
|
||||
a.MaxVideoFileSize = value
|
||||
}
|
||||
{
|
||||
value, err := b.Int53()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode autoDownloadSettings#3b1813e0: field max_other_file_size: %w", err)
|
||||
}
|
||||
a.MaxOtherFileSize = value
|
||||
}
|
||||
{
|
||||
value, err := b.Int32()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode autoDownloadSettings#3b1813e0: field video_upload_bitrate: %w", err)
|
||||
}
|
||||
a.VideoUploadBitrate = value
|
||||
}
|
||||
{
|
||||
value, err := b.Bool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode autoDownloadSettings#3b1813e0: field preload_large_videos: %w", err)
|
||||
}
|
||||
a.PreloadLargeVideos = value
|
||||
}
|
||||
{
|
||||
value, err := b.Bool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode autoDownloadSettings#3b1813e0: field preload_next_audio: %w", err)
|
||||
}
|
||||
a.PreloadNextAudio = value
|
||||
}
|
||||
{
|
||||
value, err := b.Bool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode autoDownloadSettings#3b1813e0: field preload_stories: %w", err)
|
||||
}
|
||||
a.PreloadStories = value
|
||||
}
|
||||
{
|
||||
value, err := b.Bool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode autoDownloadSettings#3b1813e0: field use_less_data_for_calls: %w", err)
|
||||
}
|
||||
a.UseLessDataForCalls = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
|
||||
func (a *AutoDownloadSettings) EncodeTDLibJSON(b tdjson.Encoder) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't encode autoDownloadSettings#3b1813e0 as nil")
|
||||
}
|
||||
b.ObjStart()
|
||||
b.PutID("autoDownloadSettings")
|
||||
b.Comma()
|
||||
b.FieldStart("is_auto_download_enabled")
|
||||
b.PutBool(a.IsAutoDownloadEnabled)
|
||||
b.Comma()
|
||||
b.FieldStart("max_photo_file_size")
|
||||
b.PutInt32(a.MaxPhotoFileSize)
|
||||
b.Comma()
|
||||
b.FieldStart("max_video_file_size")
|
||||
b.PutInt53(a.MaxVideoFileSize)
|
||||
b.Comma()
|
||||
b.FieldStart("max_other_file_size")
|
||||
b.PutInt53(a.MaxOtherFileSize)
|
||||
b.Comma()
|
||||
b.FieldStart("video_upload_bitrate")
|
||||
b.PutInt32(a.VideoUploadBitrate)
|
||||
b.Comma()
|
||||
b.FieldStart("preload_large_videos")
|
||||
b.PutBool(a.PreloadLargeVideos)
|
||||
b.Comma()
|
||||
b.FieldStart("preload_next_audio")
|
||||
b.PutBool(a.PreloadNextAudio)
|
||||
b.Comma()
|
||||
b.FieldStart("preload_stories")
|
||||
b.PutBool(a.PreloadStories)
|
||||
b.Comma()
|
||||
b.FieldStart("use_less_data_for_calls")
|
||||
b.PutBool(a.UseLessDataForCalls)
|
||||
b.Comma()
|
||||
b.StripComma()
|
||||
b.ObjEnd()
|
||||
return nil
|
||||
}
|
||||
|
||||
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
|
||||
func (a *AutoDownloadSettings) DecodeTDLibJSON(b tdjson.Decoder) error {
|
||||
if a == nil {
|
||||
return fmt.Errorf("can't decode autoDownloadSettings#3b1813e0 to nil")
|
||||
}
|
||||
|
||||
return b.Obj(func(b tdjson.Decoder, key []byte) error {
|
||||
switch string(key) {
|
||||
case tdjson.TypeField:
|
||||
if err := b.ConsumeID("autoDownloadSettings"); err != nil {
|
||||
return fmt.Errorf("unable to decode autoDownloadSettings#3b1813e0: %w", err)
|
||||
}
|
||||
case "is_auto_download_enabled":
|
||||
value, err := b.Bool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode autoDownloadSettings#3b1813e0: field is_auto_download_enabled: %w", err)
|
||||
}
|
||||
a.IsAutoDownloadEnabled = value
|
||||
case "max_photo_file_size":
|
||||
value, err := b.Int32()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode autoDownloadSettings#3b1813e0: field max_photo_file_size: %w", err)
|
||||
}
|
||||
a.MaxPhotoFileSize = value
|
||||
case "max_video_file_size":
|
||||
value, err := b.Int53()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode autoDownloadSettings#3b1813e0: field max_video_file_size: %w", err)
|
||||
}
|
||||
a.MaxVideoFileSize = value
|
||||
case "max_other_file_size":
|
||||
value, err := b.Int53()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode autoDownloadSettings#3b1813e0: field max_other_file_size: %w", err)
|
||||
}
|
||||
a.MaxOtherFileSize = value
|
||||
case "video_upload_bitrate":
|
||||
value, err := b.Int32()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode autoDownloadSettings#3b1813e0: field video_upload_bitrate: %w", err)
|
||||
}
|
||||
a.VideoUploadBitrate = value
|
||||
case "preload_large_videos":
|
||||
value, err := b.Bool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode autoDownloadSettings#3b1813e0: field preload_large_videos: %w", err)
|
||||
}
|
||||
a.PreloadLargeVideos = value
|
||||
case "preload_next_audio":
|
||||
value, err := b.Bool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode autoDownloadSettings#3b1813e0: field preload_next_audio: %w", err)
|
||||
}
|
||||
a.PreloadNextAudio = value
|
||||
case "preload_stories":
|
||||
value, err := b.Bool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode autoDownloadSettings#3b1813e0: field preload_stories: %w", err)
|
||||
}
|
||||
a.PreloadStories = value
|
||||
case "use_less_data_for_calls":
|
||||
value, err := b.Bool()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode autoDownloadSettings#3b1813e0: field use_less_data_for_calls: %w", err)
|
||||
}
|
||||
a.UseLessDataForCalls = value
|
||||
default:
|
||||
return b.Skip()
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// GetIsAutoDownloadEnabled returns value of IsAutoDownloadEnabled field.
|
||||
func (a *AutoDownloadSettings) GetIsAutoDownloadEnabled() (value bool) {
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
return a.IsAutoDownloadEnabled
|
||||
}
|
||||
|
||||
// GetMaxPhotoFileSize returns value of MaxPhotoFileSize field.
|
||||
func (a *AutoDownloadSettings) GetMaxPhotoFileSize() (value int32) {
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
return a.MaxPhotoFileSize
|
||||
}
|
||||
|
||||
// GetMaxVideoFileSize returns value of MaxVideoFileSize field.
|
||||
func (a *AutoDownloadSettings) GetMaxVideoFileSize() (value int64) {
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
return a.MaxVideoFileSize
|
||||
}
|
||||
|
||||
// GetMaxOtherFileSize returns value of MaxOtherFileSize field.
|
||||
func (a *AutoDownloadSettings) GetMaxOtherFileSize() (value int64) {
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
return a.MaxOtherFileSize
|
||||
}
|
||||
|
||||
// GetVideoUploadBitrate returns value of VideoUploadBitrate field.
|
||||
func (a *AutoDownloadSettings) GetVideoUploadBitrate() (value int32) {
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
return a.VideoUploadBitrate
|
||||
}
|
||||
|
||||
// GetPreloadLargeVideos returns value of PreloadLargeVideos field.
|
||||
func (a *AutoDownloadSettings) GetPreloadLargeVideos() (value bool) {
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
return a.PreloadLargeVideos
|
||||
}
|
||||
|
||||
// GetPreloadNextAudio returns value of PreloadNextAudio field.
|
||||
func (a *AutoDownloadSettings) GetPreloadNextAudio() (value bool) {
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
return a.PreloadNextAudio
|
||||
}
|
||||
|
||||
// GetPreloadStories returns value of PreloadStories field.
|
||||
func (a *AutoDownloadSettings) GetPreloadStories() (value bool) {
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
return a.PreloadStories
|
||||
}
|
||||
|
||||
// GetUseLessDataForCalls returns value of UseLessDataForCalls field.
|
||||
func (a *AutoDownloadSettings) GetUseLessDataForCalls() (value bool) {
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
return a.UseLessDataForCalls
|
||||
}
|
||||
Reference in New Issue
Block a user