MCPcopy Index your code
hub / github.com/python-telegram-bot/python-telegram-bot / answer_inline_query

Method answer_inline_query

src/telegram/_bot.py:3873–3967  ·  view source on GitHub ↗

Use this method to send answers to an inline query. No more than :tg-const:`telegram.InlineQuery.MAX_RESULTS` results per query are allowed. Warning: In most use cases :paramref:`current_offset` should not be passed manually. Instead of calling this

(
        self,
        inline_query_id: str,
        results: Sequence["InlineQueryResult"]
        | (Callable[[int], Sequence["InlineQueryResult"] | None]),
        cache_time: TimePeriod | None = None,
        is_personal: bool | None = None,
        next_offset: str | None = None,
        button: InlineQueryResultsButton | None = None,
        *,
        current_offset: str | None = None,
        read_timeout: ODVInput[float] = DEFAULT_NONE,
        write_timeout: ODVInput[float] = DEFAULT_NONE,
        connect_timeout: ODVInput[float] = DEFAULT_NONE,
        pool_timeout: ODVInput[float] = DEFAULT_NONE,
        api_kwargs: JSONDict | None = None,
    )

Source from the content-addressed store, hash-verified

3871 return res
3872
3873 async def answer_inline_query(
3874 self,
3875 inline_query_id: str,
3876 results: Sequence["InlineQueryResult"]
3877 | (Callable[[int], Sequence["InlineQueryResult"] | None]),
3878 cache_time: TimePeriod | None = None,
3879 is_personal: bool | None = None,
3880 next_offset: str | None = None,
3881 button: InlineQueryResultsButton | None = None,
3882 *,
3883 current_offset: str | None = None,
3884 read_timeout: ODVInput[float] = DEFAULT_NONE,
3885 write_timeout: ODVInput[float] = DEFAULT_NONE,
3886 connect_timeout: ODVInput[float] = DEFAULT_NONE,
3887 pool_timeout: ODVInput[float] = DEFAULT_NONE,
3888 api_kwargs: JSONDict | None = None,
3889 ) -> bool:
3890 """
3891 Use this method to send answers to an inline query. No more than
3892 :tg-const:`telegram.InlineQuery.MAX_RESULTS` results per query are allowed.
3893
3894 Warning:
3895 In most use cases :paramref:`current_offset` should not be passed manually. Instead of
3896 calling this method directly, use the shortcut :meth:`telegram.InlineQuery.answer` with
3897 :paramref:`telegram.InlineQuery.answer.auto_pagination` set to :obj:`True`, which will
3898 take care of passing the correct value.
3899
3900 .. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
3901
3902
3903 .. versionchanged:: 20.5
3904 Removed deprecated arguments ``switch_pm_text`` and ``switch_pm_parameter``.
3905
3906 Args:
3907 inline_query_id (:obj:`str`): Unique identifier for the answered query.
3908 results (list[:class:`telegram.InlineQueryResult`] | Callable): A list of results for
3909 the inline query. In case :paramref:`current_offset` is passed,
3910 :paramref:`results` may also be
3911 a callable that accepts the current page index starting from 0. It must return
3912 either a list of :class:`telegram.InlineQueryResult` instances or :obj:`None` if
3913 there are no more results.
3914 cache_time (:obj:`int` | :class:`datetime.timedelta`, optional): The maximum amount of
3915 time in seconds that the
3916 result of the inline query may be cached on the server. Defaults to ``300``.
3917
3918 .. versionchanged:: 21.11
3919 |time-period-input|
3920 is_personal (:obj:`bool`, optional): Pass :obj:`True`, if results may be cached on
3921 the server side only for the user that sent the query. By default,
3922 results may be returned to any user who sends the same query.
3923 next_offset (:obj:`str`, optional): Pass the offset that a client should send in the
3924 next query with the same text to receive more results. Pass an empty string if
3925 there are no more results or if you don't support pagination. Offset length can't
3926 exceed :tg-const:`telegram.InlineQuery.MAX_OFFSET_LENGTH` bytes.
3927 button (:class:`telegram.InlineQueryResultsButton`, optional): A button to be shown
3928 above the inline query results.
3929
3930 .. versionadded:: 20.3

Calls 3

_postMethod · 0.95