Add vCard support for contacts

This commit is contained in:
Dan 2018-07-12 00:10:33 +02:00
parent b6a4dee787
commit f242aceb31
3 changed files with 22 additions and 8 deletions

View File

@ -360,6 +360,7 @@ def parse_messages(
phone_number=media.phone_number,
first_name=media.first_name,
last_name=media.last_name or None,
vcard=media.vcard or None,
user_id=media.user_id or None
)
elif isinstance(media, types.MessageMediaVenue):

View File

@ -26,6 +26,7 @@ class SendContact(BaseClient):
phone_number: str,
first_name: str,
last_name: str = "",
vcard: str = "",
disable_notification: bool = None,
reply_to_message_id: int = None,
reply_markup=None):
@ -47,6 +48,9 @@ class SendContact(BaseClient):
last_name (``str``, *optional*):
Contact's last name.
vcard (``str``, *optional*):
Contact's vCard information.
disable_notification (``bool``, *optional*):
Sends the message silently.
Users will receive a notification with no sound.
@ -68,9 +72,10 @@ class SendContact(BaseClient):
functions.messages.SendMedia(
peer=self.resolve_peer(chat_id),
media=types.InputMediaContact(
phone_number,
first_name,
last_name
phone_number=phone_number,
first_name=first_name,
last_name=last_name,
vcard=vcard
),
message="",
silent=disable_notification or None,

View File

@ -38,8 +38,16 @@ class Contact(Object):
ID = 0xb0700011
def __init__(self, phone_number: str, first_name: str, last_name: str = None, user_id=None):
self.phone_number = phone_number # string
self.first_name = first_name # string
self.last_name = last_name # flags.0?string
self.user_id = user_id # flags.1?int
def __init__(
self,
phone_number: str,
first_name: str,
last_name: str = None,
vcard: str = None,
user_id: int = None
):
self.phone_number = phone_number
self.first_name = first_name
self.last_name = last_name
self.vcard = vcard
self.user_id = user_id