Skip to content

Commit 228683a

Browse files
committed
Add new param for anser inline query.
1 parent 4fe4061 commit 228683a

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

‎telebot/__init__.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,8 @@ def reply_to(self, message, text, **kwargs):
482482
"""
483483
return self.send_message(message.chat.id, text, reply_to_message_id=message.message_id, **kwargs)
484484

485-
def answer_inline_query(self, inline_query_id, results, cache_time=None, is_personal=None, next_offset=None):
485+
def answer_inline_query(self, inline_query_id, results, cache_time=None, is_personal=None, next_offset=None,
486+
switch_pm_text=None, switch_pm_parameter=None):
486487
"""
487488
Use this method to send answers to an inline query. On success, True is returned.
488489
No more than 50 results per query are allowed.
@@ -491,9 +492,13 @@ def answer_inline_query(self, inline_query_id, results, cache_time=None, is_pers
491492
:param cache_time: The maximum amount of time in seconds that the result of the inline query may be cached on the server.
492493
:param is_personal: Pass True, if results may be cached on the server side only for the user that sent the query.
493494
:param next_offset: Pass the offset that a client should send in the next query with the same text to receive more results.
495+
:param switch_pm_parameter: If passed, clients will display a button with specified text that switches the user
496+
to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter
497+
:param switch_pm_text: Parameter for the start message sent to the bot when user presses the switch button
494498
:return: True means success.
495499
"""
496-
return apihelper.answer_inline_query(self.token, inline_query_id, results, cache_time, is_personal, next_offset)
500+
return apihelper.answer_inline_query(self.token, inline_query_id, results, cache_time, is_personal, next_offset,
501+
switch_pm_text, switch_pm_parameter)
497502

498503
def register_for_reply(self, message, callback):
499504
"""

‎telebot/apihelper.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,8 @@ def answer_callback_query(token, callback_query_id, text=None, show_alert=None):
372372
return _make_request(token, method_url, params=payload, method='post')
373373

374374

375-
def answer_inline_query(token, inline_query_id, results, cache_time=None, is_personal=None, next_offset=None):
375+
def answer_inline_query(token, inline_query_id, results, cache_time=None, is_personal=None, next_offset=None,
376+
switch_pm_text=None, switch_pm_parameter=None):
376377
method_url = 'answerInlineQuery'
377378
payload = {'inline_query_id': inline_query_id, 'results': _convert_inline_results(results)}
378379
if cache_time:
@@ -381,6 +382,10 @@ def answer_inline_query(token, inline_query_id, results, cache_time=None, is_per
381382
payload['is_personal'] = is_personal
382383
if next_offset:
383384
payload['next_offset'] = next_offset
385+
if switch_pm_text:
386+
payload['switch_pm_text'] = switch_pm_text
387+
if switch_pm_parameter:
388+
payload['switch_pm_parameter'] = switch_pm_parameter
384389
return _make_request(token, method_url, params=payload, method='post')
385390

386391

0 commit comments

Comments
 (0)