mirror of
https://github.com/sochix/TLSharp.git
synced 2025-12-06 08:02:00 +01:00
commit
49bce93523
52
README.md
52
README.md
|
|
@ -20,6 +20,7 @@ It's a perfect fit for any developer who would like to send data directly to Tel
|
||||||
- [Starter Guide](#starter-guide)
|
- [Starter Guide](#starter-guide)
|
||||||
- [Quick configuration](#quick-configuration)
|
- [Quick configuration](#quick-configuration)
|
||||||
- [First requests](#first-requests)
|
- [First requests](#first-requests)
|
||||||
|
- [Working with files](#working-with-files)
|
||||||
- [Available Methods](#available-methods)
|
- [Available Methods](#available-methods)
|
||||||
- [Contributing](#contributing)
|
- [Contributing](#contributing)
|
||||||
- [FAQ](#faq)
|
- [FAQ](#faq)
|
||||||
|
|
@ -33,7 +34,7 @@ Library _almost_ ready for production usage. We need contributors to make 1.0.0
|
||||||
To use TLSharp follow next steps:
|
To use TLSharp follow next steps:
|
||||||
|
|
||||||
1. Clone TLSharp from GitHub
|
1. Clone TLSharp from GitHub
|
||||||
1. Compile source with VS2015
|
1. Compile source with VS2015 or MonoDevelop
|
||||||
1. Add reference to ```TLSharp.Core.dll``` to your awesome project.
|
1. Add reference to ```TLSharp.Core.dll``` to your awesome project.
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
|
@ -104,8 +105,41 @@ To send message to channel you could use the following code:
|
||||||
await client.SendMessageAsync(new TLInputPeerChannel() { channel_id = chat.id, access_hash = chat.access_hash.Value }, "OUR_MESSAGE");
|
await client.SendMessageAsync(new TLInputPeerChannel() { channel_id = chat.id, access_hash = chat.access_hash.Value }, "OUR_MESSAGE");
|
||||||
```
|
```
|
||||||
Full code you can see at [SendMessageToChannel test](https://github.com/sochix/TLSharp/blob/master/TLSharp.Tests/TLSharpTests.cs#L107)
|
Full code you can see at [SendMessageToChannel test](https://github.com/sochix/TLSharp/blob/master/TLSharp.Tests/TLSharpTests.cs#L107)
|
||||||
|
## Working with files
|
||||||
|
Telegram separate files to two categories -> big file and small file. File is Big if its size more than 10 Mb. TLSharp tries to hide this complexity from you, thats why we provide one method to upload files **UploadFile**.
|
||||||
|
|
||||||
## Available Methods
|
```csharp
|
||||||
|
var fileResult = await client.UploadFile("cat.jpg", new StreamReader("data/cat.jpg"));
|
||||||
|
```
|
||||||
|
|
||||||
|
TLSharp provides two wrappers for sending photo and document
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
await client.SendUploadedPhoto(new TLInputPeerUser() { user_id = user.id }, fileResult, "kitty");
|
||||||
|
await client.SendUploadedDocument(
|
||||||
|
new TLInputPeerUser() { user_id = user.id },
|
||||||
|
fileResult,
|
||||||
|
"some zips", //caption
|
||||||
|
"application/zip", //mime-type
|
||||||
|
new TLVector<TLAbsDocumentAttribute>()); //document attributes, such as file name
|
||||||
|
```
|
||||||
|
Full code you can see at [SendPhotoToContactTest](https://github.com/sochix/TLSharp/blob/master/TLSharp.Tests/TLSharpTests.cs#L125) and [SendBigFileToContactTest](https://github.com/sochix/TLSharp/blob/master/TLSharp.Tests/TLSharpTests.cs#L143)
|
||||||
|
|
||||||
|
To download file you should call **GetFile** method
|
||||||
|
```csharp
|
||||||
|
await client.GetFile(
|
||||||
|
new TLInputDocumentFileLocation()
|
||||||
|
{
|
||||||
|
access_hash = document.access_hash,
|
||||||
|
id = document.id,
|
||||||
|
version = document.version
|
||||||
|
},
|
||||||
|
document.size); //size of fileChunk you want to retrieve
|
||||||
|
```
|
||||||
|
|
||||||
|
Full code you can see at [DownloadFileFromContactTest](https://github.com/sochix/TLSharp/blob/master/TLSharp.Tests/TLSharpTests.cs#L167)
|
||||||
|
|
||||||
|
# Available Methods
|
||||||
|
|
||||||
For your convenience TLSharp have wrappers for several Telegram API methods. You could add your own, see details below.
|
For your convenience TLSharp have wrappers for several Telegram API methods. You could add your own, see details below.
|
||||||
|
|
||||||
|
|
@ -117,6 +151,10 @@ For your convenience TLSharp have wrappers for several Telegram API methods. You
|
||||||
1. SendMessageAsync
|
1. SendMessageAsync
|
||||||
1. SendTypingAsync
|
1. SendTypingAsync
|
||||||
1. GetUserDialogsAsync
|
1. GetUserDialogsAsync
|
||||||
|
1. SendUploadedPhoto
|
||||||
|
1. SendUploadedDocument
|
||||||
|
1. GetFile
|
||||||
|
1. UploadFile
|
||||||
|
|
||||||
**What if you can't find needed method at the list?**
|
**What if you can't find needed method at the list?**
|
||||||
|
|
||||||
|
|
@ -140,18 +178,19 @@ Don't panic. You can call any method with help of `SendRequestAsync` function. F
|
||||||
The only way is [Telegram API docs](https://core.telegram.org/methods). Yes, it's outdated. But there is no other source.
|
The only way is [Telegram API docs](https://core.telegram.org/methods). Yes, it's outdated. But there is no other source.
|
||||||
Latest scheme in JSON format you can find [here](https://gist.github.com/aarani/b22b7cda024973dff68e1672794b0298)
|
Latest scheme in JSON format you can find [here](https://gist.github.com/aarani/b22b7cda024973dff68e1672794b0298)
|
||||||
|
|
||||||
## Contributing
|
# Contributing
|
||||||
|
|
||||||
Contributing is highly appreciated!
|
Contributing is highly appreciated!
|
||||||
|
|
||||||
### What things can I Implement (Project Roadmap)?
|
## What things can I Implement (Project Roadmap)?
|
||||||
|
|
||||||
#### Release 1.0.0
|
### Release 1.0.0
|
||||||
|
|
||||||
* [DONE] Add PHONE_MIGRATE handling
|
* [DONE] Add PHONE_MIGRATE handling
|
||||||
|
* Add FILE_MIGRATE handling
|
||||||
* Add Updates handling
|
* Add Updates handling
|
||||||
* Add NuGet package
|
* Add NuGet package
|
||||||
* [WIP] Add wrappers for media uploading
|
* [DONE] Add wrappers for media uploading and downloading
|
||||||
* Store user session as JSON
|
* Store user session as JSON
|
||||||
|
|
||||||
# FAQ
|
# FAQ
|
||||||
|
|
@ -194,6 +233,7 @@ List of donators:
|
||||||
|
|
||||||
# Contributors
|
# Contributors
|
||||||
* [Afshin Arani](http://aarani.ir) - TLGenerator, and a lot of other usefull things
|
* [Afshin Arani](http://aarani.ir) - TLGenerator, and a lot of other usefull things
|
||||||
|
* [Knocte](https://github.com/knocte)
|
||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -279,9 +279,7 @@ namespace TLSharp.Core.Network
|
||||||
{
|
{
|
||||||
var resultString = Regex.Match(errorMessage, @"\d+").Value;
|
var resultString = Regex.Match(errorMessage, @"\d+").Value;
|
||||||
var dcIdx = int.Parse(resultString);
|
var dcIdx = int.Parse(resultString);
|
||||||
var exception = new InvalidOperationException($"Your phone number registered to {dcIdx} dc. Please update settings. See https://github.com/sochix/TLSharp#i-get-an-error-migrate_x for details.");
|
throw new MigrationNeededException(dcIdx);
|
||||||
exception.Data.Add("dcId", dcIdx);
|
|
||||||
throw exception;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -338,9 +336,9 @@ namespace TLSharp.Core.Network
|
||||||
switch (errorCode)
|
switch (errorCode)
|
||||||
{
|
{
|
||||||
case 16:
|
case 16:
|
||||||
throw new InvalidOperationException(" msg_id too low (most likely, client time is wrong; it would be worthwhile to synchronize it using msg_id notifications and re-send the original message with the “correct” msg_id or wrap it in a container with a new msg_id if the original message had waited too long on the client to be transmitted)");
|
throw new InvalidOperationException("msg_id too low (most likely, client time is wrong; it would be worthwhile to synchronize it using msg_id notifications and re-send the original message with the “correct” msg_id or wrap it in a container with a new msg_id if the original message had waited too long on the client to be transmitted)");
|
||||||
case 17:
|
case 17:
|
||||||
throw new InvalidOperationException(" msg_id too high (similar to the previous case, the client time has to be synchronized, and the message re-sent with the correct msg_id)");
|
throw new InvalidOperationException("msg_id too high (similar to the previous case, the client time has to be synchronized, and the message re-sent with the correct msg_id)");
|
||||||
case 18:
|
case 18:
|
||||||
throw new InvalidOperationException("incorrect two lower order msg_id bits (the server expects client message msg_id to be divisible by 4)");
|
throw new InvalidOperationException("incorrect two lower order msg_id bits (the server expects client message msg_id to be divisible by 4)");
|
||||||
case 19:
|
case 19:
|
||||||
|
|
@ -484,4 +482,15 @@ namespace TLSharp.Core.Network
|
||||||
return new MemoryStream(new byte[len], 0, len, true, true);
|
return new MemoryStream(new byte[len], 0, len, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal class MigrationNeededException : Exception
|
||||||
|
{
|
||||||
|
internal int DC { get; private set; }
|
||||||
|
|
||||||
|
internal MigrationNeededException(int dc)
|
||||||
|
: base ($"Your phone number is registered to a different DC: {dc}. Please migrate.")
|
||||||
|
{
|
||||||
|
DC = dc;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,118 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
using TeleSharp.TL.Upload;
|
|
||||||
namespace TLSharp.Core.Requests
|
|
||||||
{
|
|
||||||
public class UploadHelper
|
|
||||||
{
|
|
||||||
public static async Task<TLAbsInputFile> Uploader(string name,StreamReader reader,TelegramClient client)
|
|
||||||
{
|
|
||||||
if (reader.BaseStream.Length < 10 * 1024 * 1024)
|
|
||||||
return await SmallFileUpload(name, reader, client);
|
|
||||||
else
|
|
||||||
return await BigFileUpload(name, reader, client);
|
|
||||||
}
|
|
||||||
private static async Task<TLInputFile> SmallFileUpload(string name, StreamReader reader, TelegramClient client)
|
|
||||||
{
|
|
||||||
var file = new byte[reader.BaseStream.Length];
|
|
||||||
reader.BaseStream.Read(file, 0, (int)reader.BaseStream.Length);
|
|
||||||
string hash;
|
|
||||||
using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider())
|
|
||||||
{
|
|
||||||
hash = Convert.ToBase64String(md5.ComputeHash(file));
|
|
||||||
}
|
|
||||||
reader = null;
|
|
||||||
var stream = new MemoryStream(file);
|
|
||||||
Queue<byte[]> parts = new Queue<byte[]>();
|
|
||||||
while (!(stream.Position == stream.Length))
|
|
||||||
{
|
|
||||||
if ((stream.Length - stream.Position) > 512 *1024)
|
|
||||||
{
|
|
||||||
byte[] temp = new byte[512];
|
|
||||||
stream.Read(temp, 0, 512 * 1024);
|
|
||||||
parts.Enqueue(temp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
byte[] temp = new byte[512];
|
|
||||||
stream.Read(temp, 0, (int)(stream.Length - stream.Position));
|
|
||||||
parts.Enqueue(temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stream = null;
|
|
||||||
int partnumber = 0;
|
|
||||||
long file_id = BitConverter.ToInt64(RandomByteArray(8), 0);
|
|
||||||
while (parts.Count != 0)
|
|
||||||
{
|
|
||||||
var part = parts.Dequeue();
|
|
||||||
TLRequestSaveFilePart save = new TLRequestSaveFilePart();
|
|
||||||
save.file_id = file_id;
|
|
||||||
save.file_part = partnumber;
|
|
||||||
save.bytes = part;
|
|
||||||
await client.SendRequestAsync<bool>(save);
|
|
||||||
partnumber++;
|
|
||||||
}
|
|
||||||
TLInputFile returnFile = new TLInputFile();
|
|
||||||
returnFile.id = file_id;
|
|
||||||
returnFile.name = name;
|
|
||||||
returnFile.parts = parts.Count;
|
|
||||||
returnFile.md5_checksum = hash;
|
|
||||||
return returnFile;
|
|
||||||
}
|
|
||||||
private static async Task<TLInputFileBig> BigFileUpload(string name, StreamReader reader, TelegramClient client)
|
|
||||||
{
|
|
||||||
var file = new byte[reader.BaseStream.Length];
|
|
||||||
reader.BaseStream.Read(file, 0, (int)reader.BaseStream.Length);
|
|
||||||
reader = null;
|
|
||||||
var stream = new MemoryStream(file);
|
|
||||||
Queue<byte[]> parts = new Queue<byte[]>();
|
|
||||||
while (!(stream.Position == stream.Length))
|
|
||||||
{
|
|
||||||
if ((stream.Length - stream.Position) > 512 * 1024)
|
|
||||||
{
|
|
||||||
byte[] temp = new byte[512];
|
|
||||||
stream.Read(temp, 0, 512 * 1024);
|
|
||||||
parts.Enqueue(temp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
byte[] temp = new byte[512];
|
|
||||||
stream.Read(temp, 0, (int)(stream.Length - stream.Position));
|
|
||||||
parts.Enqueue(temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stream = null;
|
|
||||||
int partnumber = 0;
|
|
||||||
long file_id = BitConverter.ToInt64(RandomByteArray(8), 0);
|
|
||||||
while (parts.Count != 0)
|
|
||||||
{
|
|
||||||
var part = parts.Dequeue();
|
|
||||||
TLRequestSaveBigFilePart save = new TLRequestSaveBigFilePart();
|
|
||||||
save.file_id = file_id;
|
|
||||||
save.file_part = partnumber;
|
|
||||||
save.bytes = part;
|
|
||||||
save.file_total_parts = parts.Count;
|
|
||||||
await client.SendRequestAsync<bool>(save);
|
|
||||||
partnumber++;
|
|
||||||
}
|
|
||||||
TLInputFileBig returnFile = new TLInputFileBig();
|
|
||||||
returnFile.id = file_id;
|
|
||||||
returnFile.name = name;
|
|
||||||
returnFile.parts = parts.Count;
|
|
||||||
return returnFile;
|
|
||||||
}
|
|
||||||
private static byte[] RandomByteArray(int count)
|
|
||||||
{
|
|
||||||
var temp = new byte[count];
|
|
||||||
Random random = new Random();
|
|
||||||
random.NextBytes(temp);
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>TLSharp.Core</RootNamespace>
|
<RootNamespace>TLSharp.Core</RootNamespace>
|
||||||
<AssemblyName>TLSharp.Core</AssemblyName>
|
<AssemblyName>TLSharp.Core</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
|
@ -63,7 +63,7 @@
|
||||||
<Compile Include="Network\TcpTransport.cs" />
|
<Compile Include="Network\TcpTransport.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Requests\AckRequest.cs" />
|
<Compile Include="Requests\AckRequest.cs" />
|
||||||
<Compile Include="Requests\UploadHelper.cs" />
|
<Compile Include="Utils\UploadHelper.cs" />
|
||||||
<Compile Include="Session.cs" />
|
<Compile Include="Session.cs" />
|
||||||
<Compile Include="TelegramClient.cs" />
|
<Compile Include="TelegramClient.cs" />
|
||||||
<Compile Include="Utils\Helpers.cs" />
|
<Compile Include="Utils\Helpers.cs" />
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,18 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Web;
|
||||||
using TeleSharp.TL;
|
using TeleSharp.TL;
|
||||||
using TeleSharp.TL.Auth;
|
using TeleSharp.TL.Auth;
|
||||||
using TeleSharp.TL.Contacts;
|
using TeleSharp.TL.Contacts;
|
||||||
using TeleSharp.TL.Help;
|
using TeleSharp.TL.Help;
|
||||||
using TeleSharp.TL.Messages;
|
using TeleSharp.TL.Messages;
|
||||||
|
using TeleSharp.TL.Upload;
|
||||||
using TLSharp.Core.Auth;
|
using TLSharp.Core.Auth;
|
||||||
using TLSharp.Core.MTProto.Crypto;
|
using TLSharp.Core.MTProto.Crypto;
|
||||||
using TLSharp.Core.Network;
|
using TLSharp.Core.Network;
|
||||||
|
using TLSharp.Core.Requests;
|
||||||
|
using TLSharp.Core.Utils;
|
||||||
|
|
||||||
namespace TLSharp.Core
|
namespace TLSharp.Core
|
||||||
{
|
{
|
||||||
|
|
@ -31,11 +35,11 @@ namespace TLSharp.Core
|
||||||
TLContext.Init();
|
TLContext.Init();
|
||||||
_apiHash = apiHash;
|
_apiHash = apiHash;
|
||||||
_apiId = apiId;
|
_apiId = apiId;
|
||||||
if (_apiId == 0)
|
if (_apiId == default(int))
|
||||||
throw new InvalidOperationException("Your API_ID is invalid. Do a configuration first https://github.com/sochix/TLSharp#quick-configuration");
|
throw new MissingApiConfigurationException("API_ID");
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(_apiHash))
|
if (string.IsNullOrEmpty(_apiHash))
|
||||||
throw new InvalidOperationException("Your API_ID is invalid. Do a configuration first https://github.com/sochix/TLSharp#quick-configuration");
|
throw new MissingApiConfigurationException("API_HASH");
|
||||||
|
|
||||||
_session = Session.TryLoadOrCreateNew(store, sessionUserId);
|
_session = Session.TryLoadOrCreateNew(store, sessionUserId);
|
||||||
_transport = new TcpTransport(_session.ServerAddress, _session.Port);
|
_transport = new TcpTransport(_session.ServerAddress, _session.Port);
|
||||||
}
|
}
|
||||||
|
|
@ -53,7 +57,15 @@ namespace TLSharp.Core
|
||||||
|
|
||||||
//set-up layer
|
//set-up layer
|
||||||
var config = new TLRequestGetConfig();
|
var config = new TLRequestGetConfig();
|
||||||
var request = new TLRequestInitConnection() { api_id = _apiId, app_version = "1.0.0", device_model = "PC", lang_code = "en", query = config, system_version = "Win 10.0" };
|
var request = new TLRequestInitConnection()
|
||||||
|
{
|
||||||
|
api_id = _apiId,
|
||||||
|
app_version = "1.0.0",
|
||||||
|
device_model = "PC",
|
||||||
|
lang_code = "en",
|
||||||
|
query = config,
|
||||||
|
system_version = "Win 10.0"
|
||||||
|
};
|
||||||
var invokewithLayer = new TLRequestInvokeWithLayer() { layer = 57, query = request };
|
var invokewithLayer = new TLRequestInvokeWithLayer() { layer = 57, query = request };
|
||||||
await _sender.Send(invokewithLayer);
|
await _sender.Send(invokewithLayer);
|
||||||
await _sender.Receive(invokewithLayer);
|
await _sender.Receive(invokewithLayer);
|
||||||
|
|
@ -110,16 +122,9 @@ namespace TLSharp.Core
|
||||||
|
|
||||||
completed = true;
|
completed = true;
|
||||||
}
|
}
|
||||||
catch (InvalidOperationException ex)
|
catch (MigrationNeededException ex)
|
||||||
{
|
{
|
||||||
if (ex.Message.StartsWith("Your phone number registered to") && ex.Data["dcId"] != null)
|
await ReconnectToDcAsync(ex.DC);
|
||||||
{
|
|
||||||
await ReconnectToDcAsync((int)ex.Data["dcId"]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -172,14 +177,12 @@ namespace TLSharp.Core
|
||||||
if (!IsUserAuthorized())
|
if (!IsUserAuthorized())
|
||||||
throw new InvalidOperationException("Authorize user first!");
|
throw new InvalidOperationException("Authorize user first!");
|
||||||
|
|
||||||
long uniqueId = Convert.ToInt64((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds);
|
|
||||||
|
|
||||||
return await SendRequestAsync<TLAbsUpdates>(
|
return await SendRequestAsync<TLAbsUpdates>(
|
||||||
new TLRequestSendMessage()
|
new TLRequestSendMessage()
|
||||||
{
|
{
|
||||||
peer = peer,
|
peer = peer,
|
||||||
message = message,
|
message = message,
|
||||||
random_id = uniqueId
|
random_id = Helpers.GenerateRandomLong()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -200,6 +203,46 @@ namespace TLSharp.Core
|
||||||
new TLRequestGetDialogs() { offset_date = 0, offset_peer = peer, limit = 100 });
|
new TLRequestGetDialogs() { offset_date = 0, offset_peer = peer, limit = 100 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<TLAbsUpdates> SendUploadedPhoto(TLAbsInputPeer peer, TLAbsInputFile file, string caption)
|
||||||
|
{
|
||||||
|
return await SendRequestAsync<TLAbsUpdates>(new TLRequestSendMedia()
|
||||||
|
{
|
||||||
|
random_id = Helpers.GenerateRandomLong(),
|
||||||
|
background = false,
|
||||||
|
clear_draft = false,
|
||||||
|
media = new TLInputMediaUploadedPhoto() { file = file, caption = caption },
|
||||||
|
peer = peer
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<TLAbsUpdates> SendUploadedDocument(
|
||||||
|
TLAbsInputPeer peer, TLAbsInputFile file, string caption, string mimeType, TLVector<TLAbsDocumentAttribute> attributes)
|
||||||
|
{
|
||||||
|
return await SendRequestAsync<TLAbsUpdates>(new TLRequestSendMedia()
|
||||||
|
{
|
||||||
|
random_id = Helpers.GenerateRandomLong(),
|
||||||
|
background = false,
|
||||||
|
clear_draft = false,
|
||||||
|
media = new TLInputMediaUploadedDocument()
|
||||||
|
{
|
||||||
|
file = file,
|
||||||
|
caption = caption,
|
||||||
|
mime_type = mimeType,
|
||||||
|
attributes = attributes
|
||||||
|
},
|
||||||
|
peer = peer
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<TLFile> GetFile(TLAbsInputFileLocation location, int filePartSize)
|
||||||
|
{
|
||||||
|
return await SendRequestAsync<TLFile>(new TLRequestGetFile()
|
||||||
|
{
|
||||||
|
location = location,
|
||||||
|
limit = filePartSize
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void OnUserAuthenticated(TLUser TLUser)
|
private void OnUserAuthenticated(TLUser TLUser)
|
||||||
{
|
{
|
||||||
_session.TLUser = TLUser;
|
_session.TLUser = TLUser;
|
||||||
|
|
@ -207,6 +250,15 @@ namespace TLSharp.Core
|
||||||
|
|
||||||
_session.Save();
|
_session.Save();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MissingApiConfigurationException : Exception
|
||||||
|
{
|
||||||
|
public const string InfoUrl = "https://github.com/sochix/TLSharp#quick-configuration";
|
||||||
|
|
||||||
|
internal MissingApiConfigurationException(string invalidParamName):
|
||||||
|
base($"Your {invalidParamName} setting is missing. Adjust the configuration first, see {InfoUrl}")
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
135
TLSharp.Core/Utils/UploadHelper.cs
Normal file
135
TLSharp.Core/Utils/UploadHelper.cs
Normal file
|
|
@ -0,0 +1,135 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using TeleSharp.TL;
|
||||||
|
using TeleSharp.TL.Upload;
|
||||||
|
|
||||||
|
namespace TLSharp.Core.Utils
|
||||||
|
{
|
||||||
|
public static class UploadHelper
|
||||||
|
{
|
||||||
|
private static string GetFileHash(byte[] data)
|
||||||
|
{
|
||||||
|
string md5_checksum;
|
||||||
|
using (var md5 = MD5.Create())
|
||||||
|
{
|
||||||
|
var hash = md5.ComputeHash(data);
|
||||||
|
var hashResult = new StringBuilder(hash.Length * 2);
|
||||||
|
|
||||||
|
foreach (byte t in hash)
|
||||||
|
hashResult.Append(t.ToString("x2"));
|
||||||
|
|
||||||
|
md5_checksum = hashResult.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return md5_checksum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<TLAbsInputFile> UploadFile(this TelegramClient client, string name, StreamReader reader)
|
||||||
|
{
|
||||||
|
const long tenMb = 10 * 1024 * 1024;
|
||||||
|
return await UploadFile(name, reader, client, reader.BaseStream.Length >= tenMb);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[] GetFile(StreamReader reader)
|
||||||
|
{
|
||||||
|
var file = new byte[reader.BaseStream.Length];
|
||||||
|
|
||||||
|
using (reader)
|
||||||
|
{
|
||||||
|
reader.BaseStream.Read(file, 0, (int)reader.BaseStream.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Queue<byte[]> GetFileParts(byte[] file)
|
||||||
|
{
|
||||||
|
var fileParts = new Queue<byte[]>();
|
||||||
|
|
||||||
|
const int maxFilePart = 512 * 1024;
|
||||||
|
|
||||||
|
using (var stream = new MemoryStream(file))
|
||||||
|
{
|
||||||
|
while (stream.Position != stream.Length)
|
||||||
|
{
|
||||||
|
if ((stream.Length - stream.Position) > maxFilePart)
|
||||||
|
{
|
||||||
|
var temp = new byte[maxFilePart];
|
||||||
|
stream.Read(temp, 0, maxFilePart);
|
||||||
|
fileParts.Enqueue(temp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var length = stream.Length - stream.Position;
|
||||||
|
var temp = new byte[length];
|
||||||
|
stream.Read(temp, 0, (int)(length));
|
||||||
|
fileParts.Enqueue(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileParts;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task<TLAbsInputFile> UploadFile(string name, StreamReader reader,
|
||||||
|
TelegramClient client, bool isBigFileUpload)
|
||||||
|
{
|
||||||
|
var file = GetFile(reader);
|
||||||
|
var fileParts = GetFileParts(file);
|
||||||
|
|
||||||
|
int partNumber = 0;
|
||||||
|
int partsCount = fileParts.Count;
|
||||||
|
long file_id = BitConverter.ToInt64(Helpers.GenerateRandomBytes(8), 0);
|
||||||
|
while (fileParts.Count != 0)
|
||||||
|
{
|
||||||
|
var part = fileParts.Dequeue();
|
||||||
|
|
||||||
|
if (isBigFileUpload)
|
||||||
|
{
|
||||||
|
await client.SendRequestAsync<bool>(new TLRequestSaveBigFilePart
|
||||||
|
{
|
||||||
|
file_id = file_id,
|
||||||
|
file_part = partNumber,
|
||||||
|
bytes = part,
|
||||||
|
file_total_parts = partsCount
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await client.SendRequestAsync<bool>(new TLRequestSaveFilePart
|
||||||
|
{
|
||||||
|
file_id = file_id,
|
||||||
|
file_part = partNumber,
|
||||||
|
bytes = part
|
||||||
|
});
|
||||||
|
}
|
||||||
|
partNumber++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isBigFileUpload)
|
||||||
|
{
|
||||||
|
return new TLInputFileBig
|
||||||
|
{
|
||||||
|
id = file_id,
|
||||||
|
name = name,
|
||||||
|
parts = partsCount
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new TLInputFile
|
||||||
|
{
|
||||||
|
id = file_id,
|
||||||
|
name = name,
|
||||||
|
parts = partsCount,
|
||||||
|
md5_checksum = GetFileHash(file)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
|
@ -68,6 +68,11 @@
|
||||||
<Name>TLSharp.Core</Name>
|
<Name>TLSharp.Core</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="data\cat.jpg">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
<Choose>
|
<Choose>
|
||||||
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
|
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,19 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
using TeleSharp.TL;
|
using TeleSharp.TL;
|
||||||
using TeleSharp.TL.Channels;
|
|
||||||
using TeleSharp.TL.Contacts;
|
|
||||||
using TeleSharp.TL.Messages;
|
using TeleSharp.TL.Messages;
|
||||||
using TLSharp.Core;
|
using TLSharp.Core;
|
||||||
using TLSharp.Core.Auth;
|
using TLSharp.Core.Requests;
|
||||||
using TLSharp.Core.MTProto;
|
using TLSharp.Core.Utils;
|
||||||
using TLSharp.Core.Network;
|
|
||||||
|
|
||||||
namespace TLSharp.Tests
|
namespace TLSharp.Tests
|
||||||
{
|
{
|
||||||
|
|
@ -33,14 +32,42 @@ namespace TLSharp.Tests
|
||||||
|
|
||||||
private string NumberToAddToChat { get; set; }
|
private string NumberToAddToChat { get; set; }
|
||||||
|
|
||||||
private string apiHash = null;
|
private string ApiHash { get; set; }
|
||||||
|
|
||||||
private int apiId = 0;
|
private int ApiId { get; set; }
|
||||||
|
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void Init()
|
public void Init()
|
||||||
{
|
{
|
||||||
// Setup your phone numbers in app.config
|
// Setup your API settings and phone numbers in app.config
|
||||||
|
GatherTestConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
|
private TelegramClient NewClient()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return new TelegramClient(ApiId, ApiHash);
|
||||||
|
}
|
||||||
|
catch (MissingApiConfigurationException ex)
|
||||||
|
{
|
||||||
|
throw new Exception($"Please add your API settings to the `app.config` file. (More info: {MissingApiConfigurationException.InfoUrl})",
|
||||||
|
ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GatherTestConfiguration()
|
||||||
|
{
|
||||||
|
ApiHash = ConfigurationManager.AppSettings[nameof(ApiHash)];
|
||||||
|
if (string.IsNullOrEmpty(ApiHash))
|
||||||
|
Debug.WriteLine("ApiHash not configured in app.config! Some tests may fail.");
|
||||||
|
|
||||||
|
var apiId = ConfigurationManager.AppSettings[nameof(ApiId)];
|
||||||
|
if (string.IsNullOrEmpty(apiId))
|
||||||
|
Debug.WriteLine("ApiId not configured in app.config! Some tests may fail.");
|
||||||
|
else
|
||||||
|
ApiId = int.Parse(apiId);
|
||||||
|
|
||||||
NumberToAuthenticate = ConfigurationManager.AppSettings[nameof(NumberToAuthenticate)];
|
NumberToAuthenticate = ConfigurationManager.AppSettings[nameof(NumberToAuthenticate)];
|
||||||
if (string.IsNullOrEmpty(NumberToAuthenticate))
|
if (string.IsNullOrEmpty(NumberToAuthenticate))
|
||||||
Debug.WriteLine("NumberToAuthenticate not configured in app.config! Some tests may fail.");
|
Debug.WriteLine("NumberToAuthenticate not configured in app.config! Some tests may fail.");
|
||||||
|
|
@ -69,7 +96,7 @@ namespace TLSharp.Tests
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async Task AuthUser()
|
public async Task AuthUser()
|
||||||
{
|
{
|
||||||
var client = new TelegramClient(apiId, apiHash);
|
var client = NewClient();
|
||||||
|
|
||||||
await client.ConnectAsync();
|
await client.ConnectAsync();
|
||||||
|
|
||||||
|
|
@ -85,26 +112,32 @@ namespace TLSharp.Tests
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async Task SendMessageTest()
|
public async Task SendMessageTest()
|
||||||
{
|
{
|
||||||
var client = new TelegramClient(apiId, apiHash);
|
var client = NewClient();
|
||||||
|
|
||||||
await client.ConnectAsync();
|
await client.ConnectAsync();
|
||||||
|
|
||||||
var result = await client.GetContactsAsync();
|
var result = await client.GetContactsAsync();
|
||||||
|
|
||||||
var user = result.users.lists
|
var user = result.users.lists
|
||||||
.Where(x => x.GetType() == typeof (TLUser))
|
.Where(x => x.GetType() == typeof(TLUser))
|
||||||
.Cast<TLUser>()
|
.Cast<TLUser>()
|
||||||
.FirstOrDefault(x => x.phone == NumberToSendMessage);
|
.FirstOrDefault(x => x.phone == NumberToSendMessage);
|
||||||
await client.SendTypingAsync(new TLInputPeerUser() {user_id = user.id});
|
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
throw new System.Exception("Number was not found in Contacts List of user: " + NumberToSendMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
await client.SendTypingAsync(new TLInputPeerUser() { user_id = user.id });
|
||||||
Thread.Sleep(3000);
|
Thread.Sleep(3000);
|
||||||
await client.SendMessageAsync(new TLInputPeerUser() {user_id = user.id}, "TEST");
|
await client.SendMessageAsync(new TLInputPeerUser() { user_id = user.id }, "TEST");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async Task SendMessageToChannelTest()
|
public async Task SendMessageToChannelTest()
|
||||||
{
|
{
|
||||||
var client = new TelegramClient(apiId, apiHash);
|
var client = NewClient();
|
||||||
|
|
||||||
await client.ConnectAsync();
|
await client.ConnectAsync();
|
||||||
|
|
||||||
|
|
@ -117,10 +150,91 @@ namespace TLSharp.Tests
|
||||||
await client.SendMessageAsync(new TLInputPeerChannel() { channel_id = chat.id, access_hash = chat.access_hash.Value }, "TEST MSG");
|
await client.SendMessageAsync(new TLInputPeerChannel() { channel_id = chat.id, access_hash = chat.access_hash.Value }, "TEST MSG");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public async Task SendPhotoToContactTest()
|
||||||
|
{
|
||||||
|
var client = NewClient();
|
||||||
|
|
||||||
|
await client.ConnectAsync();
|
||||||
|
|
||||||
|
var result = await client.GetContactsAsync();
|
||||||
|
|
||||||
|
var user = result.users.lists
|
||||||
|
.Where(x => x.GetType() == typeof(TLUser))
|
||||||
|
.Cast<TLUser>()
|
||||||
|
.FirstOrDefault(x => x.phone == NumberToSendMessage);
|
||||||
|
|
||||||
|
var fileResult = (TLInputFile)await client.UploadFile("cat.jpg", new StreamReader("data/cat.jpg"));
|
||||||
|
await client.SendUploadedPhoto(new TLInputPeerUser() { user_id = user.id }, fileResult, "kitty");
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public async Task SendBigFileToContactTest()
|
||||||
|
{
|
||||||
|
var client = NewClient();
|
||||||
|
|
||||||
|
await client.ConnectAsync();
|
||||||
|
|
||||||
|
var result = await client.GetContactsAsync();
|
||||||
|
|
||||||
|
var user = result.users.lists
|
||||||
|
.Where(x => x.GetType() == typeof(TLUser))
|
||||||
|
.Cast<TLUser>()
|
||||||
|
.FirstOrDefault(x => x.phone == NumberToSendMessage);
|
||||||
|
|
||||||
|
var fileResult = (TLInputFileBig)await client.UploadFile("some.zip", new StreamReader("<some big file path>"));
|
||||||
|
|
||||||
|
await client.SendUploadedDocument(
|
||||||
|
new TLInputPeerUser() { user_id = user.id },
|
||||||
|
fileResult,
|
||||||
|
"some zips",
|
||||||
|
"application/zip",
|
||||||
|
new TLVector<TLAbsDocumentAttribute>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public async Task DownloadFileFromContactTest()
|
||||||
|
{
|
||||||
|
var client = NewClient();
|
||||||
|
|
||||||
|
await client.ConnectAsync();
|
||||||
|
|
||||||
|
var result = await client.GetContactsAsync();
|
||||||
|
|
||||||
|
var user = result.users.lists
|
||||||
|
.Where(x => x.GetType() == typeof(TLUser))
|
||||||
|
.Cast<TLUser>()
|
||||||
|
.FirstOrDefault(x => x.phone == NumberToSendMessage);
|
||||||
|
|
||||||
|
var inputPeer = new TLInputPeerUser() { user_id = user.id };
|
||||||
|
var res = await client.SendRequestAsync<TLMessagesSlice>(new TLRequestGetHistory() { peer = inputPeer });
|
||||||
|
var document = res.messages.lists
|
||||||
|
.Where(m => m.GetType() == typeof(TLMessage))
|
||||||
|
.Cast<TLMessage>()
|
||||||
|
.Where(m => m.media != null && m.media.GetType() == typeof(TLMessageMediaDocument))
|
||||||
|
.Select(m => m.media)
|
||||||
|
.Cast<TLMessageMediaDocument>()
|
||||||
|
.Where(md => md.document.GetType() == typeof(TLDocument))
|
||||||
|
.Select(md => md.document)
|
||||||
|
.Cast<TLDocument>()
|
||||||
|
.First();
|
||||||
|
|
||||||
|
var resFile = await client.GetFile(
|
||||||
|
new TLInputDocumentFileLocation()
|
||||||
|
{
|
||||||
|
access_hash = document.access_hash,
|
||||||
|
id = document.id,
|
||||||
|
version = document.version
|
||||||
|
},
|
||||||
|
document.size);
|
||||||
|
|
||||||
|
Assert.IsTrue(resFile.bytes.Length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async Task SignUpNewUser()
|
public async Task SignUpNewUser()
|
||||||
{
|
{
|
||||||
var client = new TelegramClient(apiId, apiHash);
|
var client = NewClient();
|
||||||
await client.ConnectAsync();
|
await client.ConnectAsync();
|
||||||
|
|
||||||
var hash = await client.SendCodeRequestAsync(NotRegisteredNumberToSignUp);
|
var hash = await client.SendCodeRequestAsync(NotRegisteredNumberToSignUp);
|
||||||
|
|
@ -137,12 +251,11 @@ namespace TLSharp.Tests
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async Task CheckPhones()
|
public async Task CheckPhones()
|
||||||
{
|
{
|
||||||
var client = new TelegramClient(apiId, apiHash);
|
var client = NewClient();
|
||||||
await client.ConnectAsync();
|
await client.ConnectAsync();
|
||||||
|
|
||||||
var result = await client.IsPhoneRegisteredAsync(NumberToAuthenticate);
|
var result = await client.IsPhoneRegisteredAsync(NumberToAuthenticate);
|
||||||
Assert.IsTrue(result);
|
Assert.IsTrue(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<appSettings>
|
<appSettings>
|
||||||
|
<add key="ApiHash" value="" />
|
||||||
|
<add key="ApiId" value="" />
|
||||||
<add key="NumberToAuthenticate" value="" />
|
<add key="NumberToAuthenticate" value="" />
|
||||||
<add key="NotRegisteredNumberToSignUp" value=""/>
|
<add key="NotRegisteredNumberToSignUp" value=""/>
|
||||||
<add key="NumberToSendMessage" value=""/>
|
<add key="NumberToSendMessage" value=""/>
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>TeleSharp.Generator</RootNamespace>
|
<RootNamespace>TeleSharp.Generator</RootNamespace>
|
||||||
<AssemblyName>TeleSharp.Generator</AssemblyName>
|
<AssemblyName>TeleSharp.Generator</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace TeleSharp.TL
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
throw new InvalidDataException("Constructor Invalid Or Context.Init Not Called !");
|
throw new InvalidDataException("Constructor Invalid Or Context.Init Not Called !", ex);
|
||||||
}
|
}
|
||||||
if (t.IsSubclassOf(typeof(TLMethod)))
|
if (t.IsSubclassOf(typeof(TLMethod)))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using TeleSharp.TL;
|
|
||||||
namespace TeleSharp.TL
|
|
||||||
{
|
|
||||||
[TLObject(481674261)]
|
|
||||||
public class TLVector : TLObject
|
|
||||||
{
|
|
||||||
public override int Constructor
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 481674261;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void ComputeFlags()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void DeserializeBody(BinaryReader br)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
|
||||||
{
|
|
||||||
bw.Write(Constructor);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -54,6 +54,8 @@ namespace TeleSharp.TL
|
||||||
public override void SerializeBody(BinaryWriter bw)
|
public override void SerializeBody(BinaryWriter bw)
|
||||||
{
|
{
|
||||||
bw.Write(Constructor);
|
bw.Write(Constructor);
|
||||||
|
bw.Write(lists.Count());
|
||||||
|
|
||||||
foreach (var item in lists.Cast<TLObject>())
|
foreach (var item in lists.Cast<TLObject>())
|
||||||
{
|
{
|
||||||
item.SerializeBody(bw);
|
item.SerializeBody(bw);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>TeleSharp.TL</RootNamespace>
|
<RootNamespace>TeleSharp.TL</RootNamespace>
|
||||||
<AssemblyName>TeleSharp.TL</AssemblyName>
|
<AssemblyName>TeleSharp.TL</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
|
@ -758,7 +758,6 @@
|
||||||
<Compile Include="TL\TLUserStatusOffline.cs" />
|
<Compile Include="TL\TLUserStatusOffline.cs" />
|
||||||
<Compile Include="TL\TLUserStatusOnline.cs" />
|
<Compile Include="TL\TLUserStatusOnline.cs" />
|
||||||
<Compile Include="TL\TLUserStatusRecently.cs" />
|
<Compile Include="TL\TLUserStatusRecently.cs" />
|
||||||
<Compile Include="TL\TLVector.cs" />
|
|
||||||
<Compile Include="TL\TLWallPaper.cs" />
|
<Compile Include="TL\TLWallPaper.cs" />
|
||||||
<Compile Include="TL\TLWallPaperSolid.cs" />
|
<Compile Include="TL\TLWallPaperSolid.cs" />
|
||||||
<Compile Include="TL\TLWebPage.cs" />
|
<Compile Include="TL\TLWebPage.cs" />
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue