Skip to content

Commit c0e9b98

Browse files
committed
Add is_gallery parameter to answer_inline_query and InlineQuery.answer
1 parent 0906754 commit c0e9b98

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

pyrogram/client/methods/bots/answer_inline_query.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,34 @@ def answer_inline_query(
2929
inline_query_id: str,
3030
results: List[InlineQueryResult],
3131
cache_time: int = 300,
32-
is_personal: bool = None,
32+
is_gallery: bool = False,
33+
is_personal: bool = False,
3334
next_offset: str = "",
3435
switch_pm_text: str = "",
3536
switch_pm_parameter: str = ""
3637
):
3738
"""Send answers to an inline query.
38-
No more than 50 results per query are allowed.
39+
40+
A maximum of 50 results per query is allowed.
3941
4042
Parameters:
4143
inline_query_id (``str``):
4244
Unique identifier for the answered query.
4345
44-
results (List of :obj:`InlineQueryResult <pyrogram.InlineQueryResult>`):
46+
results (List of :obj:`InlineQueryResult`):
4547
A list of results for the inline query.
4648
4749
cache_time (``int``, *optional*):
4850
The maximum amount of time in seconds that the result of the inline query may be cached on the server.
4951
Defaults to 300.
5052
53+
is_gallery (``bool``, *optional*):
54+
Pass True, if results should be displayed in gallery mode instead of list mode.
55+
Defaults to False.
56+
5157
is_personal (``bool``, *optional*):
5258
Pass True, if results may be cached on the server side only for the user that sent the query.
53-
By default, results may be returned to any user who sends the same query.
59+
By default (False), results may be returned to any user who sends the same query.
5460
5561
next_offset (``str``, *optional*):
5662
Pass the offset that a client should send in the next query with the same text to receive more results.
@@ -83,7 +89,7 @@ def answer_inline_query(
8389
query_id=int(inline_query_id),
8490
results=[r.write() for r in results],
8591
cache_time=cache_time,
86-
gallery=None,
92+
gallery=is_gallery or None,
8793
private=is_personal or None,
8894
next_offset=next_offset or None,
8995
switch_pm=types.InlineBotSwitchPM(

pyrogram/client/types/inline_mode/inline_query.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ def answer(
8787
self,
8888
results: List[InlineQueryResult],
8989
cache_time: int = 300,
90-
is_personal: bool = None,
90+
is_gallery: bool = False,
91+
is_personal: bool = False,
9192
next_offset: str = "",
9293
switch_pm_text: str = "",
9394
switch_pm_parameter: str = ""
@@ -116,9 +117,13 @@ def answer(
116117
The maximum amount of time in seconds that the result of the inline query may be cached on the server.
117118
Defaults to 300.
118119
120+
is_gallery (``bool``, *optional*):
121+
Pass True, if results should be displayed in gallery mode instead of list mode.
122+
Defaults to False.
123+
119124
is_personal (``bool``, *optional*):
120125
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.
126+
By default (False), results may be returned to any user who sends the same query.
122127
123128
next_offset (``str``, *optional*):
124129
Pass the offset that a client should send in the next query with the same text to receive more results.
@@ -145,6 +150,7 @@ def answer(
145150
inline_query_id=self.id,
146151
results=results,
147152
cache_time=cache_time,
153+
is_gallery=is_gallery,
148154
is_personal=is_personal,
149155
next_offset=next_offset,
150156
switch_pm_text=switch_pm_text,

0 commit comments

Comments
 (0)