diff --git a/ExportTelegramContacts/ExportTelegramContacts.csproj b/ExportTelegramContacts/ExportTelegramContacts.csproj index 7c82e64..32ceb26 100644 --- a/ExportTelegramContacts/ExportTelegramContacts.csproj +++ b/ExportTelegramContacts/ExportTelegramContacts.csproj @@ -8,7 +8,7 @@ Exe ExportTelegramContacts ExportTelegramContacts - v4.7 + v4.8 512 @@ -32,15 +32,9 @@ 4 - - ..\packages\TLSharp.0.1.0.394\lib\net45\BigMath.dll - ..\packages\DotNetZip.1.13.3\lib\net40\DotNetZip.dll - - ..\packages\TLSharp.0.1.0.394\lib\net45\Ionic.ZLib.dll - @@ -52,10 +46,10 @@ - ..\packages\TLSharp.0.1.0.394\lib\net45\TeleSharp.TL.dll + ..\packages\TLSharp.0.1.0.574\lib\net46\TeleSharp.TL.dll - ..\packages\TLSharp.0.1.0.394\lib\net45\TLSharp.Core.dll + ..\packages\TLSharp.0.1.0.574\lib\net46\TLSharp.Core.dll diff --git a/ExportTelegramContacts/Program.cs b/ExportTelegramContacts/Program.cs index 8b7b2bd..fa0e14b 100644 --- a/ExportTelegramContacts/Program.cs +++ b/ExportTelegramContacts/Program.cs @@ -10,8 +10,10 @@ using System.Threading.Tasks; using TeleSharp.TL; using TeleSharp.TL.Account; +using TeleSharp.TL.Auth; using TeleSharp.TL.Contacts; using TLSharp.Core; +using TLSharp.Core.Exceptions; namespace ExportTelegramContacts { @@ -343,8 +345,8 @@ private static async Task CallAuthenicate() } Console.Write("Request is sent to your mobile or the telegram app associated with this number, please enter the code here: "); var authCode = Console.ReadLine(); - - try + TLUser user; + try { _user = await _client.MakeAuthAsync(phoneNumber, requestHash, authCode); @@ -355,7 +357,46 @@ private static async Task CallAuthenicate() #endif } - catch (Exception ex) + catch (CloudPasswordNeededException) + { + TLPassword passwordSetting = await _client.GetPasswordSetting(); + Console.WriteLine("This account needs cloud password."); + + TryAgain: + Console.Write("Enter your password: "); + string password = Console.ReadLine(); + + try + { + user = await _client.MakeAuthWithPasswordAsync( passwordSetting, password); + } + catch // If wrong password + { + Console.WriteLine("Hint: " + passwordSetting.Hint); + + if (passwordSetting.HasRecovery) + { + Console.WriteLine("Do you want to reset your password? [Y|N]"); + string answer = Console.ReadLine(); + if (answer == "Y") + { + Console.WriteLine("Recovery email: " + passwordSetting.EmailUnconfirmedPattern); + + // Recover password + Console.Write("Enter email recovery code: "); + string recoveryCode = Console.ReadLine(); + _client.SendRequestAsync(new TLRequestRecoverPassword() { Code = recoveryCode }); + } + } + else + { + Console.WriteLine("This account doesn't have recovery!"); + } + + goto TryAgain; + } + } + catch (Exception ex) { Console.WriteLine(ex.Message); return; diff --git a/ExportTelegramContacts/packages.config b/ExportTelegramContacts/packages.config index f1cdc39..550b731 100644 --- a/ExportTelegramContacts/packages.config +++ b/ExportTelegramContacts/packages.config @@ -3,5 +3,5 @@ - + \ No newline at end of file