From 7490f63f25ec3f25a03d91cea66e35d583066b68 Mon Sep 17 00:00:00 2001 From: eternnoir Date: Sat, 16 Apr 2016 15:07:52 +0800 Subject: [PATCH] Add send_contact --- telebot/__init__.py | 9 +++++++-- telebot/apihelper.py | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/telebot/__init__.py b/telebot/__init__.py index f34f96f..98679de 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -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']): diff --git a/telebot/apihelper.py b/telebot/apihelper.py index 76cca75..474eb08 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -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}