InlineQuery¶
- class telegram.InlineQuery(id, from_user, query, offset, location=None, chat_type=None, *, api_kwargs=None)[source]¶
Bases:
telegram.TelegramObjectThis object represents an incoming inline query. When the user sends an empty query, your bot could return some default or trending results.
Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their
idis equal.Inline queries on Telegram¶
See also
The
telegram.InlineQueryResultclasses represent the media the user can choose from (see above figure).Available In
Changed in version 20.0: The following are now keyword-only arguments in Bot methods:
{read, write, connect, pool}_timeout,answer.api_kwargs,auto_pagination. Use a named argument for those, and notice that some positional arguments changed position as a result.Changed in version 22.0: Removed constants
MIN_START_PARAMETER_LENGTHandMAX_START_PARAMETER_LENGTH. Usetelegram.constants.InlineQueryResultsButtonLimit.MIN_START_PARAMETER_LENGTHandtelegram.constants.InlineQueryResultsButtonLimit.MAX_START_PARAMETER_LENGTHinstead.- Parameters:
from_user (
telegram.User) – Sender.offset (
str) – Offset of the results to be returned, can be controlled by the bot.Type of the chat, from which the inline query was sent. Can be either
'sender'for a private chat with the inline query sender,'private','group','supergroup'or'channel'. The chat type should be always known for requests sent from official clients and most third-party clients, unless the request was sent from a secret chat.Added in version 13.5.
location (
telegram.Location, optional) – Sender location, only for bots that request user location.
- chat_type[source]¶
Optional. Type of the chat, from which the inline query was sent. Can be either
'sender'for a private chat with the inline query sender,'private','group','supergroup'or'channel'. The chat type should be always known for requests sent from official clients and most third-party clients, unless the request was sent from a secret chat.Added in version 13.5.
- Type:
- MAX_OFFSET_LENGTH = 64[source]¶
telegram.constants.InlineQueryLimit.MAX_OFFSET_LENGTHAdded in version 20.0.
- MAX_QUERY_LENGTH = 256[source]¶
telegram.constants.InlineQueryLimit.MAX_QUERY_LENGTHAdded in version 20.0.
- MAX_RESULTS = 50[source]¶
telegram.constants.InlineQueryLimit.RESULTSAdded in version 13.2.
- async answer(results, cache_time=None, is_personal=None, next_offset=None, button=None, *, current_offset=None, auto_pagination=False, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.answer_inline_query( update.inline_query.id, *args, current_offset=self.offset if auto_pagination else None, **kwargs )
For the documentation of the arguments, please see
telegram.Bot.answer_inline_query().Changed in version 20.0: Raises
ValueErrorinstead ofTypeError.- Keyword Arguments:
auto_pagination (
bool, optional) – If set toTrue,offsetwill be passed ascurrent_offsettotelegram.Bot.answer_inline_query(). Defaults toFalse.- Raises:
ValueError – If both
current_offsetandauto_paginationare supplied.