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	m
Z
 ddlmZ ddlmZmZ ddlmZmZ G d	d
 d
eeeef ZdS )z6This module contains the ChatJoinRequestHandler class.    )Optional)Update)DEFAULT_TRUE)RTSCTDVType)BaseHandler)parse_chat_idparse_username)CCT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 )ChatJoinRequestHandlera  Handler class to handle Telegram updates that contain
    :attr:`telegram.Update.chat_join_request`.

    Note:
        If neither of :paramref:`username` and the :paramref:`chat_id` are passed, this handler
        accepts *any* join request. Otherwise, this handler accepts all requests to join chats
        for which the chat ID is listed in :paramref:`chat_id` or the username is listed in
        :paramref:`username`, or both.

        .. versionadded:: 20.0

    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.

    .. versionadded:: 13.8

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

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

            .. versionadded:: 20.0
        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 callback will run in a blocking way..

    )	_chat_ids
_usernamesNzChatJoinRequestHandler[CCT, RT]selfcallbackZchat_idusernameblockc                    s(   t  j||d t|| _t|| _d S )N)r   )super__init__r	   r   r
   r   r   	__class__ Q/tmp/pip-unpacked-wheel-swnnwir2/telegram/ext/_handlers/chatjoinrequesthandler.pyr   S   s    
zChatJoinRequestHandler.__init__)updatereturnc                 C   sH   t |trD|jrD| js | js dS |jjj| jkr4dS |jjj| jk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   Zchat_join_requestr   r   ZchatidZ	from_userr   )r   r   r   r   r   check_update_   s    
z#ChatJoinRequestHandler.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   r   Z"telegram.ext._handlers.basehandlerr   Z#telegram.ext._utils._update_parsingr	   r
   Ztelegram.ext._utils.typesr   r   r   r   r   r   r   <module>   s   