1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Add send_contact

This commit is contained in:
eternnoir 2016-04-16 15:07:52 +08:00
parent 22ab50989e
commit 7490f63f25
2 changed files with 22 additions and 2 deletions

@ -442,6 +442,13 @@ class TeleBot:
disable_notification, reply_to_message_id, reply_markup) disable_notification, reply_to_message_id, reply_markup)
) )
def send_contact(self, chat_id, phone_number, first_name, last_name=None, disable_notification=None,
reply_to_message_id=None, reply_markup=None):
return types.Message.de_json(
apihelper.send_contact(self.token, chat_id, phone_number, first_name, last_name, disable_notification,
reply_to_message_id, reply_markup)
)
def send_chat_action(self, chat_id, action): def send_chat_action(self, chat_id, action):
""" """
Use this method when you need to tell the user that something is happening on the bot's side. Use this method when you need to tell the user that something is happening on the bot's side.
@ -520,7 +527,6 @@ class TeleBot:
""" """
return apihelper.answer_callback_query(self.token, callback_query_id, text, show_alert) return apihelper.answer_callback_query(self.token, callback_query_id, text, show_alert)
def register_for_reply(self, message, callback): def register_for_reply(self, message, callback):
""" """
Registers a callback function to be notified when a reply to `message` arrives. Registers a callback function to be notified when a reply to `message` arrives.
@ -689,7 +695,6 @@ class TeleBot:
self.callback_query_handlers.append(handler_dict) self.callback_query_handlers.append(handler_dict)
@staticmethod @staticmethod
def _test_message_handler(message_handler, message): def _test_message_handler(message_handler, message):
for filter, filter_value in six.iteritems(message_handler['filters']): for filter, filter_value in six.iteritems(message_handler['filters']):

@ -203,6 +203,21 @@ def send_venue(token, chat_id, latitude, longitude, title, address, foursquare_i
return _make_request(token, method_url, params=payload) return _make_request(token, method_url, params=payload)
def send_contact(token, chat_id, phone_number, first_name, last_name=None, disable_notification=None,
reply_to_message_id=None, reply_markup=None):
method_url = r'sendContact'
payload = {'chat_id': chat_id, 'phone_number': phone_number, 'first_name': first_name}
if last_name:
payload['last_name'] = last_name
if disable_notification:
payload['disable_notification'] = disable_notification
if reply_to_message_id:
payload['reply_to_message_id'] = reply_to_message_id
if reply_markup:
payload['reply_markup'] = _convert_markup(reply_markup)
return _make_request(token, method_url, params=payload)
def send_chat_action(token, chat_id, action): def send_chat_action(token, chat_id, action):
method_url = r'sendChatAction' method_url = r'sendChatAction'
payload = {'chat_id': chat_id, 'action': action} payload = {'chat_id': chat_id, 'action': action}