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

View File

@ -442,6 +442,13 @@ class TeleBot:
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):
"""
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)
def register_for_reply(self, message, callback):
"""
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)
@staticmethod
def _test_message_handler(message_handler, message):
for filter, filter_value in six.iteritems(message_handler['filters']):

View File

@ -203,6 +203,21 @@ def send_venue(token, chat_id, latitude, longitude, title, address, foursquare_i
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):
method_url = r'sendChatAction'
payload = {'chat_id': chat_id, 'action': action}