private void SendContact(ContactBubble contactBubble) { var inputPeer = GetInputPeer(contactBubble.Address, contactBubble.Party, contactBubble.ExtendedParty); var contactCard = Platform.GenerateContactCardFromBytes(contactBubble.VCardData); if (contactCard != null) { using (var client = new FullClientDisposable(this)) { var updates = TelegramUtils.RunSynchronously( client.Client.Methods.MessagesSendMediaAsync(new MessagesSendMediaArgs { Flags = 0, Peer = inputPeer, Media = new InputMediaContact { FirstName = contactCard.GivenName, LastName = contactCard.FamilyName, PhoneNumber = contactCard.Phones?.FirstOrDefault()?.Number }, RandomId = GenerateRandomId(), })); var id = GetMessageId(updates); contactBubble.IdService = id; SendToResponseDispatcher(updates, client.Client); } } }
private ContactBubble MakeContactBubble(Message message, bool isUser, bool useCurrentTime, string addressStr, string participantAddress, byte[] vCardData, string name) { ContactBubble bubble; if (isUser) { bubble = new ContactBubble(useCurrentTime ? Time.GetNowUnixTimestamp() : (long)message.Date, message.Out != null ? Bubble.BubbleDirection.Outgoing : Bubble.BubbleDirection.Incoming, addressStr, null, false, this, name, vCardData, message.Id.ToString(CultureInfo.InvariantCulture)); } else { bubble = new ContactBubble(useCurrentTime ? Time.GetNowUnixTimestamp() : (long)message.Date, message.Out != null ? Bubble.BubbleDirection.Outgoing : Bubble.BubbleDirection.Incoming, addressStr, participantAddress, true, this, name, vCardData, message.Id.ToString(CultureInfo.InvariantCulture)); } if (bubble.Direction == Bubble.BubbleDirection.Outgoing) { bubble.Status = Bubble.BubbleStatus.Sent; } return bubble; }