o
    -˜Žjd  ã                   @  sX   d dl mZ d dlmZ d dlmZ ddlmZ d dlZd dl	m
Z
 G dd	„ d	eƒZdS )
é    )Úannotations)ÚIterable)ÚCallableé   )ÚHandlerN)ÚUpdatec                      s:   e Zd ZdZ	dd‡ fdd„Zddd„Zddd„Z‡  ZS )ÚErrorHandleraü  The Error handler class. Used to handle errors.
    It is intended to be used with :meth:`~pyrogram.Client.add_handler`

    For a nicer way to register this handler, have a look at the
    :meth:`~pyrogram.Client.on_error` decorator.

    Parameters:
        callback (``Callable``):
            Pass a function that will be called when a new Error arrives. It takes *(client, error)*
            as positional arguments (look at the section below for a detailed description).

        exceptions (``Exception`` | Iterable of ``Exception``, *optional*):
            Pass one or more exception classes to allow only a subset of errors to be passed
            in your callback function.

    Other parameters:
        client (:obj:`~pyrogram.Client`):
            The Client itself, useful when you want to call other API methods inside the error handler.

        update (:obj:`~pyrogram.Update`):
            The update that caused the error.

        error (``Exception``):
            The error that was raised.
    NÚcallbackr   Ú
exceptionsú2type[Exception] | Iterable[type[Exception]] | Nonec                   s4   t |tƒr	t|ƒn|r|fntf| _tƒ  |¡ d S ©N)Ú
isinstancer   ÚtupleÚ	Exceptionr
   ÚsuperÚ__init__)Úselfr	   r
   ©Ú	__class__© ú\/var/www/kodo/Anonymous/send/lib/python3.10/site-packages/pyrogram/handlers/error_handler.pyr   :   s   
ÿÿûzErrorHandler.__init__Úclientúpyrogram.ClientÚupdater   Ú	exceptionr   ÚreturnÚboolc                 Ã  s*   �t || jƒr|  |||¡I d H  dS dS )NTF)r   r
   r	   )r   r   r   r   r   r   r   ÚcheckH   s
   €zErrorHandler.checkÚerrorú+type[Exception] | Iterable[type[Exception]]c                 C  s   t || jƒS r   )r   r
   )r   r   r   r   r   Úcheck_removeN   s   zErrorHandler.check_remover   )r	   r   r
   r   )r   r   r   r   r   r   r   r   )r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r    Ú__classcell__r   r   r   r   r      s    ý
r   )Ú
__future__r   Úcollections.abcr   Útypingr   Úhandlerr   ÚpyrogramÚpyrogram.typesr   r   r   r   r   r   Ú<module>   s   