Skip to content

Commit aab6514

Browse files
authored
feat(pyrogram.filters): support filters.regex for ChosenInlineResult
1 parent f32fdbd commit aab6514

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

pyrogram/filters.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from pyrogram.types import (
2626
Message,
2727
CallbackQuery,
28+
ChosenInlineResult,
2829
InlineQuery,
2930
InlineKeyboardMarkup,
3031
PreCheckoutQuery,
@@ -1041,6 +1042,7 @@ def regex(pattern: Union[str, Pattern], flags: int = 0) -> Filter:
10411042
10421043
- :obj:`~pyrogram.types.Message`: The filter will match ``text`` or ``caption``.
10431044
- :obj:`~pyrogram.types.CallbackQuery`: The filter will match ``data``.
1045+
- :obj:`~pyrogram.types.ChosenInlineResult`: The filter will match ``query``.
10441046
- :obj:`~pyrogram.types.InlineQuery`: The filter will match ``query``.
10451047
- :obj:`~pyrogram.types.PreCheckoutQuery`: The filter will match ``payload``.
10461048
@@ -1060,7 +1062,7 @@ async def func(flt, _, update: Update) -> bool:
10601062
value: Str = update.text or update.caption
10611063
elif isinstance(update, CallbackQuery):
10621064
value: str | bytes = update.data
1063-
elif isinstance(update, InlineQuery):
1065+
elif isinstance(update, (ChosenInlineResult, InlineQuery)):
10641066
value: str = update.query
10651067
elif isinstance(update, PreCheckoutQuery):
10661068
value: str = update.invoice_payload

pyrogram/types/inline_mode/chosen_inline_result.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19+
import re
1920
from typing import Optional
2021

2122
import pyrogram
@@ -49,6 +50,10 @@ class ChosenInlineResult(Object, Update):
4950
Identifier of the sent inline message.
5051
Available only if there is an :doc:`inline keyboard <InlineKeyboardMarkup>` attached to the message.
5152
Will be also received in :doc:`callback queries <CallbackQuery>` and can be used to edit the message.
53+
54+
matches (List of regex Matches, *optional*):
55+
A list containing all `Match Objects <https://docs.python.org/3/library/re.html#match-objects>`_ that match
56+
the query of this inline query. Only applicable when using :obj:`Filters.regex <pyrogram.Filters.regex>`.
5257
"""
5358

5459
def __init__(
@@ -59,7 +64,8 @@ def __init__(
5964
from_user: "types.User",
6065
query: str,
6166
location: "types.Location" = None,
62-
inline_message_id: str = None
67+
inline_message_id: str = None,
68+
matches: list[re.Match] = None
6369
):
6470
super().__init__(client)
6571

@@ -68,6 +74,7 @@ def __init__(
6874
self.query = query
6975
self.location = location
7076
self.inline_message_id = inline_message_id
77+
self.matches = matches
7178

7279
@staticmethod
7380
def _parse(client, chosen_inline_result: raw.types.UpdateBotInlineSend, users) -> "ChosenInlineResult":

0 commit comments

Comments
 (0)