diff --git a/telebot/__init__.py b/telebot/__init__.py index 0b45d5f..f34f96f 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -509,6 +509,18 @@ class TeleBot: return apihelper.answer_inline_query(self.token, inline_query_id, results, cache_time, is_personal, next_offset, switch_pm_text, switch_pm_parameter) + def answer_callback_query(self, callback_query_id, text=None, show_alert=None): + """ + Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to + the user as a notification at the top of the chat screen or as an alert. + :param callback_query_id: + :param text: + :param show_alert: + :return: + """ + 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. diff --git a/telebot/apihelper.py b/telebot/apihelper.py index 842c699..76cca75 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -389,6 +389,16 @@ def answer_inline_query(token, inline_query_id, results, cache_time=None, is_per return _make_request(token, method_url, params=payload, method='post') +def answer_callback_query(token, callback_query_id, text=None, show_alert=None): + method_url = 'answerCallbackQuery' + payload = {'callback_query_id': callback_query_id} + if text: + payload['text'] = text + if show_alert: + payload['show_alert'] = show_alert + return _make_request(token, method_url, params=payload, method='post') + + def _convert_inline_results(results): ret = '' for r in results: