
    i                         d Z ddl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
 ddlmZ dd	lmZmZ  ed
          Z G d deeeef                   ZdS )z7This module contains the PreCheckoutQueryHandler class.    N)Pattern)TypeVar)Update)DEFAULT_TRUE)DVType)BaseHandler)CCTHandlerCallbackRTc                        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fdZ xZS )PreCheckoutQueryHandlera  Handler class to handle Telegram :attr:`telegram.Update.pre_checkout_query`.

    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.

    Examples:
        :any:`Payment Bot <examples.paymentbot>`

    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): Optional. Regex pattern
            to test :attr:`telegram.PreCheckoutQuery.invoice_payload` against.

            .. versionadded:: 20.8

    Attributes:
        callback (:term:`coroutine function`): The callback function for this handler.
        block (:obj:`bool`): Determines whether the callback will run in a blocking way..
        pattern (:obj:`str` | :func:`re.Pattern <re.compile>`, optional): Optional. Regex pattern
            to test :attr:`telegram.PreCheckoutQuery.invoice_payload` against.

            .. versionadded:: 20.8

    )patternNselfz PreCheckoutQueryHandler[CCT, RT]callbackblockr   c                     t                                          ||           |t          j        |          nd | _        d S )N)r   )super__init__recompiler   )r   r   r   r   	__class__s       n/Users/shanyulin/my-agent/.venv/lib/python3.11/site-packages/telegram/ext/_handlers/precheckoutqueryhandler.pyr   z PreCheckoutQueryHandler.__init__K   sB     	///CJCVBJw,?,?,?\`    updatereturnc                     t          |t                    r9|j        r2|j        j        }| j        r| j                            |          rdS ndS dS )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`

        TF)
isinstancer   pre_checkout_queryinvoice_payloadr   match)r   r   r   s      r   check_updatez$PreCheckoutQueryHandler.check_updateU   sc     ff%% 	&*C 	$7GO| <%%o66  4  tur   )__name__
__module____qualname____doc__	__slots__r   r
   r   r	   r   r   boolstrr   r   objectr!   __classcell__)r   s   @r   r   r   "   s        $ $L I
 +-1	a a0a!&#r/2a d|a ws|#d*	a a a a a a6 d        r   r   )r%   r   r   typingr   telegramr   telegram._utils.defaultvaluer   telegram._utils.typesr   "telegram.ext._handlers.basehandlerr   telegram.ext._utils.typesr	   r
   r   r    r   r   <module>r2      s   & > = 				                   5 5 5 5 5 5 ( ( ( ( ( ( : : : : : : : : : : : : : :WT]]D D D D Dk&#r/: D D D D Dr   