From dd0f7ab1d502b52597ed53b92cbed8966c9e3c59 Mon Sep 17 00:00:00 2001 From: eternnoir Date: Sun, 28 Jun 2015 17:56:32 +0800 Subject: [PATCH 1/2] Send chat action support. --- telebot/__init__.py | 12 ++++++++++++ telebot/apihelper.py | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/telebot/__init__.py b/telebot/__init__.py index 975afb8..4ebb48c 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -202,3 +202,15 @@ class TeleBot: :return: """ return apihelper.send_location(self.token, chat_id, latitude, longitude, 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. + The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear + its typing status). + :param chat_id: + :param action: string . typing,upload_photo,record_video,upload_video,record_audio,upload_audio,upload_document, + find_location. + :return: + """ + return apihelper.send_chat_action(self.token, chat_id, action) diff --git a/telebot/apihelper.py b/telebot/apihelper.py index 1aea1c1..8c2e5f7 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -82,6 +82,13 @@ def send_location(token, chat_id, latitude, longitude, reply_to_message_id=None, req = requests.get(request_url, params=payload) return check_result(method_url, req) +def send_chat_action(token,chat_id,action): + api_url = telebot.API_URL + method_url = r'sendChatAction' + request_url = api_url + 'bot' + token + '/' + method_url + payload = {'chat_id': chat_id, 'action': action} + req = requests.get(request_url, params=payload) + return check_result(method_url, req) def send_data(token, chat_id, data, data_type, reply_to_message_id=None, reply_markup=None): api_url = telebot.API_URL From a8af3eb269aec475a09ff5e1af36e12a2a18f8e1 Mon Sep 17 00:00:00 2001 From: eternnoir Date: Sun, 28 Jun 2015 17:58:15 +0800 Subject: [PATCH 2/2] Add send_chat_action to readme. --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 93a2e73..b879cca 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,11 @@ tb.send_video(chat_id, video) # sendLocation tb.send_location(chat_id, lat, lon) +# sendChatAction +# action_string can be : typing,upload_photo,record_video,upload_video,record_audio,upload_audio,upload_document, +# find_location. +tb.send_chat_action(chat_id, action_string) + ``` ## Message notifier