2020
2121import pyrogram
2222from pyrogram .api import types
23- from .. bots . inline_query_result import InlineQueryResult
23+ from .inline_query_result import InlineQueryResult
2424from ..messages_and_media import Location
2525from ..pyrogram_type import PyrogramType
26+ from ..update import Update
2627from ..user_and_chats import User
2728
2829
29- class InlineQuery (PyrogramType ):
30+ class InlineQuery (PyrogramType , Update ):
3031 """This object represents an incoming inline query.
31- When the user sends an empty query, your bot could return some default or trending results
32+ When the user sends an empty query, your bot could return some default or trending results.
3233
3334 Args:
3435 id (``str``):
@@ -50,6 +51,7 @@ class InlineQuery(PyrogramType):
5051
5152 def __init__ (
5253 self ,
54+ * ,
5355 client : "pyrogram.client.ext.BaseClient" ,
5456 id : str ,
5557 from_user : User ,
@@ -69,7 +71,6 @@ def __init__(
6971 @staticmethod
7072 def _parse (client , inline_query : types .UpdateBotInlineQuery , users : dict ) -> "InlineQuery" :
7173 return InlineQuery (
72- client = client ,
7374 id = str (inline_query .query_id ),
7475 from_user = User ._parse (client , users [inline_query .user_id ]),
7576 query = inline_query .query ,
@@ -78,7 +79,8 @@ def _parse(client, inline_query: types.UpdateBotInlineQuery, users: dict) -> "In
7879 longitude = inline_query .geo .long ,
7980 latitude = inline_query .geo .lat ,
8081 client = client
81- ) if inline_query .geo else None
82+ ) if inline_query .geo else None ,
83+ client = client
8284 )
8385
8486 def answer (
@@ -90,6 +92,55 @@ def answer(
9092 switch_pm_text : str = "" ,
9193 switch_pm_parameter : str = ""
9294 ):
95+ """Bound method *answer* of :obj:`InlineQuery <pyrogram.InlineQuery>`.
96+
97+ Use this method as a shortcut for:
98+
99+ .. code-block:: python
100+
101+ client.answer_inline_query(
102+ inline_query.id,
103+ results=[...]
104+ )
105+
106+ Example:
107+ .. code-block:: python
108+
109+ inline_query.answer([...])
110+
111+ Args:
112+ results (List of :obj:`InlineQueryResult <pyrogram.InlineQueryResult>`):
113+ A list of results for the inline query.
114+
115+ cache_time (``int``, *optional*):
116+ The maximum amount of time in seconds that the result of the inline query may be cached on the server.
117+ Defaults to 300.
118+
119+ is_personal (``bool``, *optional*):
120+ Pass True, if results may be cached on the server side only for the user that sent the query.
121+ By default, results may be returned to any user who sends the same query.
122+
123+ next_offset (``str``, *optional*):
124+ Pass the offset that a client should send in the next query with the same text to receive more results.
125+ Pass an empty string if there are no more results or if you don‘t support pagination.
126+ Offset length can’t exceed 64 bytes.
127+
128+ switch_pm_text (``str``, *optional*):
129+ If passed, clients will display a button with specified text that switches the user to a private chat
130+ with the bot and sends the bot a start message with the parameter switch_pm_parameter
131+
132+ switch_pm_parameter (``str``, *optional*):
133+ `Deep-linking <https://core.telegram.org/bots#deep-linking>`_ parameter for the /start message sent to
134+ the bot when user presses the switch button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed.
135+
136+ Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube
137+ account to adapt search results accordingly. To do this, it displays a "Connect your YouTube account"
138+ button above the results, or even before showing any. The user presses the button, switches to a private
139+ chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an oauth
140+ link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat
141+ where they wanted to use the bot's inline capabilities.
142+ """
143+
93144 return self ._client .answer_inline_query (
94145 inline_query_id = self .id ,
95146 results = results ,
0 commit comments