From ab1af4524754f8fc4d0b40927ea58a30a9d2001f Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Sat, 5 Feb 2022 09:49:21 -0500 Subject: [PATCH] Support contact messages --- telegram/utils.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/telegram/utils.go b/telegram/utils.go index ee7b4e8..5b0e2ca 100644 --- a/telegram/utils.go +++ b/telegram/utils.go @@ -469,6 +469,20 @@ func (c *Client) messageToText(message *client.Message) string { formatter.SortEntities(animation.Caption.Entities), markupFunction, ) + case client.TypeMessageContact: + contact, _ := message.Content.(*client.MessageContact) + var jid string + if contact.Contact.UserId != 0 { + jid = fmt.Sprintf("%v@%s", contact.Contact.UserId, gateway.Jid.Bare()) + } + return fmt.Sprintf( + "*%s %s*\n%s\n%s\n%s", + contact.Contact.FirstName, + contact.Contact.LastName, + contact.Contact.PhoneNumber, + contact.Contact.Vcard, + jid, + ) } return fmt.Sprintf("unknown message (%s)", message.Content.MessageContentType())