U
    g                     @   s   d Z ddlmZmZ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 ddlmZmZ ed	ZG d
d deeeef ZdS )z1This module contains the ChatMemberHandler class.    )FinalOptionalTypeVar)Update)DEFAULT_TRUE)SCTDVType)BaseHandler)parse_chat_id)CCTHandlerCallbackRTc                       s   e Zd ZU dZdZdZee ed< dZ	ee ed< dZ
ee ed< eed	fd
eeeef eee eee  d fddZeedddZ  ZS )ChatMemberHandlera  Handler class to handle Telegram updates that contain a chat member update.

    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:`Chat Member Bot <examples.chatmemberbot>`

    .. versionadded:: 13.4

    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_member_types (:obj:`int`, optional): Pass one of :attr:`MY_CHAT_MEMBER`,
            :attr:`CHAT_MEMBER` or :attr:`ANY_CHAT_MEMBER` to specify if this handler should handle
            only updates with :attr:`telegram.Update.my_chat_member`,
            :attr:`telegram.Update.chat_member` or both. Defaults to :attr:`MY_CHAT_MEMBER`.
        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`
        chat_id (:obj:`int` | Collection[:obj:`int`], optional): Filters chat member updates from
            specified chat ID(s) only.
            .. versionadded:: 21.3

    Attributes:
        callback (:term:`coroutine function`): The callback function for this handler.
        chat_member_types (:obj:`int`): Optional. Specifies if this handler should handle
            only updates with :attr:`telegram.Update.my_chat_member`,
            :attr:`telegram.Update.chat_member` or both.
        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`.

    )	_chat_idschat_member_typesMY_CHAT_MEMBERr   CHAT_MEMBER   ANY_CHAT_MEMBERNzChatMemberHandler[CCT, RT]selfcallbackr   blockZchat_idc                    s$   t  j||d || _t|| _d S )N)r   )super__init__r   r
   r   r   	__class__ L/tmp/pip-unpacked-wheel-swnnwir2/telegram/ext/_handlers/chatmemberhandler.pyr   Y   s    zChatMemberHandler.__init__)updatereturnc                 C   sl   t |tsdS |js|jsdS | jr<|jr<|jj| jkr<dS | j| jkrLdS | j| j	krbt
|jS t
|j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my_chat_memberZchat_memberr   Zeffective_chatidr   r   r   bool)r   r    r   r   r   check_updatee   s     


zChatMemberHandler.check_update)__name__
__module____qualname____doc__	__slots__r   r   int__annotations__r   r   r   r   r   r   r   r   r$   r   r   r   objectr%   __classcell__r   r   r   r   r       s    
,
r   N)r)   typingr   r   r   Ztelegramr   Ztelegram._utils.defaultvaluer   Ztelegram._utils.typesr   r   Z"telegram.ext._handlers.basehandlerr	   Z#telegram.ext._utils._update_parsingr
   Ztelegram.ext._utils.typesr   r   r   r   r   r   r   r   <module>   s   