prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  [FEATURE] Add a pattern for result_id of ChosenInlineResultHandler
  In this way you can separate the results of your inline queries and redirect them to specific function as it happens for callback queries.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `telegram/ext/choseninlineresulthandler.py`
  Content:
  ```
  1 #!/usr/bin/env python
  2 #
  3 # A library that provides a Python interface to the Telegram Bot API
  4 # Copyright (C) 2015-2021
  5 # Leandro Toledo de Souza <devs@python-telegram-bot.org>
  6 #
  7 # This program is free software: you can redistribute it and/or modify
  8 # it under the terms of the GNU Lesser Public License as published by
  9 # the Free Software Foundation, either version 3 of the License, or
  10 # (at your option) any later version.
  11 #
  12 # This program is distributed in the hope that it will be useful,
  13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15 # GNU Lesser Public License for more details.
  16 #
  17 # You should have received a copy of the GNU Lesser Public License
  18 # along with this program.  If not, see [http://www.gnu.org/licenses/].
  19 """This module contains the ChosenInlineResultHandler class."""
  20 
  21 from typing import Optional, TypeVar, Union
  22 
  23 from telegram import Update
  24 
  25 from .handler import Handler
  26 
  27 RT = TypeVar('RT')
  28 
  29 
  30 class ChosenInlineResultHandler(Handler[Update]):
  31     """Handler class to handle Telegram updates that contain a chosen inline result.
  32 
  33     Note:
  34         :attr:`pass_user_data` and :attr:`pass_chat_data` determine whether a ``dict`` you
  35         can use to keep any data in will be sent to the :attr:`callback` function. Related to
  36         either the user or the chat that the update was sent in. For each update from the same user
  37         or in the same chat, it will be the same ``dict``.
  38 
  39         Note that this is DEPRECATED, and you should use context based callbacks. See
  40         https://git.io/fxJuV for more info.
  41 
  42     Warning:
  43         When setting ``run_async`` to :obj:`True`, you cannot rely on adding custom
  44         attributes to :class:`telegram.ext.CallbackContext`. See its docs for more info.
  45 
  46     Args:
  47         callback (:obj:`callable`): The callback function for this handler. Will be called when
  48             :attr:`check_update` has determined that an update should be processed by this handler.
  49             Callback signature for context based API:
  50 
  51             ``def callback(update: Update, context: CallbackContext)``
  52 
  53             The return value of the callback is usually ignored except for the special case of
  54             :class:`telegram.ext.ConversationHandler`.
  55         pass_update_queue (:obj:`bool`, optional): If set to :obj:`True`, a keyword argument called
  56             ``update_queue`` will be passed to the callback function. It will be the ``Queue``
  57             instance used by the :class:`telegram.ext.Updater` and :class:`telegram.ext.Dispatcher`
  58             that contains new updates which can be used to insert updates. Default is :obj:`False`.
  59             DEPRECATED: Please switch to context based callbacks.
  60         pass_job_queue (:obj:`bool`, optional): If set to :obj:`True`, a keyword argument called
  61             ``job_queue`` will be passed to the callback function. It will be a
  62             :class:`telegram.ext.JobQueue` instance created by the :class:`telegram.ext.Updater`
  63             which can be used to schedule new jobs. Default is :obj:`False`.
  64             DEPRECATED: Please switch to context based callbacks.
  65         pass_user_data (:obj:`bool`, optional): If set to :obj:`True`, a keyword argument called
  66             ``user_data`` will be passed to the callback function. Default is :obj:`False`.
  67             DEPRECATED: Please switch to context based callbacks.
  68         pass_chat_data (:obj:`bool`, optional): If set to :obj:`True`, a keyword argument called
  69             ``chat_data`` will be passed to the callback function. Default is :obj:`False`.
  70             DEPRECATED: Please switch to context based callbacks.
  71         run_async (:obj:`bool`): Determines whether the callback will run asynchronously.
  72             Defaults to :obj:`False`.
  73 
  74     Attributes:
  75         callback (:obj:`callable`): The callback function for this handler.
  76         pass_update_queue (:obj:`bool`): Determines whether ``update_queue`` will be
  77             passed to the callback function.
  78         pass_job_queue (:obj:`bool`): Determines whether ``job_queue`` will be passed to
  79             the callback function.
  80         pass_user_data (:obj:`bool`): Determines whether ``user_data`` will be passed to
  81             the callback function.
  82         pass_chat_data (:obj:`bool`): Determines whether ``chat_data`` will be passed to
  83             the callback function.
  84         run_async (:obj:`bool`): Determines whether the callback will run asynchronously.
  85 
  86     """
  87 
  88     def check_update(self, update: object) -> Optional[Union[bool, object]]:
  89         """Determines whether an update should be passed to this handlers :attr:`callback`.
  90 
  91         Args:
  92             update (:class:`telegram.Update` | :obj:`object`): Incoming update.
  93 
  94         Returns:
  95             :obj:`bool`
  96 
  97         """
  98         return isinstance(update, Update) and update.chosen_inline_result
  99
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/telegram/ext/choseninlineresulthandler.py b/telegram/ext/choseninlineresulthandler.py
  --- a/telegram/ext/choseninlineresulthandler.py
  +++ b/telegram/ext/choseninlineresulthandler.py
  @@ -17,15 +17,19 @@
   # You should have received a copy of the GNU Lesser Public License
   # along with this program.  If not, see [http://www.gnu.org/licenses/].
   """This module contains the ChosenInlineResultHandler class."""
  -
  -from typing import Optional, TypeVar, Union
  +import re
  +from typing import Optional, TypeVar, Union, Callable, TYPE_CHECKING, Pattern, Match, cast
   
   from telegram import Update
   
  +from telegram.utils.helpers import DefaultValue, DEFAULT_FALSE
   from .handler import Handler
   
   RT = TypeVar('RT')
   
  +if TYPE_CHECKING:
  +    from telegram.ext import CallbackContext, Dispatcher
  +
   
   class ChosenInlineResultHandler(Handler[Update]):
       """Handler class to handle Telegram updates that contain a chosen inline result.
  @@ -70,6 +74,12 @@
               DEPRECATED: Please switch to context based callbacks.
           run_async (:obj:`bool`): Determines whether the callback will run asynchronously.
               Defaults to :obj:`False`.
  +        pattern (:obj:`str` | `Pattern`, optional): Regex pattern. If not :obj:`None`, ``re.match``
  +            is used on :attr:`telegram.ChosenInlineResult.result_id` to determine if an update
  +            should be handled by this handler. This is accessible in the callback as
  +            :attr:`telegram.ext.CallbackContext.matches`.
  +
  +            .. versionadded:: 13.6
   
       Attributes:
           callback (:obj:`callable`): The callback function for this handler.
  @@ -82,9 +92,37 @@
           pass_chat_data (:obj:`bool`): Determines whether ``chat_data`` will be passed to
               the callback function.
           run_async (:obj:`bool`): Determines whether the callback will run asynchronously.
  +        pattern (`Pattern`): Optional. Regex pattern to test
  +            :attr:`telegram.ChosenInlineResult.result_id` against.
  +
  +            .. versionadded:: 13.6
   
       """
   
  +    def __init__(
  +        self,
  +        callback: Callable[[Update, 'CallbackContext'], RT],
  +        pass_update_queue: bool = False,
  +        pass_job_queue: bool = False,
  +        pass_user_data: bool = False,
  +        pass_chat_data: bool = False,
  +        run_async: Union[bool, DefaultValue] = DEFAULT_FALSE,
  +        pattern: Union[str, Pattern] = None,
  +    ):
  +        super().__init__(
  +            callback,
  +            pass_update_queue=pass_update_queue,
  +            pass_job_queue=pass_job_queue,
  +            pass_user_data=pass_user_data,
  +            pass_chat_data=pass_chat_data,
  +            run_async=run_async,
  +        )
  +
  +        if isinstance(pattern, str):
  +            pattern = re.compile(pattern)
  +
  +        self.pattern = pattern
  +
       def check_update(self, update: object) -> Optional[Union[bool, object]]:
           """Determines whether an update should be passed to this handlers :attr:`callback`.
   
  @@ -95,4 +133,24 @@
               :obj:`bool`
   
           """
  -        return isinstance(update, Update) and update.chosen_inline_result
  +        if isinstance(update, Update) and update.chosen_inline_result:
  +            if self.pattern:
  +                match = re.match(self.pattern, update.chosen_inline_result.result_id)
  +                if match:
  +                    return match
  +            else:
  +                return True
  +        return None
  +
  +    def collect_additional_context(
  +        self,
  +        context: 'CallbackContext',
  +        update: Update,
  +        dispatcher: 'Dispatcher',
  +        check_result: Union[bool, Match],
  +    ) -> None:
  +        """This function adds the matched regex pattern result to
  +        :attr:`telegram.ext.CallbackContext.matches`."""
  +        if self.pattern:
  +            check_result = cast(Match, check_result)
  +            context.matches = [check_result]
  
verification_info: {"golden_diff": "diff --git a/telegram/ext/choseninlineresulthandler.py b/telegram/ext/choseninlineresulthandler.py\n--- a/telegram/ext/choseninlineresulthandler.py\n+++ b/telegram/ext/choseninlineresulthandler.py\n@@ -17,15 +17,19 @@\n # You should have received a copy of the GNU Lesser Public License\n # along with this program.  If not, see [http://www.gnu.org/licenses/].\n \"\"\"This module contains the ChosenInlineResultHandler class.\"\"\"\n-\n-from typing import Optional, TypeVar, Union\n+import re\n+from typing import Optional, TypeVar, Union, Callable, TYPE_CHECKING, Pattern, Match, cast\n \n from telegram import Update\n \n+from telegram.utils.helpers import DefaultValue, DEFAULT_FALSE\n from .handler import Handler\n \n RT = TypeVar('RT')\n \n+if TYPE_CHECKING:\n+    from telegram.ext import CallbackContext, Dispatcher\n+\n \n class ChosenInlineResultHandler(Handler[Update]):\n     \"\"\"Handler class to handle Telegram updates that contain a chosen inline result.\n@@ -70,6 +74,12 @@\n             DEPRECATED: Please switch to context based callbacks.\n         run_async (:obj:`bool`): Determines whether the callback will run asynchronously.\n             Defaults to :obj:`False`.\n+        pattern (:obj:`str` | `Pattern`, optional): Regex pattern. If not :obj:`None`, ``re.match``\n+            is used on :attr:`telegram.ChosenInlineResult.result_id` to determine if an update\n+            should be handled by this handler. This is accessible in the callback as\n+            :attr:`telegram.ext.CallbackContext.matches`.\n+\n+            .. versionadded:: 13.6\n \n     Attributes:\n         callback (:obj:`callable`): The callback function for this handler.\n@@ -82,9 +92,37 @@\n         pass_chat_data (:obj:`bool`): Determines whether ``chat_data`` will be passed to\n             the callback function.\n         run_async (:obj:`bool`): Determines whether the callback will run asynchronously.\n+        pattern (`Pattern`): Optional. Regex pattern to test\n+            :attr:`telegram.ChosenInlineResult.result_id` against.\n+\n+            .. versionadded:: 13.6\n \n     \"\"\"\n \n+    def __init__(\n+        self,\n+        callback: Callable[[Update, 'CallbackContext'], RT],\n+        pass_update_queue: bool = False,\n+        pass_job_queue: bool = False,\n+        pass_user_data: bool = False,\n+        pass_chat_data: bool = False,\n+        run_async: Union[bool, DefaultValue] = DEFAULT_FALSE,\n+        pattern: Union[str, Pattern] = None,\n+    ):\n+        super().__init__(\n+            callback,\n+            pass_update_queue=pass_update_queue,\n+            pass_job_queue=pass_job_queue,\n+            pass_user_data=pass_user_data,\n+            pass_chat_data=pass_chat_data,\n+            run_async=run_async,\n+        )\n+\n+        if isinstance(pattern, str):\n+            pattern = re.compile(pattern)\n+\n+        self.pattern = pattern\n+\n     def check_update(self, update: object) -> Optional[Union[bool, object]]:\n         \"\"\"Determines whether an update should be passed to this handlers :attr:`callback`.\n \n@@ -95,4 +133,24 @@\n             :obj:`bool`\n \n         \"\"\"\n-        return isinstance(update, Update) and update.chosen_inline_result\n+        if isinstance(update, Update) and update.chosen_inline_result:\n+            if self.pattern:\n+                match = re.match(self.pattern, update.chosen_inline_result.result_id)\n+                if match:\n+                    return match\n+            else:\n+                return True\n+        return None\n+\n+    def collect_additional_context(\n+        self,\n+        context: 'CallbackContext',\n+        update: Update,\n+        dispatcher: 'Dispatcher',\n+        check_result: Union[bool, Match],\n+    ) -> None:\n+        \"\"\"This function adds the matched regex pattern result to\n+        :attr:`telegram.ext.CallbackContext.matches`.\"\"\"\n+        if self.pattern:\n+            check_result = cast(Match, check_result)\n+            context.matches = [check_result]\n", "issue": "[FEATURE] Add a pattern for result_id of ChosenInlineResultHandler\nIn this way you can separate the results of your inline queries and redirect them to specific function as it happens for callback queries.\n", "before_files": [{"content": "#!/usr/bin/env python\n#\n# A library that provides a Python interface to the Telegram Bot API\n# Copyright (C) 2015-2021\n# Leandro Toledo de Souza <devs@python-telegram-bot.org>\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Lesser Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU Lesser Public License for more details.\n#\n# You should have received a copy of the GNU Lesser Public License\n# along with this program.  If not, see [http://www.gnu.org/licenses/].\n\"\"\"This module contains the ChosenInlineResultHandler class.\"\"\"\n\nfrom typing import Optional, TypeVar, Union\n\nfrom telegram import Update\n\nfrom .handler import Handler\n\nRT = TypeVar('RT')\n\n\nclass ChosenInlineResultHandler(Handler[Update]):\n    \"\"\"Handler class to handle Telegram updates that contain a chosen inline result.\n\n    Note:\n        :attr:`pass_user_data` and :attr:`pass_chat_data` determine whether a ``dict`` you\n        can use to keep any data in will be sent to the :attr:`callback` function. Related to\n        either the user or the chat that the update was sent in. For each update from the same user\n        or in the same chat, it will be the same ``dict``.\n\n        Note that this is DEPRECATED, and you should use context based callbacks. See\n        https://git.io/fxJuV for more info.\n\n    Warning:\n        When setting ``run_async`` to :obj:`True`, you cannot rely on adding custom\n        attributes to :class:`telegram.ext.CallbackContext`. See its docs for more info.\n\n    Args:\n        callback (:obj:`callable`): The callback function for this handler. Will be called when\n            :attr:`check_update` has determined that an update should be processed by this handler.\n            Callback signature for context based API:\n\n            ``def callback(update: Update, context: CallbackContext)``\n\n            The return value of the callback is usually ignored except for the special case of\n            :class:`telegram.ext.ConversationHandler`.\n        pass_update_queue (:obj:`bool`, optional): If set to :obj:`True`, a keyword argument called\n            ``update_queue`` will be passed to the callback function. It will be the ``Queue``\n            instance used by the :class:`telegram.ext.Updater` and :class:`telegram.ext.Dispatcher`\n            that contains new updates which can be used to insert updates. Default is :obj:`False`.\n            DEPRECATED: Please switch to context based callbacks.\n        pass_job_queue (:obj:`bool`, optional): If set to :obj:`True`, a keyword argument called\n            ``job_queue`` will be passed to the callback function. It will be a\n            :class:`telegram.ext.JobQueue` instance created by the :class:`telegram.ext.Updater`\n            which can be used to schedule new jobs. Default is :obj:`False`.\n            DEPRECATED: Please switch to context based callbacks.\n        pass_user_data (:obj:`bool`, optional): If set to :obj:`True`, a keyword argument called\n            ``user_data`` will be passed to the callback function. Default is :obj:`False`.\n            DEPRECATED: Please switch to context based callbacks.\n        pass_chat_data (:obj:`bool`, optional): If set to :obj:`True`, a keyword argument called\n            ``chat_data`` will be passed to the callback function. Default is :obj:`False`.\n            DEPRECATED: Please switch to context based callbacks.\n        run_async (:obj:`bool`): Determines whether the callback will run asynchronously.\n            Defaults to :obj:`False`.\n\n    Attributes:\n        callback (:obj:`callable`): The callback function for this handler.\n        pass_update_queue (:obj:`bool`): Determines whether ``update_queue`` will be\n            passed to the callback function.\n        pass_job_queue (:obj:`bool`): Determines whether ``job_queue`` will be passed to\n            the callback function.\n        pass_user_data (:obj:`bool`): Determines whether ``user_data`` will be passed to\n            the callback function.\n        pass_chat_data (:obj:`bool`): Determines whether ``chat_data`` will be passed to\n            the callback function.\n        run_async (:obj:`bool`): Determines whether the callback will run asynchronously.\n\n    \"\"\"\n\n    def check_update(self, update: object) -> Optional[Union[bool, object]]:\n        \"\"\"Determines whether an update should be passed to this handlers :attr:`callback`.\n\n        Args:\n            update (:class:`telegram.Update` | :obj:`object`): Incoming update.\n\n        Returns:\n            :obj:`bool`\n\n        \"\"\"\n        return isinstance(update, Update) and update.chosen_inline_result\n", "path": "telegram/ext/choseninlineresulthandler.py"}], "after_files": [{"content": "#!/usr/bin/env python\n#\n# A library that provides a Python interface to the Telegram Bot API\n# Copyright (C) 2015-2021\n# Leandro Toledo de Souza <devs@python-telegram-bot.org>\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Lesser Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU Lesser Public License for more details.\n#\n# You should have received a copy of the GNU Lesser Public License\n# along with this program.  If not, see [http://www.gnu.org/licenses/].\n\"\"\"This module contains the ChosenInlineResultHandler class.\"\"\"\nimport re\nfrom typing import Optional, TypeVar, Union, Callable, TYPE_CHECKING, Pattern, Match, cast\n\nfrom telegram import Update\n\nfrom telegram.utils.helpers import DefaultValue, DEFAULT_FALSE\nfrom .handler import Handler\n\nRT = TypeVar('RT')\n\nif TYPE_CHECKING:\n    from telegram.ext import CallbackContext, Dispatcher\n\n\nclass ChosenInlineResultHandler(Handler[Update]):\n    \"\"\"Handler class to handle Telegram updates that contain a chosen inline result.\n\n    Note:\n        :attr:`pass_user_data` and :attr:`pass_chat_data` determine whether a ``dict`` you\n        can use to keep any data in will be sent to the :attr:`callback` function. Related to\n        either the user or the chat that the update was sent in. For each update from the same user\n        or in the same chat, it will be the same ``dict``.\n\n        Note that this is DEPRECATED, and you should use context based callbacks. See\n        https://git.io/fxJuV for more info.\n\n    Warning:\n        When setting ``run_async`` to :obj:`True`, you cannot rely on adding custom\n        attributes to :class:`telegram.ext.CallbackContext`. See its docs for more info.\n\n    Args:\n        callback (:obj:`callable`): The callback function for this handler. Will be called when\n            :attr:`check_update` has determined that an update should be processed by this handler.\n            Callback signature for context based API:\n\n            ``def callback(update: Update, context: CallbackContext)``\n\n            The return value of the callback is usually ignored except for the special case of\n            :class:`telegram.ext.ConversationHandler`.\n        pass_update_queue (:obj:`bool`, optional): If set to :obj:`True`, a keyword argument called\n            ``update_queue`` will be passed to the callback function. It will be the ``Queue``\n            instance used by the :class:`telegram.ext.Updater` and :class:`telegram.ext.Dispatcher`\n            that contains new updates which can be used to insert updates. Default is :obj:`False`.\n            DEPRECATED: Please switch to context based callbacks.\n        pass_job_queue (:obj:`bool`, optional): If set to :obj:`True`, a keyword argument called\n            ``job_queue`` will be passed to the callback function. It will be a\n            :class:`telegram.ext.JobQueue` instance created by the :class:`telegram.ext.Updater`\n            which can be used to schedule new jobs. Default is :obj:`False`.\n            DEPRECATED: Please switch to context based callbacks.\n        pass_user_data (:obj:`bool`, optional): If set to :obj:`True`, a keyword argument called\n            ``user_data`` will be passed to the callback function. Default is :obj:`False`.\n            DEPRECATED: Please switch to context based callbacks.\n        pass_chat_data (:obj:`bool`, optional): If set to :obj:`True`, a keyword argument called\n            ``chat_data`` will be passed to the callback function. Default is :obj:`False`.\n            DEPRECATED: Please switch to context based callbacks.\n        run_async (:obj:`bool`): Determines whether the callback will run asynchronously.\n            Defaults to :obj:`False`.\n        pattern (:obj:`str` | `Pattern`, optional): Regex pattern. If not :obj:`None`, ``re.match``\n            is used on :attr:`telegram.ChosenInlineResult.result_id` to determine if an update\n            should be handled by this handler. This is accessible in the callback as\n            :attr:`telegram.ext.CallbackContext.matches`.\n\n            .. versionadded:: 13.6\n\n    Attributes:\n        callback (:obj:`callable`): The callback function for this handler.\n        pass_update_queue (:obj:`bool`): Determines whether ``update_queue`` will be\n            passed to the callback function.\n        pass_job_queue (:obj:`bool`): Determines whether ``job_queue`` will be passed to\n            the callback function.\n        pass_user_data (:obj:`bool`): Determines whether ``user_data`` will be passed to\n            the callback function.\n        pass_chat_data (:obj:`bool`): Determines whether ``chat_data`` will be passed to\n            the callback function.\n        run_async (:obj:`bool`): Determines whether the callback will run asynchronously.\n        pattern (`Pattern`): Optional. Regex pattern to test\n            :attr:`telegram.ChosenInlineResult.result_id` against.\n\n            .. versionadded:: 13.6\n\n    \"\"\"\n\n    def __init__(\n        self,\n        callback: Callable[[Update, 'CallbackContext'], RT],\n        pass_update_queue: bool = False,\n        pass_job_queue: bool = False,\n        pass_user_data: bool = False,\n        pass_chat_data: bool = False,\n        run_async: Union[bool, DefaultValue] = DEFAULT_FALSE,\n        pattern: Union[str, Pattern] = None,\n    ):\n        super().__init__(\n            callback,\n            pass_update_queue=pass_update_queue,\n            pass_job_queue=pass_job_queue,\n            pass_user_data=pass_user_data,\n            pass_chat_data=pass_chat_data,\n            run_async=run_async,\n        )\n\n        if isinstance(pattern, str):\n            pattern = re.compile(pattern)\n\n        self.pattern = pattern\n\n    def check_update(self, update: object) -> Optional[Union[bool, object]]:\n        \"\"\"Determines whether an update should be passed to this handlers :attr:`callback`.\n\n        Args:\n            update (:class:`telegram.Update` | :obj:`object`): Incoming update.\n\n        Returns:\n            :obj:`bool`\n\n        \"\"\"\n        if isinstance(update, Update) and update.chosen_inline_result:\n            if self.pattern:\n                match = re.match(self.pattern, update.chosen_inline_result.result_id)\n                if match:\n                    return match\n            else:\n                return True\n        return None\n\n    def collect_additional_context(\n        self,\n        context: 'CallbackContext',\n        update: Update,\n        dispatcher: 'Dispatcher',\n        check_result: Union[bool, Match],\n    ) -> None:\n        \"\"\"This function adds the matched regex pattern result to\n        :attr:`telegram.ext.CallbackContext.matches`.\"\"\"\n        if self.pattern:\n            check_result = cast(Match, check_result)\n            context.matches = [check_result]\n", "path": "telegram/ext/choseninlineresulthandler.py"}]}