U
    g                     @   s   d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	 ddl
mZ ddlmZmZ ddlmZmZmZ G d	d
 d
eeeef ZdS )z2This module contains the PaidMediaPurchased class.    )Optional)Update)DEFAULT_TRUE)SCTDVType)BaseHandler)parse_chat_idparse_username)CCTRTHandlerCallbackc                       sh   e Zd ZdZdZddefdeeee	f e
ee  e
ee  ee d fddZeedd	d
Z  ZS )PaidMediaPurchasedHandlerai  Handler class to handle Telegram
    :attr:`purchased paid media <telegram.Update.purchased_paid_media>`.

    .. versionadded:: 21.6

    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)
        user_id (:obj:`int` | Collection[:obj:`int`], optional): Filters requests to allow only
            those which are from the specified user ID(s).

        username (:obj:`str` | Collection[:obj:`str`], optional): Filters requests to allow only
            those which are from the specified username(s).

        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`
    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`.
    )	_user_ids
_usernamesNz"PaidMediaPurchasedHandler[CCT, RT]selfcallbackZuser_idusernameblockc                    s(   t  j||d t|| _t|| _d S )N)r   )super__init__r   r   r	   r   r   	__class__ T/tmp/pip-unpacked-wheel-swnnwir2/telegram/ext/_handlers/paidmediapurchasedhandler.pyr   B   s    
z"PaidMediaPurchasedHandler.__init__)updatereturnc                 C   sH   t |tr|jsdS | js$| js$dS |jjj| jkr8dS |jjj| jk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`

        FT)
isinstancer   Zpurchased_paid_mediar   r   Z	from_useridr   )r   r   r   r   r   check_updateN   s    
z&PaidMediaPurchasedHandler.check_update)__name__
__module____qualname____doc__	__slots__r   r   r   r
   r   r   r   intstrr   boolr   objectr   __classcell__r   r   r   r   r      s   

r   N)r#   typingr   Ztelegramr   Ztelegram._utils.defaultvaluer   Ztelegram._utils.typesr   r   Z"telegram.ext._handlers.basehandlerr   Z#telegram.ext._utils._update_parsingr   r	   Ztelegram.ext._utils.typesr
   r   r   r   r   r   r   r   <module>   s   