diff --git a/FAQ.md b/FAQ.md index 5e3dea8..0b4d1c5 100644 --- a/FAQ.md +++ b/FAQ.md @@ -292,6 +292,8 @@ Here are the recommended actions to fix your problem: } ``` +Also, remember to add a `using TL;` at the top of your files to have access to all the Telegram API methods. + ## Troubleshooting guide diff --git a/src/SecretChats.cs b/src/SecretChats.cs index 701619f..8065b5f 100644 --- a/src/SecretChats.cs +++ b/src/SecretChats.cs @@ -588,12 +588,8 @@ namespace WTelegram fingerprint ^= fingerprint >> 32; using var ige = new AES_IGE_Stream(stream, aes_key, aes_iv, true); - return await client.UploadFileAsync(ige, null, progress) switch - { - InputFile ifl => new InputEncryptedFileUploaded { id = ifl.id, parts = ifl.parts, md5_checksum = ifl.md5_checksum, key_fingerprint = (int)fingerprint }, - InputFileBig ifb => new InputEncryptedFileBigUploaded { id = ifb.id, parts = ifb.parts, key_fingerprint = (int)fingerprint }, - _ => null - }; + var inputFile = await client.UploadFileAsync(ige, null, progress); + return inputFile.ToInputEncryptedFile((int)fingerprint); } /// Download and decrypt an encrypted file from Telegram Secret Chat into the outputStream diff --git a/src/TL.Helpers.cs b/src/TL.Helpers.cs index aad124b..529ec5d 100644 --- a/src/TL.Helpers.cs +++ b/src/TL.Helpers.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.IO; using System.Linq; using System.Text; using System.Web; @@ -57,6 +58,14 @@ namespace TL { public abstract InputEncryptedFileBase ToInputEncryptedFile(int key_fingerprint); public abstract InputSecureFileBase ToInputSecureFile(byte[] file_hash, byte[] secret); + /// for a profile photo. for auto-detection
for a profile video. The video MUST be square and 10 seconds max + public InputChatUploadedPhoto ToInputChatPhoto(bool? isSquareVideo10s = null) + { + if (isSquareVideo10s ?? Path.GetExtension(Name)?.ToLowerInvariant() is ".mp4") + return new InputChatUploadedPhoto { video = this, flags = InputChatUploadedPhoto.Flags.has_video }; + else + return new InputChatUploadedPhoto { file = this, flags = InputChatUploadedPhoto.Flags.has_file }; + } } partial class InputFile {