Fix dc loop #719

This commit is contained in:
Federico Armellini 2019-01-28 17:29:10 +01:00
parent f2a394ea15
commit 558d58a950
12 changed files with 1673 additions and 1654 deletions

View file

@ -66,7 +66,7 @@ namespace TLSharp.Core.Network
byte[] msgKey;
byte[] ciphertext;
using (MemoryStream plaintextPacket = makeMemory(8 + 8 + 8 + 4 + 4 + packet.Length))
using (MemoryStream plaintextPacket = MakeMemory(8 + 8 + 8 + 4 + 4 + packet.Length))
{
using (BinaryWriter plaintextWriter = new BinaryWriter(plaintextPacket))
{
@ -82,7 +82,7 @@ namespace TLSharp.Core.Network
}
}
using (MemoryStream ciphertextPacket = makeMemory(8 + 16 + ciphertext.Length))
using (MemoryStream ciphertextPacket = MakeMemory(8 + 16 + ciphertext.Length))
{
using (BinaryWriter writer = new BinaryWriter(ciphertextPacket))
{
@ -136,7 +136,7 @@ namespace TLSharp.Core.Network
using (var messageStream = new MemoryStream(result.Item1, false))
using (var messageReader = new BinaryReader(messageStream))
{
processMessage(result.Item2, result.Item3, messageReader, request);
ProcessMessage(result.Item2, result.Item3, messageReader, request);
}
}
@ -156,7 +156,7 @@ namespace TLSharp.Core.Network
await Receive(pingRequest);
}
private bool processMessage(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request)
private bool ProcessMessage(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request)
{
// TODO: check salt
// TODO: check sessionid
@ -240,7 +240,7 @@ namespace TLSharp.Core.Network
using (MemoryStream packedStream = new MemoryStream(packedData, false))
using (BinaryReader compressedReader = new BinaryReader(packedStream))
{
processMessage(messageId, sequence, compressedReader, request);
ProcessMessage(messageId, sequence, compressedReader, request);
}
return true;
@ -503,7 +503,7 @@ namespace TLSharp.Core.Network
long beginPosition = messageReader.BaseStream.Position;
try
{
if (!processMessage(innerMessageId, sequence, messageReader, request))
if (!ProcessMessage(innerMessageId, sequence, messageReader, request))
{
messageReader.BaseStream.Position = beginPosition + innerLength;
}
@ -518,7 +518,7 @@ namespace TLSharp.Core.Network
return false;
}
private MemoryStream makeMemory(int len)
private MemoryStream MakeMemory(int len)
{
return new MemoryStream(new byte[len], 0, len, true, true);
}

View file

@ -9,8 +9,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TLSharp.Core</RootNamespace>
<AssemblyName>TLSharp.Core</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>

View file

@ -1,408 +1,421 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using TeleSharp.TL;
using TeleSharp.TL.Account;
using TeleSharp.TL.Auth;
using TeleSharp.TL.Contacts;
using TeleSharp.TL.Help;
using TeleSharp.TL.Messages;
using TeleSharp.TL.Upload;
using TLSharp.Core.Auth;
using TLSharp.Core.MTProto.Crypto;
using TLSharp.Core.Network;
using TLSharp.Core.Utils;
using TLAuthorization = TeleSharp.TL.Auth.TLAuthorization;
namespace TLSharp.Core
{
public class TelegramClient : IDisposable
{
private MtProtoSender _sender;
private AuthKey _key;
private TcpTransport _transport;
private string _apiHash = "";
private int _apiId = 0;
private Session _session;
private List<TLDcOption> dcOptions;
private TcpClientConnectionHandler _handler;
public TelegramClient(int apiId, string apiHash,
ISessionStore store = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null)
{
if (apiId == default(int))
throw new MissingApiConfigurationException("API_ID");
if (string.IsNullOrEmpty(apiHash))
throw new MissingApiConfigurationException("API_HASH");
if (store == null)
store = new FileSessionStore();
_apiHash = apiHash;
_apiId = apiId;
_handler = handler;
_session = Session.TryLoadOrCreateNew(store, sessionUserId);
_transport = new TcpTransport(_session.ServerAddress, _session.Port, _handler);
}
public async Task ConnectAsync(bool reconnect = false)
{
if (_session.AuthKey == null || reconnect)
{
var result = await Authenticator.DoAuthentication(_transport);
_session.AuthKey = result.AuthKey;
_session.TimeOffset = result.TimeOffset;
}
_sender = new MtProtoSender(_transport, _session);
//set-up layer
var config = new TLRequestGetConfig();
var request = new TLRequestInitConnection()
{
ApiId = _apiId,
AppVersion = "1.0.0",
DeviceModel = "PC",
LangCode = "en",
Query = config,
SystemVersion = "Win 10.0"
};
var invokewithLayer = new TLRequestInvokeWithLayer() { Layer = 66, Query = request };
await _sender.Send(invokewithLayer);
await _sender.Receive(invokewithLayer);
dcOptions = ((TLConfig)invokewithLayer.Response).DcOptions.ToList();
}
private async Task ReconnectToDcAsync(int dcId)
{
if (dcOptions == null || !dcOptions.Any())
throw new InvalidOperationException($"Can't reconnect. Establish initial connection first.");
TLExportedAuthorization exported = null;
if (_session.TLUser != null)
{
TLRequestExportAuthorization exportAuthorization = new TLRequestExportAuthorization() { DcId = dcId };
exported = await SendRequestAsync<TLExportedAuthorization>(exportAuthorization);
}
var dc = dcOptions.First(d => d.Id == dcId);
_transport = new TcpTransport(dc.IpAddress, dc.Port, _handler);
_session.ServerAddress = dc.IpAddress;
_session.Port = dc.Port;
await ConnectAsync(true);
if (_session.TLUser != null)
{
TLRequestImportAuthorization importAuthorization = new TLRequestImportAuthorization() { Id = exported.Id, Bytes = exported.Bytes };
var imported = await SendRequestAsync<TLAuthorization>(importAuthorization);
OnUserAuthenticated(((TLUser)imported.User));
}
}
private async Task RequestWithDcMigration(TLMethod request)
{
if (_sender == null)
throw new InvalidOperationException("Not connected!");
var completed = false;
while(!completed)
{
try
{
await _sender.Send(request);
await _sender.Receive(request);
completed = true;
}
catch(DataCenterMigrationException e)
{
await ReconnectToDcAsync(e.DC);
// prepare the request for another try
request.ConfirmReceived = false;
}
}
}
public bool IsUserAuthorized()
{
return _session.TLUser != null;
}
public async Task<bool> IsPhoneRegisteredAsync(string phoneNumber)
{
if (String.IsNullOrWhiteSpace(phoneNumber))
throw new ArgumentNullException(nameof(phoneNumber));
var authCheckPhoneRequest = new TLRequestCheckPhone() { PhoneNumber = phoneNumber };
await RequestWithDcMigration(authCheckPhoneRequest);
return authCheckPhoneRequest.Response.PhoneRegistered;
}
public async Task<string> SendCodeRequestAsync(string phoneNumber)
{
if (String.IsNullOrWhiteSpace(phoneNumber))
throw new ArgumentNullException(nameof(phoneNumber));
var request = new TLRequestSendCode() { PhoneNumber = phoneNumber, ApiId = _apiId, ApiHash = _apiHash };
await RequestWithDcMigration(request);
return request.Response.PhoneCodeHash;
}
public async Task<TLUser> MakeAuthAsync(string phoneNumber, string phoneCodeHash, string code)
{
if (String.IsNullOrWhiteSpace(phoneNumber))
throw new ArgumentNullException(nameof(phoneNumber));
if (String.IsNullOrWhiteSpace(phoneCodeHash))
throw new ArgumentNullException(nameof(phoneCodeHash));
if (String.IsNullOrWhiteSpace(code))
throw new ArgumentNullException(nameof(code));
var request = new TLRequestSignIn() { PhoneNumber = phoneNumber, PhoneCodeHash = phoneCodeHash, PhoneCode = code };
await RequestWithDcMigration(request);
OnUserAuthenticated(((TLUser)request.Response.User));
return ((TLUser)request.Response.User);
}
public async Task<TLPassword> GetPasswordSetting()
{
var request = new TLRequestGetPassword();
await RequestWithDcMigration(request);
return ((TLPassword)request.Response);
}
public async Task<TLUser> MakeAuthWithPasswordAsync(TLPassword password, string password_str)
{
byte[] password_Bytes = Encoding.UTF8.GetBytes(password_str);
IEnumerable<byte> rv = password.CurrentSalt.Concat(password_Bytes).Concat(password.CurrentSalt);
SHA256Managed hashstring = new SHA256Managed();
var password_hash = hashstring.ComputeHash(rv.ToArray());
var request = new TLRequestCheckPassword() { PasswordHash = password_hash };
await RequestWithDcMigration(request);
OnUserAuthenticated(((TLUser)request.Response.User));
return ((TLUser)request.Response.User);
}
public async Task<TLUser> SignUpAsync(string phoneNumber, string phoneCodeHash, string code, string firstName, string lastName)
{
var request = new TLRequestSignUp() { PhoneNumber = phoneNumber, PhoneCode = code, PhoneCodeHash = phoneCodeHash, FirstName = firstName, LastName = lastName };
await RequestWithDcMigration(request);
OnUserAuthenticated(((TLUser)request.Response.User));
return ((TLUser)request.Response.User);
}
public async Task<T> SendRequestAsync<T>(TLMethod methodToExecute)
{
await RequestWithDcMigration(methodToExecute);
var result = methodToExecute.GetType().GetProperty("Response").GetValue(methodToExecute);
return (T)result;
}
public async Task<TLContacts> GetContactsAsync()
{
if (!IsUserAuthorized())
throw new InvalidOperationException("Authorize user first!");
var req = new TLRequestGetContacts() { Hash = "" };
return await SendRequestAsync<TLContacts>(req);
}
public async Task<TLAbsUpdates> SendMessageAsync(TLAbsInputPeer peer, string message)
{
if (!IsUserAuthorized())
throw new InvalidOperationException("Authorize user first!");
return await SendRequestAsync<TLAbsUpdates>(
new TLRequestSendMessage()
{
Peer = peer,
Message = message,
RandomId = Helpers.GenerateRandomLong()
});
}
public async Task<Boolean> SendTypingAsync(TLAbsInputPeer peer)
{
var req = new TLRequestSetTyping()
{
Action = new TLSendMessageTypingAction(),
Peer = peer
};
return await SendRequestAsync<Boolean>(req);
}
public async Task<TLAbsDialogs> GetUserDialogsAsync(int offsetDate = 0, int offsetId = 0, TLAbsInputPeer offsetPeer = null, int limit = 100)
{
if (!IsUserAuthorized())
throw new InvalidOperationException("Authorize user first!");
if (offsetPeer == null)
offsetPeer = new TLInputPeerSelf();
var req = new TLRequestGetDialogs()
{
OffsetDate = offsetDate,
OffsetId = offsetId,
OffsetPeer = offsetPeer,
Limit = limit
};
return await SendRequestAsync<TLAbsDialogs>(req);
}
public async Task<TLAbsUpdates> SendUploadedPhoto(TLAbsInputPeer peer, TLAbsInputFile file, string caption)
{
return await SendRequestAsync<TLAbsUpdates>(new TLRequestSendMedia()
{
RandomId = Helpers.GenerateRandomLong(),
Background = false,
ClearDraft = 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()
{
RandomId = Helpers.GenerateRandomLong(),
Background = false,
ClearDraft = false,
Media = new TLInputMediaUploadedDocument()
{
File = file,
Caption = caption,
MimeType = mimeType,
Attributes = attributes
},
Peer = peer
});
}
public async Task<TLFile> GetFile(TLAbsInputFileLocation location, int filePartSize, int offset = 0)
{
TLFile result = null;
result = await SendRequestAsync<TLFile>(new TLRequestGetFile()
{
Location = location,
Limit = filePartSize,
Offset = offset
});
return result;
}
public async Task SendPingAsync()
{
await _sender.SendPingAsync();
}
public async Task<TLAbsMessages> GetHistoryAsync(TLAbsInputPeer peer, int offsetId = 0, int offsetDate = 0, int addOffset = 0, int limit = 100, int maxId = 0, int minId = 0)
{
if (!IsUserAuthorized())
throw new InvalidOperationException("Authorize user first!");
var req = new TLRequestGetHistory()
{
Peer = peer,
OffsetId = offsetId,
OffsetDate = offsetDate,
AddOffset = addOffset,
Limit = limit,
MaxId = maxId,
MinId = minId
};
return await SendRequestAsync<TLAbsMessages>(req);
}
/// <summary>
/// Serch user or chat. API: contacts.search#11f812d8 q:string limit:int = contacts.Found;
/// </summary>
/// <param name="q">User or chat name</param>
/// <param name="limit">Max result count</param>
/// <returns></returns>
public async Task<TLFound> SearchUserAsync(string q, int limit = 10)
{
var r = new TeleSharp.TL.Contacts.TLRequestSearch
{
Q = q,
Limit = limit
};
return await SendRequestAsync<TLFound>(r);
}
private void OnUserAuthenticated(TLUser TLUser)
{
_session.TLUser = TLUser;
_session.SessionExpires = int.MaxValue;
_session.Save();
}
public bool IsConnected
{
get
{
if (_transport == null)
return false;
return _transport.IsConnected;
}
}
public void Dispose()
{
if (_transport != null)
{
_transport.Dispose();
_transport = null;
}
}
}
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}")
{
}
}
public class InvalidPhoneCodeException : Exception
{
internal InvalidPhoneCodeException(string msg) : base(msg) { }
}
public class CloudPasswordNeededException : Exception
{
internal CloudPasswordNeededException(string msg) : base(msg) { }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using TeleSharp.TL;
using TeleSharp.TL.Account;
using TeleSharp.TL.Auth;
using TeleSharp.TL.Contacts;
using TeleSharp.TL.Help;
using TeleSharp.TL.Messages;
using TeleSharp.TL.Upload;
using TLSharp.Core.Auth;
using TLSharp.Core.MTProto.Crypto;
using TLSharp.Core.Network;
using TLSharp.Core.Utils;
using TLAuthorization = TeleSharp.TL.Auth.TLAuthorization;
namespace TLSharp.Core
{
public class TelegramClient : IDisposable
{
private MtProtoSender _sender;
private readonly AuthKey _key;
private TcpTransport _transport;
private string _apiHash = "";
private int _apiId = 0;
private Session _session;
private List<TLDcOption> dcOptions;
private readonly TcpClientConnectionHandler _handler;
public TelegramClient(int apiId, string apiHash,
ISessionStore store = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null)
{
if (apiId == default(int))
throw new MissingApiConfigurationException("API_ID");
if (string.IsNullOrEmpty(apiHash))
throw new MissingApiConfigurationException("API_HASH");
if (store == null)
store = new FileSessionStore();
_apiHash = apiHash;
_apiId = apiId;
_handler = handler;
_session = Session.TryLoadOrCreateNew(store, sessionUserId);
_transport = new TcpTransport(_session.ServerAddress, _session.Port, _handler);
}
public async Task ConnectAsync(bool reconnect = false)
{
if (_session.AuthKey == null || reconnect)
{
var result = await Authenticator.DoAuthentication(_transport);
_session.AuthKey = result.AuthKey;
_session.TimeOffset = result.TimeOffset;
}
_sender = new MtProtoSender(_transport, _session);
//set-up layer
var config = new TLRequestGetConfig();
var request = new TLRequestInitConnection()
{
ApiId = _apiId,
AppVersion = "1.0.0",
DeviceModel = "PC",
LangCode = "en",
Query = config,
SystemVersion = "Win 10.0"
};
var invokewithLayer = new TLRequestInvokeWithLayer() { Layer = 66, Query = request };
await _sender.Send(invokewithLayer);
await _sender.Receive(invokewithLayer);
dcOptions = ((TLConfig)invokewithLayer.Response).DcOptions.ToList();
}
private async Task ReconnectToDcAsync(int dcId, int times)
{
if (dcOptions == null || !dcOptions.Any())
throw new InvalidOperationException($"Can't reconnect. Establish initial connection first.");
TLExportedAuthorization exported = null;
if (_session.TLUser != null)
{
TLRequestExportAuthorization exportAuthorization = new TLRequestExportAuthorization() { DcId = dcId };
exported = await SendRequestAsync<TLExportedAuthorization>(exportAuthorization,times);
}
var dc = dcOptions.First(d => d.Id == dcId);
_transport = new TcpTransport(dc.IpAddress, dc.Port, _handler);
_session.ServerAddress = dc.IpAddress;
_session.Port = dc.Port;
await ConnectAsync(true);
if (_session.TLUser != null)
{
TLRequestImportAuthorization importAuthorization = new TLRequestImportAuthorization() { Id = exported.Id, Bytes = exported.Bytes };
var imported = await SendRequestAsync<TLAuthorization>(importAuthorization,times);
OnUserAuthenticated(((TLUser)imported.User));
}
}
private async Task RequestWithDcMigration(TLMethod request, int times)
{
if (_sender == null)
throw new InvalidOperationException("Not connected!");
var completed = false;
while(!completed)
{
try
{
await _sender.Send(request);
await _sender.Receive(request);
completed = true;
}
catch(DataCenterMigrationException e)
{
if (times <= 1)
{
await ReconnectToDcAsync(e.DC, times + 1);
// prepare the request for another try
request.ConfirmReceived = false;
}
else
{
throw e;
}
}
catch (TLSharp.Core.Network.FloodException e)
{
throw e;
}
}
}
public bool IsUserAuthorized()
{
return _session.TLUser != null;
}
public async Task<bool> IsPhoneRegisteredAsync(string phoneNumber)
{
if (String.IsNullOrWhiteSpace(phoneNumber))
throw new ArgumentNullException(nameof(phoneNumber));
var authCheckPhoneRequest = new TLRequestCheckPhone() { PhoneNumber = phoneNumber };
await RequestWithDcMigration(authCheckPhoneRequest,0);
return authCheckPhoneRequest.Response.PhoneRegistered;
}
public async Task<string> SendCodeRequestAsync(string phoneNumber)
{
if (String.IsNullOrWhiteSpace(phoneNumber))
throw new ArgumentNullException(nameof(phoneNumber));
var request = new TLRequestSendCode() { PhoneNumber = phoneNumber, ApiId = _apiId, ApiHash = _apiHash };
await RequestWithDcMigration(request,0);
return request.Response.PhoneCodeHash;
}
public async Task<TLUser> MakeAuthAsync(string phoneNumber, string phoneCodeHash, string code)
{
if (String.IsNullOrWhiteSpace(phoneNumber))
throw new ArgumentNullException(nameof(phoneNumber));
if (String.IsNullOrWhiteSpace(phoneCodeHash))
throw new ArgumentNullException(nameof(phoneCodeHash));
if (String.IsNullOrWhiteSpace(code))
throw new ArgumentNullException(nameof(code));
var request = new TLRequestSignIn() { PhoneNumber = phoneNumber, PhoneCodeHash = phoneCodeHash, PhoneCode = code };
await RequestWithDcMigration(request,0);
OnUserAuthenticated(((TLUser)request.Response.User));
return ((TLUser)request.Response.User);
}
public async Task<TLPassword> GetPasswordSetting()
{
var request = new TLRequestGetPassword();
await RequestWithDcMigration(request,0);
return ((TLPassword)request.Response);
}
public async Task<TLUser> MakeAuthWithPasswordAsync(TLPassword password, string password_str)
{
byte[] password_Bytes = Encoding.UTF8.GetBytes(password_str);
IEnumerable<byte> rv = password.CurrentSalt.Concat(password_Bytes).Concat(password.CurrentSalt);
SHA256Managed hashstring = new SHA256Managed();
var password_hash = hashstring.ComputeHash(rv.ToArray());
var request = new TLRequestCheckPassword() { PasswordHash = password_hash };
await RequestWithDcMigration(request,0);
OnUserAuthenticated(((TLUser)request.Response.User));
return ((TLUser)request.Response.User);
}
public async Task<TLUser> SignUpAsync(string phoneNumber, string phoneCodeHash, string code, string firstName, string lastName)
{
var request = new TLRequestSignUp() { PhoneNumber = phoneNumber, PhoneCode = code, PhoneCodeHash = phoneCodeHash, FirstName = firstName, LastName = lastName };
await RequestWithDcMigration(request,0);
OnUserAuthenticated(((TLUser)request.Response.User));
return ((TLUser)request.Response.User);
}
public async Task<T> SendRequestAsync<T>(TLMethod methodToExecute, int times)
{
await RequestWithDcMigration(methodToExecute, times);
var result = methodToExecute.GetType().GetProperty("Response").GetValue(methodToExecute);
return (T)result;
}
public async Task<TLContacts> GetContactsAsync()
{
if (!IsUserAuthorized())
throw new InvalidOperationException("Authorize user first!");
var req = new TLRequestGetContacts() { Hash = "" };
return await SendRequestAsync<TLContacts>(req,0);
}
public async Task<TLAbsUpdates> SendMessageAsync(TLAbsInputPeer peer, string message)
{
if (!IsUserAuthorized())
throw new InvalidOperationException("Authorize user first!");
var x = new TLRequestSendMessage()
{
Peer = peer,
Message = message,
RandomId = Helpers.GenerateRandomLong()
};
return await SendRequestAsync<TLAbsUpdates>(x, 0);
}
public async Task<Boolean> SendTypingAsync(TLAbsInputPeer peer)
{
var req = new TLRequestSetTyping()
{
Action = new TLSendMessageTypingAction(),
Peer = peer
};
return await SendRequestAsync<Boolean>(req,0);
}
public async Task<TLAbsDialogs> GetUserDialogsAsync(int offsetDate = 0, int offsetId = 0, TLAbsInputPeer offsetPeer = null, int limit = 100)
{
if (!IsUserAuthorized())
throw new InvalidOperationException("Authorize user first!");
if (offsetPeer == null)
offsetPeer = new TLInputPeerSelf();
var req = new TLRequestGetDialogs()
{
OffsetDate = offsetDate,
OffsetId = offsetId,
OffsetPeer = offsetPeer,
Limit = limit
};
return await SendRequestAsync<TLAbsDialogs>(req,0);
}
public async Task<TLAbsUpdates> SendUploadedPhoto(TLAbsInputPeer peer, TLAbsInputFile file, string caption)
{
return await SendRequestAsync<TLAbsUpdates>(new TLRequestSendMedia()
{
RandomId = Helpers.GenerateRandomLong(),
Background = false,
ClearDraft = false,
Media = new TLInputMediaUploadedPhoto() { File = file, Caption = caption },
Peer = peer
},0);
}
public async Task<TLAbsUpdates> SendUploadedDocument(
TLAbsInputPeer peer, TLAbsInputFile file, string caption, string mimeType, TLVector<TLAbsDocumentAttribute> attributes)
{
return await SendRequestAsync<TLAbsUpdates>(new TLRequestSendMedia()
{
RandomId = Helpers.GenerateRandomLong(),
Background = false,
ClearDraft = false,
Media = new TLInputMediaUploadedDocument()
{
File = file,
Caption = caption,
MimeType = mimeType,
Attributes = attributes
},
Peer = peer
},0);
}
public async Task<TLFile> GetFile(TLAbsInputFileLocation location, int filePartSize, int offset = 0)
{
TLFile result = null;
result = await SendRequestAsync<TLFile>(new TLRequestGetFile()
{
Location = location,
Limit = filePartSize,
Offset = offset
},0);
return result;
}
public async Task SendPingAsync()
{
await _sender.SendPingAsync();
}
public async Task<TLAbsMessages> GetHistoryAsync(TLAbsInputPeer peer, int offsetId = 0, int offsetDate = 0, int addOffset = 0, int limit = 100, int maxId = 0, int minId = 0)
{
if (!IsUserAuthorized())
throw new InvalidOperationException("Authorize user first!");
var req = new TLRequestGetHistory()
{
Peer = peer,
OffsetId = offsetId,
OffsetDate = offsetDate,
AddOffset = addOffset,
Limit = limit,
MaxId = maxId,
MinId = minId
};
return await SendRequestAsync<TLAbsMessages>(req,0);
}
/// <summary>
/// Serch user or chat. API: contacts.search#11f812d8 q:string limit:int = contacts.Found;
/// </summary>
/// <param name="q">User or chat name</param>
/// <param name="limit">Max result count</param>
/// <returns></returns>
public async Task<TLFound> SearchUserAsync(string q, int limit = 10)
{
var r = new TeleSharp.TL.Contacts.TLRequestSearch
{
Q = q,
Limit = limit
};
return await SendRequestAsync<TLFound>(r,0);
}
private void OnUserAuthenticated(TLUser TLUser)
{
_session.TLUser = TLUser;
_session.SessionExpires = int.MaxValue;
_session.Save();
}
public bool IsConnected
{
get
{
if (_transport == null)
return false;
return _transport.IsConnected;
}
}
public void Dispose()
{
if (_transport != null)
{
_transport.Dispose();
_transport = null;
}
}
}
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}")
{
}
}
public class InvalidPhoneCodeException : Exception
{
internal InvalidPhoneCodeException(string msg) : base(msg) { }
}
public class CloudPasswordNeededException : Exception
{
internal CloudPasswordNeededException(string msg) : base(msg) { }
}
}

View file

@ -97,7 +97,7 @@ namespace TLSharp.Core.Utils
FilePart = partNumber,
Bytes = part,
FileTotalParts = partsCount
});
},0);
}
else
{
@ -106,7 +106,7 @@ namespace TLSharp.Core.Utils
FileId = file_id,
FilePart = partNumber,
Bytes = part
});
},0);
}
partNumber++;
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="DotNetZip" version="1.9.3" targetFramework="net451" />
<package id="DotNetZip" version="1.11.0" targetFramework="net451" />
<package id="MarkerMetro.Unity.Ionic.Zlib" version="2.0.0.14" targetFramework="net452" />
</packages>

View file

@ -1,54 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E90B705B-19FA-43BA-B952-69957976D12C}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>TLSharp.Tests.NUnit</RootNamespace>
<AssemblyName>TLSharp.Tests.NUnit</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Test.cs" />
</ItemGroup>
<ItemGroup>
<None Include="..\TLSharp.Tests\app.config">
<Link>app.config</Link>
</None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TLSharp.Tests\TLSharp.Tests.csproj">
<Project>{DE5C0467-EE99-4734-95F2-EFF7A0B99924}</Project>
<Name>TLSharp.Tests</Name>
</ProjectReference>
</ItemGroup>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E90B705B-19FA-43BA-B952-69957976D12C}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>TLSharp.Tests.NUnit</RootNamespace>
<AssemblyName>TLSharp.Tests.NUnit</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Test.cs" />
</ItemGroup>
<ItemGroup>
<None Include="..\TLSharp.Tests\app.config">
<Link>app.config</Link>
</None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TLSharp.Tests\TLSharp.Tests.csproj">
<Project>{DE5C0467-EE99-4734-95F2-EFF7A0B99924}</Project>
<Name>TLSharp.Tests</Name>
</ProjectReference>
</ItemGroup>
</Project>

View file

@ -1,103 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{AFFC3B00-3E4D-4327-8F7A-08EE41E0C8B7}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TLSharp.Tests.VS</RootNamespace>
<AssemblyName>TLSharp.Tests.VS</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
</ItemGroup>
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="TLSharpTestsVs.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TeleSharp.TL\TeleSharp.TL.csproj">
<Project>{d6144517-91d2-4880-86df-e9ff5d7f383a}</Project>
<Name>TeleSharp.TL</Name>
</ProjectReference>
<ProjectReference Include="..\TLSharp.Core\TLSharp.Core.csproj">
<Project>{400d2544-1cc6-4d8a-a62c-2292d9947a16}</Project>
<Name>TLSharp.Core</Name>
</ProjectReference>
<ProjectReference Include="..\TLSharp.Tests\TLSharp.Tests.csproj">
<Project>{de5c0467-ee99-4734-95f2-eff7a0b99924}</Project>
<Name>TLSharp.Tests</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="..\TLSharp.Tests\app.config">
<Link>app.config</Link>
</None>
</ItemGroup>
<ItemGroup />
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
</ItemGroup>
</When>
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{AFFC3B00-3E4D-4327-8F7A-08EE41E0C8B7}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TLSharp.Tests.VS</RootNamespace>
<AssemblyName>TLSharp.Tests.VS</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
</ItemGroup>
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="TLSharpTestsVs.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TeleSharp.TL\TeleSharp.TL.csproj">
<Project>{d6144517-91d2-4880-86df-e9ff5d7f383a}</Project>
<Name>TeleSharp.TL</Name>
</ProjectReference>
<ProjectReference Include="..\TLSharp.Core\TLSharp.Core.csproj">
<Project>{400d2544-1cc6-4d8a-a62c-2292d9947a16}</Project>
<Name>TLSharp.Core</Name>
</ProjectReference>
<ProjectReference Include="..\TLSharp.Tests\TLSharp.Tests.csproj">
<Project>{de5c0467-ee99-4734-95f2-eff7a0b99924}</Project>
<Name>TLSharp.Tests</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="..\TLSharp.Tests\app.config">
<Link>app.config</Link>
</None>
</ItemGroup>
<ItemGroup />
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
</ItemGroup>
</When>
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
-->
</Project>

View file

@ -1,67 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DE5C0467-EE99-4734-95F2-EFF7A0B99924}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TLSharp.Tests</RootNamespace>
<AssemblyName>TLSharp.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
</ItemGroup>
<ItemGroup>
<Compile Include="TLSharpTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TeleSharp.TL\TeleSharp.TL.csproj">
<Project>{d6144517-91d2-4880-86df-e9ff5d7f383a}</Project>
<Name>TeleSharp.TL</Name>
</ProjectReference>
<ProjectReference Include="..\TLSharp.Core\TLSharp.Core.csproj">
<Project>{400d2544-1cc6-4d8a-a62c-2292d9947a16}</Project>
<Name>TLSharp.Core</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="data\cat.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DE5C0467-EE99-4734-95F2-EFF7A0B99924}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TLSharp.Tests</RootNamespace>
<AssemblyName>TLSharp.Tests</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
</ItemGroup>
<ItemGroup>
<Compile Include="TLSharpTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TeleSharp.TL\TeleSharp.TL.csproj">
<Project>{d6144517-91d2-4880-86df-e9ff5d7f383a}</Project>
<Name>TeleSharp.TL</Name>
</ProjectReference>
<ProjectReference Include="..\TLSharp.Core\TLSharp.Core.csproj">
<Project>{400d2544-1cc6-4d8a-a62c-2292d9947a16}</Project>
<Name>TLSharp.Core</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="data\cat.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
-->
</Project>

View file

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="ApiHash" value="" />
<add key="ApiId" value="" />
<add key="NumberToAuthenticate" value="" />
<add key="CodeToAuthenticate" value="" />
<add key="PasswordToAuthenticate" value=""/>
<add key="NotRegisteredNumberToSignUp" value=""/>
<add key="NumberToSendMessage" value=""/>
<add key="UserNameToSendMessage" value=""/>
<add key="NumberToGetUserFull" value=""/>
<add key="NumberToAddToChat" value=""/>
</appSettings>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="ApiHash" value=""/>
<add key="ApiId" value=""/>
<add key="NumberToAuthenticate" value=""/>
<add key="CodeToAuthenticate" value=""/>
<add key="PasswordToAuthenticate" value=""/>
<add key="NotRegisteredNumberToSignUp" value=""/>
<add key="NumberToSendMessage" value=""/>
<add key="UserNameToSendMessage" value=""/>
<add key="NumberToGetUserFull" value=""/>
<add key="NumberToAddToChat" value=""/>
</appSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration>

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
</configuration>

View file

@ -1,80 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9BE3B9D4-9FF6-4DC8-B9CC-EB2E3F390129}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TeleSharp.Generator</RootNamespace>
<AssemblyName>TeleSharp.Generator</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Models.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<Content Include="Method.tmp">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup>
<Content Include="Constructor.tmp">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="ConstructorAbs.tmp">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9BE3B9D4-9FF6-4DC8-B9CC-EB2E3F390129}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TeleSharp.Generator</RootNamespace>
<AssemblyName>TeleSharp.Generator</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Models.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<Content Include="Method.tmp">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup>
<Content Include="Constructor.tmp">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="ConstructorAbs.tmp">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
-->
</Project>

File diff suppressed because it is too large Load diff