I want to send a message to someone when he share contact to me, this is my code:
foreach (var update in updates.UpdateList)
{
switch (update)
{
case UpdateNewMessage unm:
...
break;
case UpdatePeerSettings ups:
try
{
if (Users.TryGetValue(ups.peer.ID, out TL.User User))
{
Contacts_Contacts contacts = await _client.Contacts_GetContacts();
var contact = await _client.Contacts_ImportContacts(new[] { new InputPhoneContact { phone = User.phone} });
await _client.SendMessageAsync(contact.users[0], "Hello");
if (!contacts.users.ContainsKey(ups.peer.ID))
{
contacts.users.Add(ups.peer.ID, User);
}
}
else
{
Contacts_Contacts contacts = await _client.Contacts_GetContacts();
if (!contacts.users.ContainsKey(ups.peer.ID))
{
contacts.users.Add(ups.peer.ID, User);
}
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
break;
default:
break;
}
}
but why can not add he to my contact. how can i add he to my contact programly.
