telegram.InlineQuery
- class telegram.InlineQuery(id, from_user, query, offset, location=None, bot=None, chat_type=None, **_kwargs)
Bases:
telegram.base.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.Note
In Python
fromis a reserved word, usefrom_userinstead.- Parameters
id (
str) – Unique identifier for this query.from_user (
telegram.User) – Sender.query (
str) – Text of the query (up to 256 characters).offset (
str) – Offset of the results to be returned, can be controlled by the bot.chat_type (
str, optional) –Type of the chat, from which the inline query was sent. Can be either
telegram.Chat.SENDERfor a private chat with the inline query sender,telegram.Chat.PRIVATE,telegram.Chat.GROUP,telegram.Chat.SUPERGROUPortelegram.Chat.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.New in version 13.5.
location (
telegram.Location, optional) – Sender location, only for bots that request user location.bot (
telegram.Bot, optional) – The Bot to use for instance methods.**kwargs (
dict) – Arbitrary keyword arguments.
- id
Unique identifier for this query.
- Type
str
- from_user
Sender.
- Type
- query
Text of the query (up to 256 characters).
- Type
str
- offset
Offset of the results to be returned, can be controlled by the bot.
- Type
str
- location
Optional. Sender location, only for bots that request user location.
- Type
- chat_type
Type of the chat, from which the inline query was sent.
New in version 13.5.
- Type
str, optional
- MAX_RESULTS = 50
telegram.constants.MAX_INLINE_QUERY_RESULTSNew in version 13.2.
- answer(results, cache_time=300, is_personal=None, next_offset=None, switch_pm_text=None, switch_pm_parameter=None, timeout=None, current_offset=None, api_kwargs=None, auto_pagination=False)
Shortcut for:
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().- Parameters
auto_pagination (
bool, optional) – If set toTrue,offsetwill be passed ascurrent_offsettotelegram.Bot.answer_inline_query(). Defaults toFalse.- Raises
TypeError – If both
current_offsetandauto_paginationare supplied.
- classmethod de_json(data, bot)