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

天涯浪子 提交于 2019-12-06 22:50:33

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);
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;
        }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!