telegram.InlineQuery

class telegram.InlineQuery(id: str, from_user: telegram.user.User, query: str, offset: str, location: telegram.files.location.Location = None, bot: Bot = None, **_kwargs)

Bases: telegram.base.TelegramObject

This 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 id is equal.

Note

  • In Python from is a reserved word, use from_user instead.
Parameters:
  • id (str) – Unique identifier for this query.
  • from_user (telegram.User) – Sender.
  • location (telegram.Location, optional) – Sender location, only for bots that request user location.
  • 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.
  • 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:telegram.User
location

Optional. Sender location, only for bots that request user location.

Type:telegram.Location
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
MAX_RESULTS = 50

telegram.constants.MAX_INLINE_QUERY_RESULTS

New in version 13.2.

answer(results: Union[List[InlineQueryResult], Callable[[int], Optional[List[InlineQueryResult]]]], cache_time: int = 300, is_personal: bool = None, next_offset: str = None, switch_pm_text: str = None, switch_pm_parameter: str = None, timeout: Union[DefaultValue[DVType], float, None] = None, current_offset: str = None, api_kwargs: Dict[str, Any] = None, auto_pagination: bool = False) → bool

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 to True, offset will be passed as current_offset to telegram.Bot.answer_inline_query(). Defaults to False.
Raises:TypeError – If both current_offset and attr:auto_pagination are supplied.