
    'i                          d Z ddlZddlmZmZ ddlmZmZmZmZ ddl	m
Z
 ddlmZ ddlmZ ddlmZ dd	lmZmZ  ed
      ZerddlmZ  G d dee
eef         Zy)z9This module contains the ChosenInlineResultHandler class.    N)MatchPattern)TYPE_CHECKINGAnyTypeVarcast)Update)DEFAULT_TRUE)DVType)BaseHandler)CCTHandlerCallbackRT)Applicationc                        e Zd ZdZdZedfdddeeee	f   de
e   deee   z  dz  f fd	Zd
edeez  dz  fdZded
edddeee   z  ddf
dZ xZS )ChosenInlineResultHandlera  Handler class to handle Telegram updates that contain
    :attr:`telegram.Update.chosen_inline_result`.

    Warning:
        When setting :paramref:`block` to :obj:`False`, you cannot rely on adding custom
        attributes to :class:`telegram.ext.CallbackContext`. See its docs for more info.

    Args:
        callback (:term:`coroutine function`): The callback function for this handler. Will be
            called when :meth:`check_update` has determined that an update should be processed by
            this handler. Callback signature::

                async def callback(update: Update, context: CallbackContext)

            The return value of the callback is usually ignored except for the special case of
            :class:`telegram.ext.ConversationHandler`.
        block (:obj:`bool`, optional): Determines whether the return value of the callback should
            be awaited before processing the next handler in
            :meth:`telegram.ext.Application.process_update`. Defaults to :obj:`True`.

            .. seealso:: :wiki:`Concurrency`
        pattern (:obj:`str` | :func:`re.Pattern <re.compile>`, optional): Regex pattern. If not
            :obj:`None`, :func:`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 (:term:`coroutine function`): The callback function for this handler.
        block (:obj:`bool`): Determines whether the return value of the callback should be
            awaited before processing the next handler in
            :meth:`telegram.ext.Application.process_update`.
        pattern (`Pattern`): Optional. Regex pattern to test
            :attr:`telegram.ChosenInlineResult.result_id` against.

            .. versionadded:: 13.6

    )patternNselfz"ChosenInlineResultHandler[CCT, RT]callbackblockr   c                     t         |   ||       t        |t              rt	        j
                  |      }|| _        y )N)r   )super__init__
isinstancestrrecompiler   )r   r   r   r   	__class__s       z/home/obispo/Crisostomo_bridge/mision_env/lib/python3.12/site-packages/telegram/ext/_handlers/choseninlineresulthandler.pyr   z"ChosenInlineResultHandler.__init__P   s6     	/gs#jj)G29    updatereturnc                     t        |t              rR|j                  rF| j                  r9t	        j
                  | j                  |j                  j                        x}r|S yyy)zDetermines whether an update should be passed to this handler's :attr:`callback`.

        Args:
            update (:class:`telegram.Update` | :obj:`object`): Incoming update.

        Returns:
            :obj:`bool` | :obj:`re.match`

        TN)r   r	   chosen_inline_resultr   r   match	result_id)r   r!   r%   s      r   check_updatez&ChosenInlineResultHandler.check_update]   sU     ff%&*E*E||HHT\\63N3N3X3XYY5Y L  r    contextapplicationz)Application[Any, CCT, Any, Any, Any, Any]check_resultc                 F    | j                   rt        d|      }|g|_        yy)zuThis function adds the matched regex pattern result to
        :attr:`telegram.ext.CallbackContext.matches`.
        r   N)r   r   matches)r   r(   r!   r)   r*   s        r   collect_additional_contextz4ChosenInlineResultHandler.collect_additional_contexto   s%     <<6L+nGO r    )__name__
__module____qualname____doc__	__slots__r
   r   r	   r   r   r   boolr   r   r   objectr'   r   r-   __classcell__)r   s   @r   r   r   %   s    &P I
 +-1	:2:!&#r/2: d|: ws|#d*	:6 dVmd.B $-- - A	-
 U3Z'- 
-r    r   )r1   r   r   r   typingr   r   r   r   telegramr	   telegram._utils.defaultvaluer
   telegram._utils.typesr   "telegram.ext._handlers.basehandlerr   telegram.ext._utils.typesr   r   r   telegram.extr   r    r    r   <module>r>      sN   & @ 	  4 4  5 ( : :T](V-FCO < V-r    