Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pyrogram/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from pyrogram.types import (
Message,
CallbackQuery,
ChosenInlineResult,
InlineQuery,
InlineKeyboardMarkup,
PreCheckoutQuery,
Expand Down Expand Up @@ -1041,6 +1042,7 @@ def regex(pattern: Union[str, Pattern], flags: int = 0) -> Filter:

- :obj:`~pyrogram.types.Message`: The filter will match ``text`` or ``caption``.
- :obj:`~pyrogram.types.CallbackQuery`: The filter will match ``data``.
- :obj:`~pyrogram.types.ChosenInlineResult`: The filter will match ``query``.
- :obj:`~pyrogram.types.InlineQuery`: The filter will match ``query``.
- :obj:`~pyrogram.types.PreCheckoutQuery`: The filter will match ``payload``.

Expand All @@ -1060,7 +1062,7 @@ async def func(flt, _, update: Update) -> bool:
value: Str = update.text or update.caption
elif isinstance(update, CallbackQuery):
value: str | bytes = update.data
elif isinstance(update, InlineQuery):
elif isinstance(update, (ChosenInlineResult, InlineQuery)):
value: str = update.query
elif isinstance(update, PreCheckoutQuery):
value: str = update.invoice_payload
Expand Down
9 changes: 8 additions & 1 deletion pyrogram/types/inline_mode/chosen_inline_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.

import re
from typing import Optional

import pyrogram
Expand Down Expand Up @@ -49,6 +50,10 @@ class ChosenInlineResult(Object, Update):
Identifier of the sent inline message.
Available only if there is an :doc:`inline keyboard <InlineKeyboardMarkup>` attached to the message.
Will be also received in :doc:`callback queries <CallbackQuery>` and can be used to edit the message.

matches (List of regex Matches, *optional*):
A list containing all `Match Objects <https://docs.python.org/3/library/re.html#match-objects>`_ that match
the query of this inline query. Only applicable when using :obj:`Filters.regex <pyrogram.Filters.regex>`.
"""

def __init__(
Expand All @@ -59,7 +64,8 @@ def __init__(
from_user: "types.User",
query: str,
location: "types.Location" = None,
inline_message_id: str = None
inline_message_id: str = None,
matches: list[re.Match] = None
):
super().__init__(client)

Expand All @@ -68,6 +74,7 @@ def __init__(
self.query = query
self.location = location
self.inline_message_id = inline_message_id
self.matches = matches

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