farhad4a
farhad4a

Reputation: 13

how to add contacts in telegram-cli by using vcard?

im trying to add my contacts in telegram-cli by using vcard. but when i use this command:

import_card <card>

nothing happen! it just goes to next line without any error and no contact added.

my vcard is VERSION:2.1

how can i improt my contacts to my telegram account by using vcard?

Upvotes: 1

Views: 3237

Answers (2)

Ali asghar Fendereski
Ali asghar Fendereski

Reputation: 157

private async Task<bool> ImportContact(string _phone , string _first_name , string _last_name)
        {
            //https://github.com/sochix/TLSharp/issues/243
            var phoneContact = new TLInputPhoneContact() { phone = _phone, first_name = _first_name, last_name = _last_name };
            var contacts = new List<TLInputPhoneContact>() { phoneContact };
            var req = new TLRequestImportContacts() { contacts = new TLVector<TLInputPhoneContact>() { lists = contacts } };
            TLImportedContacts result = await client.SendRequestAsync<TLImportedContacts>(req);
            if (result.users.lists.Count > 0)
                return true;
            else return false;
        }

Upvotes: 0

Masoud Sojodi
Masoud Sojodi

Reputation: 24

Install-Package TLSharp

 client = new TelegramClient(apiId, apiHash);
    await client.ConnectAsync();
    var phoneContact = new TLInputPhoneContact() { phone = "", first_name = "", last_name = "" };
    var contacts = new List<TLInputPhoneContact>() { phoneContact };
    var req = new TeleSharp.TL.Contacts.TLRequestImportContacts() { contacts = new TLVector<TLInputPhoneContact>() { lists = contacts } };
    var rrr=     await client.SendRequestAsync<TeleSharp.TL.Contacts.TLImportedContacts>(req);

Upvotes: 1

Related Questions