U
    g                     @   s   d Z ddlmZmZmZ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 ddlmZmZ erdd	lmZ ed
ZG dd dee
eef ZdS )z.This module contains the MessageHandler class.    )TYPE_CHECKINGAnyDictListOptionalTypeVarUnion)Update)DEFAULT_TRUE)DVTypefilters)BaseHandler)CCTHandlerCallback)ApplicationRTc                	       s   e Zd ZdZdZefdeej e	e
eef ee d fddZeeeeeeee f f  ddd	Zee
d
eeeeeef f  ddddZ  ZS )MessageHandlera  Handler class to handle Telegram messages. They might contain text, media or status
    updates.

    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:
        filters (:class:`telegram.ext.filters.BaseFilter`): A filter inheriting from
            :class:`telegram.ext.filters.BaseFilter`. Standard filters can be found in
            :mod:`telegram.ext.filters`. Filters can be combined using bitwise
            operators (& for and, | for or, ~ for not). Passing :obj:`None` is a shortcut
            to passing :class:`telegram.ext.filters.ALL`.

            .. seealso:: :wiki:`Advanced Filters <Extensions---Advanced-Filters>`
        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`

    Attributes:
        filters (:class:`telegram.ext.filters.BaseFilter`): Only allow updates with these Filters.
            See :mod:`telegram.ext.filters` for a full list of all available filters.
        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`.

    r   zMessageHandler[CCT, RT]selfr   callbackblockc                    s(   t  j||d |d k	r|ntj| _d S )N)r   )super__init__filters_moduleALLr   r   	__class__ I/tmp/pip-unpacked-wheel-swnnwir2/telegram/ext/_handlers/messagehandler.pyr   M   s    zMessageHandler.__init__)updatereturnc                 C   s   t |tr| j|p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`

        FN)
isinstancer	   r   check_update)r   r    r   r   r   r#   X   s    

zMessageHandler.check_updatez)Application[Any, CCT, Any, Any, Any, Any]N)contextr    applicationcheck_resultr!   c                 C   s   t |tr|| dS )zEAdds possible output of data filters to the :class:`CallbackContext`.N)r"   dictr    )r   r$   r    r%   r&   r   r   r   collect_additional_contextf   s    
z)MessageHandler.collect_additional_context)__name__
__module____qualname____doc__	__slots__r
   r   r   Z
BaseFilterr   r	   r   r   r   boolr   objectr   r   strr   r   r#   r(   __classcell__r   r   r   r   r   #   s    '(r   N)r,   typingr   r   r   r   r   r   r   Ztelegramr	   Ztelegram._utils.defaultvaluer
   Ztelegram._utils.typesr   Ztelegram.extr   r   Z"telegram.ext._handlers.basehandlerr   Ztelegram.ext._utils.typesr   r   r   r   r   r   r   r   r   <module>   s   $