Skip to content
This repository was archived by the owner on Oct 7, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions ExportTelegramContacts/ExportTelegramContacts.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>Exe</OutputType>
<RootNamespace>ExportTelegramContacts</RootNamespace>
<AssemblyName>ExportTelegramContacts</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
Expand All @@ -32,15 +32,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="BigMath, Version=0.5.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\TLSharp.0.1.0.394\lib\net45\BigMath.dll</HintPath>
</Reference>
<Reference Include="DotNetZip, Version=1.13.3.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL">
<HintPath>..\packages\DotNetZip.1.13.3\lib\net40\DotNetZip.dll</HintPath>
</Reference>
<Reference Include="Ionic.ZLib, Version=2.0.0.14, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\TLSharp.0.1.0.394\lib\net45\Ionic.ZLib.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
Expand All @@ -52,10 +46,10 @@
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="TeleSharp.TL, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\TLSharp.0.1.0.394\lib\net45\TeleSharp.TL.dll</HintPath>
<HintPath>..\packages\TLSharp.0.1.0.574\lib\net46\TeleSharp.TL.dll</HintPath>
</Reference>
<Reference Include="TLSharp.Core, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\TLSharp.0.1.0.394\lib\net45\TLSharp.Core.dll</HintPath>
<HintPath>..\packages\TLSharp.0.1.0.574\lib\net46\TLSharp.Core.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
47 changes: 44 additions & 3 deletions ExportTelegramContacts/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);

Expand All @@ -355,7 +357,46 @@ private static async Task CallAuthenicate()
#endif

}
catch (Exception ex)
catch (CloudPasswordNeededException)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might integrate this thanks for letting me know if this exception

{
TLPassword passwordSetting = await _client.GetPasswordSetting();
Console.WriteLine("This account needs cloud password.");

TryAgain:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, but this is not acceptable code pattern

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<TLRequestRecoverPassword>(new TLRequestRecoverPassword() { Code = recoveryCode });
}
}
else
{
Console.WriteLine("This account doesn't have recovery!");
}

goto TryAgain;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return;
Expand Down
2 changes: 1 addition & 1 deletion ExportTelegramContacts/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<package id="BigMath" version="0.5.0" targetFramework="net45" />
<package id="DotNetZip" version="1.13.3" targetFramework="net47" />
<package id="MarkerMetro.Unity.Ionic.Zlib" version="2.0.0.14" targetFramework="net45" />
<package id="TLSharp" version="0.1.0.394" targetFramework="net47" />
<package id="TLSharp" version="0.1.0.574" targetFramework="net48" />
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TLSharp is out of support, I'm exploring alternatives

</packages>