如何使用vcard在telegram-cli中添加联系人?

时间:2016-10-21 11:15:45

标签: telegram vcard

我试图通过使用vcard在telegram-cli中添加我的联系人。但是当我使用这个命令时:

import_card <card>
什么都没发生!它只是进入下一行没有任何错误,也没有添加任何联系。

我的vcard是VERSION:2.1

如何使用vcard将联系人插入我的电报帐户?

2 个答案:

答案 0 :(得分:1)

安装包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);

答案 1 :(得分:0)

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;
        }