mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Almost done.
This commit is contained in:
parent
c706a7aba3
commit
94f1bbd402
@ -415,6 +415,9 @@ class TeleBot:
|
|||||||
"""
|
"""
|
||||||
return self.send_message(message.chat.id, text, reply_to_message_id=message.message_id, **kwargs)
|
return self.send_message(message.chat.id, text, reply_to_message_id=message.message_id, **kwargs)
|
||||||
|
|
||||||
|
def answer_inline_query(self, inline_query_id, results, cache_time=None, is_personal=None, next_offset=None):
|
||||||
|
return apihelper.answer_inline_query(self.token, inline_query_id, results, cache_time, is_personal, next_offset)
|
||||||
|
|
||||||
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.
|
||||||
|
@ -258,11 +258,34 @@ def get_method_by_type(data_type):
|
|||||||
return r'sendSticker'
|
return r'sendSticker'
|
||||||
|
|
||||||
|
|
||||||
|
def answer_inline_query(token, inline_query_id, results, cache_time=None, is_personal=None, next_offset=None):
|
||||||
|
method_url = 'answerInlineQuery'
|
||||||
|
payload = {'inline_query_id': inline_query_id, 'results': _convert_inline_results(results)}
|
||||||
|
if cache_time:
|
||||||
|
payload['cache_time'] = cache_time
|
||||||
|
if is_personal:
|
||||||
|
payload['is_personal'] = is_personal
|
||||||
|
if next_offset:
|
||||||
|
payload['next_offset'] = next_offset
|
||||||
|
return _make_request(token, method_url, params=payload)
|
||||||
|
|
||||||
|
|
||||||
|
def _convert_inline_results(results):
|
||||||
|
ret = ''
|
||||||
|
for r in results:
|
||||||
|
if isinstance(r, types.JsonSerializable):
|
||||||
|
ret = ret + r.to_json() + ','
|
||||||
|
if len(ret) > 0:
|
||||||
|
ret = ret[:-1]
|
||||||
|
return '[' + ret + ']'
|
||||||
|
|
||||||
|
|
||||||
def _convert_markup(markup):
|
def _convert_markup(markup):
|
||||||
if isinstance(markup, types.JsonSerializable):
|
if isinstance(markup, types.JsonSerializable):
|
||||||
return markup.to_json()
|
return markup.to_json()
|
||||||
return markup
|
return markup
|
||||||
|
|
||||||
|
|
||||||
class ApiException(Exception):
|
class ApiException(Exception):
|
||||||
"""
|
"""
|
||||||
This class represents an Exception thrown when a call to the Telegram API fails.
|
This class represents an Exception thrown when a call to the Telegram API fails.
|
||||||
|
Loading…
Reference in New Issue
Block a user