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
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on June 15, 2022Comments
-
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 about 7 yearsA 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 about 7 yearsApparently, there are some limitations on importing new contacts. The telegram had blocked me out for trying to import 24000 contacts at once.