§
    ­eîi   ã            	       óÒ   — d Z ddlmZmZ ddl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mZ erddlmZ  ed	¦  «        Z ed
¦  «        Z G d„ deeeeef         ¦  «        ZdS )zLThis module contains the base class for handlers as used by the Application.é    )ÚABCÚabstractmethod)ÚTYPE_CHECKINGÚAnyÚGenericÚTypeVar)ÚDEFAULT_TRUE)Úbuild_repr_with_selected_attrs)ÚDVType)ÚCCTÚHandlerCallback)ÚApplicationÚRTÚUTc            
       ó¼   — e Zd ZdZdZefdddeeee	f         de
e         fd„Zdefd	„Zed
edeez  dz  fd„¦   «         Zd
edddedede	f
d„Zded
edddeddf
d„ZdS )ÚBaseHandlera¿	  The base class for all update handlers. Create custom handlers by inheriting from it.

    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.

    This class is a :class:`~typing.Generic` class and accepts three type variables:

    1. The type of the updates that this handler will handle. Must coincide with the type of the
       first argument of :paramref:`callback`. :meth:`check_update` must only accept
       updates of this type.
    2. The type of the second argument of :paramref:`callback`. Must coincide with the type of the
       parameters :paramref:`handle_update.context` and
       :paramref:`collect_additional_context.context` as well as the second argument of
       :paramref:`callback`. Must be either :class:`~telegram.ext.CallbackContext` or a subclass
       of that class.

       .. tip::
           For this type variable, one should usually provide a :class:`~typing.TypeVar` that is
           also used for the mentioned method arguments. That way, a type checker can check whether
           this handler fits the definition of the :class:`~Application`.
    3. The return type of the :paramref:`callback` function accepted by this handler.

    .. seealso:: :wiki:`Types of Handlers <Types-of-Handlers>`

    .. versionchanged:: 20.0

        * The attribute ``run_async`` is now :paramref:`block`.
        * This class was previously named ``Handler``.

    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`

    Attributes:
        callback (:term:`coroutine function`): The callback function for this handler.
        block (:obj:`bool`): Determines whether the callback will run in a blocking way.

    )ÚblockÚcallbackÚselfzBaseHandler[UT, CCT, RT]r   r   c                 ó"   — || _         || _        d S )N)r   r   )r   r   r   s      úf/home/div/.hermes/hermes-agent/venv/lib/python3.11/site-packages/telegram/ext/_handlers/basehandler.pyÚ__init__zBaseHandler.__init__]   s   € ð
 7?ˆŒØ#(ˆŒ
ˆ
ˆ
ó    Úreturnc                 óˆ   — 	 | j         j        }n$# t          $ r t          | j         ¦  «        }Y nw xY wt	          | |¬¦  «        S )a!  Give a string representation of the handler in the form ``ClassName[callback=...]``.

        As this class doesn't implement :meth:`object.__str__`, the default implementation
        will be used, which is equivalent to :meth:`__repr__`.

        Returns:
            :obj:`str`
        )r   )r   Ú__qualname__ÚAttributeErrorÚreprr
   )r   Úcallback_names     r   Ú__repr__zBaseHandler.__repr__e   sT   € ð	0Ø œMÔ6ˆMˆMøÝð 	0ð 	0ð 	0Ý  ¤Ñ/Ô/ˆMˆMˆMð	0øøøå-¨d¸]ÐKÑKÔKÐKs   ‚ �0¯0ÚupdateNc                 ó   — dS )aÀ  
        This method is called to determine if an update should be handled by
        this handler instance. It should always be overridden.

        Note:
            Custom updates types can be handled by the application. Therefore, an implementation of
            this method should always check the type of :paramref:`update`.

        Args:
            update (:obj:`object` | :class:`telegram.Update`): The update to be tested.

        Returns:
            Either :obj:`None` or :obj:`False` if the update should not be handled. Otherwise an
            object that will be passed to :meth:`handle_update` and
            :meth:`collect_additional_context` when the update gets handled.

        N© )r   r!   s     r   Úcheck_updatezBaseHandler.check_updatet   ó   € € € r   Úapplicationz)Application[Any, CCT, Any, Any, Any, Any]Úcheck_resultÚcontextc              ƒ   ón   K  — |                       ||||¦  «         |                      ||¦  «        ƒ d{V —†S )a  
        This method is called if it was determined that an update should indeed
        be handled by this instance. Calls :attr:`callback` along with its respectful
        arguments. To work with the :class:`telegram.ext.ConversationHandler`, this method
        returns the value returned from :attr:`callback`.
        Note that it can be overridden if needed by the subclassing handler.

        Args:
            update (:obj:`str` | :class:`telegram.Update`): The update to be handled.
            application (:class:`telegram.ext.Application`): The calling application.
            check_result (:class:`object`): The result from :meth:`check_update`.
            context (:class:`telegram.ext.CallbackContext`): The context as provided by
                the application.

        N)Úcollect_additional_contextr   )r   r!   r&   r'   r(   s        r   Úhandle_updatezBaseHandler.handle_updateˆ   sH   è è € ð, 	×'Ò'¨°¸ÀlÑSÔSÐSØ—]’] 6¨7Ñ3Ô3Ð3Ð3Ð3Ð3Ð3Ð3Ð3r   c                 ó   — dS )a¨  Prepares additional arguments for the context. Override if needed.

        Args:
            context (:class:`telegram.ext.CallbackContext`): The context object.
            update (:class:`telegram.Update`): The update to gather chat/user id from.
            application (:class:`telegram.ext.Application`): The calling application.
            check_result: The result (return value) from :meth:`check_update`.

        Nr#   )r   r(   r!   r&   r'   s        r   r*   z&BaseHandler.collect_additional_context¡   r%   r   )Ú__name__Ú
__module__r   Ú__doc__Ú	__slots__r	   r   r   r   r   r   Úboolr   Ústrr    r   Úobjectr$   r+   r   r*   r#   r   r   r   r   $   sN  € € € € € ð1ð 1ðf€Ið +ð)ð )Ø(ð)à! " c¨2 +Ô.ð)ð �dŒ|ð)ð )ð )ð )ðL˜#ð Lð Lð Lð Lð ð 6ð ¨d°V©m¸dÑ.Bð ð ð ñ „^ðð&4àð4ð Að4ð ð	4ð
 ð4ð 
ð4ð 4ð 4ð 4ð2àðð ðð Að	ð
 ðð 
ðð ð ð ð ð r   r   N)r/   Úabcr   r   Útypingr   r   r   r   Útelegram._utils.defaultvaluer	   Útelegram._utils.reprr
   Útelegram._utils.typesr   Útelegram.ext._utils.typesr   r   Útelegram.extr   r   r   r   r#   r   r   ú<module>r;      s  ðð& SÐ Rà #Ð #Ð #Ð #Ð #Ð #Ð #Ð #Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7à 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø ?Ð ?Ð ?Ð ?Ð ?Ð ?Ø (Ð (Ð (Ð (Ð (Ð (Ø :Ð :Ð :Ð :Ð :Ð :Ð :Ð :àð )Ø(Ð(Ð(Ð(Ð(Ð(à€WˆT�]„]€Ø€WˆT�]„]€ðLð Lð Lð Lð L�#�w˜r 3¨˜{Ô+ñ Lô Lð Lð Lð Lr   