Skip to content

Commit 4c7598c

Browse files
authored
Support for contact vcards (#157)
* Add vcard parameter in send_contact function * Add docs for send_contact * Add attribute vcard in Contact class and related docs * Fix PEP-8 * Fix documentation * Fix documentation * Add myself to project contributors
1 parent e07d990 commit 4c7598c

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Contributors:
1515
Ilya Otyutskiy <ilya.otyutskiy@icloud.com>
1616
Stefano Teodorani <s.teodorani@gmail.com>
1717
Francesco Zimbolo <dtrandom@randomdev.tk>
18+
Daniele Ceribelli <danieleceribelli@gmail.com>
1819

1920
Original author:
2021

botogram/objects/media.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ class Contact(BaseObject):
247247
optional = {
248248
"last_name": str,
249249
"user_id": int,
250+
"vcard": str,
250251
}
251252
_check_equality_ = "phone_number"
252253

botogram/objects/mixins.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@ def send_sticker(self, sticker=None, reply_to=None, extra=None,
355355
expect=_objects().Message)
356356

357357
@_require_api
358-
def send_contact(self, phone, first_name, last_name=None, *, reply_to=None,
358+
def send_contact(self, phone, first_name, last_name=None,
359+
vcard=None, *, reply_to=None,
359360
extra=None, attach=None, notify=True):
360361
"""Send a contact"""
361362
args = self._get_call_args(reply_to, extra, attach, notify)
@@ -364,6 +365,8 @@ def send_contact(self, phone, first_name, last_name=None, *, reply_to=None,
364365

365366
if last_name is not None:
366367
args["last_name"] = last_name
368+
if vcard is not None:
369+
args["vcard"] = vcard
367370

368371
return self._api.call("sendContact", args, expect=_objects().Message)
369372

docs/api/telegram.rst

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ about its business.
557557

558558
Now the method returns the sent message
559559

560-
.. py:method:: send_contact(phone, first_name, [last_name=None, reply_to=None, attach=None, extra=None, notify=True])
560+
.. py:method:: send_contact(phone, first_name, [last_name=None, vcard=None, reply_to=None, attach=None, extra=None, notify=True])
561561
562562
Send a contact to the user. A Telegram contact is made of its phone
563563
number (with the international prefix), its first name and optionally its
@@ -577,6 +577,7 @@ about its business.
577577
:param str phone: The phone number of the contact
578578
:param str first_name: The first name of the contact
579579
:param str last_name: The last name of the contact
580+
:param str vcard: The contact vcard
580581
:param int reply_to: The ID of the :py:class:`~botogram.Message` this one is replying to
581582
:param object attach: An extra thing to attach to the message.
582583
:param object extra: An extra reply interface object to attach
@@ -1438,7 +1439,7 @@ about its business.
14381439

14391440
Now the method returns the sent message
14401441

1441-
.. py:method:: send_contact(phone, first_name, [last_name=None, reply_to=None, attach=None, extra=None, notify=True])
1442+
.. py:method:: send_contact(phone, first_name, [last_name=None, vcard=None, reply_to=None, attach=None, extra=None, notify=True])
14421443
14431444
Send a contact to the chat. A Telegram contact is made of its phone
14441445
number (with the international prefix), its first name and optionally its
@@ -1455,6 +1456,7 @@ about its business.
14551456
:param str phone: The phone number of the contact
14561457
:param str first_name: The first name of the contact
14571458
:param str last_name: The last name of the contact
1459+
:param str vcard: The contact vcard
14581460
:param int reply_to: The ID of the :py:class:`~botogram.Message` this one is replying to
14591461
:param object attach: An extra thing to attach to the message.
14601462
:param object extra: An extra reply interface object to attach
@@ -2425,7 +2427,7 @@ about its business.
24252427

24262428
Now the method returns the sent message
24272429

2428-
.. py:method:: reply_with_contact(phone, first_name, [last_name=None, attach=None, extra=None, notify=True])
2430+
.. py:method:: reply_with_contact(phone, first_name, [last_name=None, vcard=None, attach=None, extra=None, notify=True])
24292431
24302432
Reply to this message with a contact. A Telegram contact is made of its
24312433
phone number (with the international prefix), its first name and
@@ -2442,6 +2444,7 @@ about its business.
24422444
:param str phone: The phone number of the contact
24432445
:param str first_name: The first name of the contact
24442446
:param str last_name: The last name of the contact
2447+
:param str vcard: The contact vcard
24452448
:param object attach: An extra thing to attach to the message.
24462449
:param object extra: An extra reply interface object to attach
24472450
:param bool notify: If you want to trigger a notification on the client
@@ -2981,6 +2984,11 @@ about its business.
29812984

29822985
*This attribute can be None if it's not provided by Telegram.*
29832986

2987+
.. py:attribute:: vcard
2988+
2989+
The vcard of the contact.
2990+
2991+
*This attribute can be None if it's not provided by Telegram.*
29842992

29852993
.. py:class:: botogram.Location
29862994

docs/changelog/0.7.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ New features
7171
* New method :py:meth:`Chat.remove_photo`
7272
* New attribute :py:attr:`Chat.photo`
7373

74+
* Added support for vcards in contacts
75+
* New argument ``vcard`` in :py:meth:`botogram.Chat.send_contact`
76+
* New argument ``vcard`` in :py:meth:`botogram.User.send_contact`
77+
* New argument ``vcard`` in :py:meth:`botogram.Message.reply_with_contact`
78+
* New attribute :py:attr:`Contact.vcard`
79+
7480
Bug fixes
7581
---------
7682

0 commit comments

Comments
 (0)