diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index 7b61e61..97f4ac8 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -18,13 +18,15 @@ namespace TLSharp.Core private MtProtoSender _sender; private AuthKey _key; private TcpTransport _transport; - private string _apiHash = "a2514f96431a228e4b9ee473f6c51945"; - private int _apiId = 19474; + private string _apiHash = ""; + private int _apiId = 0; private Session _session; private List dcOptions; - public TelegramClient(ISessionStore store, string sessionUserId) + public TelegramClient(ISessionStore store, string sessionUserId, string apiHash, int apiId) { + _apiHash = apiHash; + _apiId = apiId; if (_apiId == 0) throw new InvalidOperationException("Your API_ID is invalid. Do a configuration first https://github.com/sochix/TLSharp#quick-configuration"); diff --git a/TLSharp.Tests/TLSharpTests.cs b/TLSharp.Tests/TLSharpTests.cs index ecd564d..e0d1764 100644 --- a/TLSharp.Tests/TLSharpTests.cs +++ b/TLSharp.Tests/TLSharpTests.cs @@ -19,6 +19,10 @@ namespace TLSharp.Tests private string UserNameToSendMessage { get; set; } + private string apiHash = ""; + + private int apiId = 0; + [TestInitialize] public void Init() { @@ -41,7 +45,7 @@ namespace TLSharp.Tests public async Task AuthUser() { var store = new FileSessionStore(); - var client = new TelegramClient(store, "session"); + var client = new TelegramClient(store, "session", apiHash, apiId); await client.Connect(); @@ -57,7 +61,7 @@ namespace TLSharp.Tests public async Task CheckPhones() { var store = new FileSessionStore(); - var client = new TelegramClient(store, "session"); + var client = new TelegramClient(store, "session", apiHash, apiId); await client.Connect(); var result = await client.IsPhoneRegistered(NumberToAuthenticate); @@ -70,7 +74,7 @@ namespace TLSharp.Tests // User should be already authenticated! var store = new FileSessionStore(); - var client = new TelegramClient(store, "session"); + var client = new TelegramClient(store, "session", apiHash, apiId); await client.Connect(); @@ -85,7 +89,7 @@ namespace TLSharp.Tests public async Task ImportByUserName() { var store = new FileSessionStore(); - var client = new TelegramClient(store, "session"); + var client = new TelegramClient(store, "session", apiHash, apiId); await client.Connect(); @@ -100,7 +104,7 @@ namespace TLSharp.Tests public async Task ImportByUserNameAndSendMessage() { var store = new FileSessionStore(); - var client = new TelegramClient(store, "session"); + var client = new TelegramClient(store, "session", apiHash, apiId); await client.Connect(); @@ -119,7 +123,7 @@ namespace TLSharp.Tests // User should be already authenticated! var store = new FileSessionStore(); - var client = new TelegramClient(store, "session"); + var client = new TelegramClient(store, "session", apiHash, apiId); await client.Connect(); Assert.IsTrue(client.IsUserAuthorized()); @@ -135,7 +139,7 @@ namespace TLSharp.Tests public async Task GetHistory() { var store = new FileSessionStore(); - var client = new TelegramClient(store, "session"); + var client = new TelegramClient(store, "session", apiHash, apiId); await client.Connect(); Assert.IsTrue(client.IsUserAuthorized()); @@ -153,7 +157,7 @@ namespace TLSharp.Tests public async Task UploadAndSendMedia() { var store = new FileSessionStore(); - var client = new TelegramClient(store, "session"); + var client = new TelegramClient(store, "session", apiHash, apiId); await client.Connect(); Assert.IsTrue(client.IsUserAuthorized()); @@ -178,7 +182,7 @@ namespace TLSharp.Tests public async Task TestConnection() { var store = new FakeSessionStore(); - var client = new TelegramClient(store, ""); + var client = new TelegramClient(store, "", apiHash, apiId); Assert.IsTrue(await client.Connect()); }