How to import a list of contacts to telegram from desktop application?

14,040

Solution 1

If you use TLSharp library in your desktop application, easily you can call contacts.importContacts method in this way:

client = new TelegramClient(apiId, apiHash);
await client.ConnectAsync();
var result = await client.GetContactsAsync();

and for example use the result variable in this way:

var user = result.users.lists
  .Where(x => x.GetType() == typeof(TLUser))
  .Cast<TLUser>()
  .Where(x => x.first_name == textBox1.Text);
if (user.ToList().Count != 0)
{
    foreach (var u in user)
    await client.SendMessageAsync(new TLInputPeerUser() { user_id = u.id }, textBox1.Text);
}

Solution 2

You can try Settings -> Advanced -> Export your telegram data, in the bottom of the window you will see a JSON switch
If you're on Mac OS and don't see Advanced option, then you can try Telegram Lite from Mac App Store

Share:
14,040
Admin
Author by

Admin

Updated on June 15, 2022

Comments

  • Admin
    Admin about 2 years

    Is there a way to easily import a list of contacts to telegram from desktop application?

    I found contacts.importContacts method in Telegram API, but don't understand how to use it.

  • planetmaker
    planetmaker about 7 years
    A short comment to your code what it does / why / how it solves the problem would go a long way from one answer to a good answer
  • mjyazdani
    mjyazdani about 7 years
    Apparently, there are some limitations on importing new contacts. The telegram had blocked me out for trying to import 24000 contacts at once.