Ë
    :É„jG  ã                   óV   — d dl mZ d dlmZ d dlZd dlmZmZ ddlm	Z	  G d„ de	«      Z
y)	é    )Úiscoroutinefunction)ÚCallableN)ÚMessageÚ
Identifieré   )ÚHandlerc                   óZ   ‡ — e Zd ZdZd
defˆ fd„Zdddefd„Zdddefd„Zdddefd	„Z	ˆ xZ
S )ÚMessageHandlera�  The Message handler class. Used to handle new messages.
    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_message` decorator.

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

        filters (:obj:`Filters`):
            Pass one or more filters to allow only a subset of messages 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 message handler.

        message (:obj:`~pyrogram.types.Message`):
            The received message.
    Úcallbackc                 óH   •— || _         t        ‰| �	  | j                  |«       y ©N)Úoriginal_callbackÚsuperÚ__init__Úresolve_future_or_callback)Úselfr   ÚfiltersÚ	__class__s      €úX/var/www/html/GAP/venv/lib/python3.12/site-packages/pyrogram/handlers/message_handler.pyr   zMessageHandler.__init__4   s    ø€ Ø!)ˆÔÜ‰Ñ˜×8Ñ8¸'ÕBó    Úclientzpyrogram.ClientÚmessagec           	   ƒ   óh  K  — |j                   }|r|j                  nd}|r|j                  nd}|j                  }|r|j                  nd}|r|j                  nd}t	        |dt	        |dd«      «      }	t        |	||g||g¬«      }
|j                  |
t        j                  j                  j                  «      }d}|rm|j                  }t        |«      rTt        |j                  «      r |||«      ƒ d{  –—† }||fS |j                  j!                  d|||«      ƒ d{  –—† }||fS d}||fS 7 Œ87 Œ­w)aJ  
        Checks if the message has a matching listener.

        :param client: The Client object to check with.
        :param message: The Message object to check with.
        :return: A tuple of whether the message has a matching listener and its filters does match with the Message
        and the matching listener;
        NÚidÚ
message_id)r   Úchat_idÚfrom_user_idFT)Úchatr   ÚusernameÚ	from_userÚgetattrr   Úget_listener_matching_with_dataÚpyrogramÚenumsÚListenerTypesÚMESSAGEr   Úcallabler   Ú__call__ÚloopÚrun_in_executor)r   r   r   r   r   Úchat_usernamer    r   Úfrom_user_usernamer   ÚdataÚlistenerÚlistener_does_matchr   s                 r   Úcheck_if_has_matching_listenerz-MessageHandler.check_if_has_matching_listener8   sD  è ø€ ð �|‰|ˆÙ!�$—'’' tˆÙ)-˜Ÿš°4ˆØ×%Ñ%ˆ	Ù'0�y—|’|°dˆÙ3<˜Y×/Ò/À$Ðä˜W d¬G°G¸\È4Ó,PÓQˆ
äØ!Ø˜mÐ,Ø&Ð(:Ð;ô
ˆð ×9Ñ9¸$ÄÇÁ×@\Ñ@\×@dÑ@dÓeˆà#ÐáØ×&Ñ&ˆGÜ˜Ô Ü& w×'7Ñ'7Ô8Ù07¸ÀÓ0H×*HÐ'ð # HÐ,Ð,ð 17·±×0KÑ0KØ˜g v¨wó1÷ +Ð'ð # HÐ,Ð,ð '+Ð#à" HÐ,Ð,ð +Iøð+ús$   ‚C3D2Ã5D.Ã6)D2ÄD0Ä D2Ä0D2c              ƒ   ó`  K  — | j                  ||«      ƒ d{  –—† d   }t        | j                  «      rkt        | j                  j                  «      r| j                  ||«      ƒ d{  –—† }n3|j
                  j                  d| j                  ||«      ƒ d{  –—† }nd}|xs |S 7 Œ�7 Œ@7 Œ­w)aW  
        Checks if the message has a matching listener or handler and its filters does match with the Message.

        :param client: Client object to check with.
        :param message: Message object to check with.
        :return: Whether the message has a matching listener or handler and its filters does match with the Message.
        Nr   T)r0   r'   r   r   r(   r)   r*   )r   r   r   r/   Úhandler_does_matchs        r   ÚcheckzMessageHandler.checkb   sª   è ø€ ð ×5Ñ5°f¸gÓF×FØ
ñÐô �D—L‘LÔ!Ü" 4§<¡<×#8Ñ#8Ô9Ø+/¯<©<¸ÀÓ+H×%HÑ"à+1¯;©;×+FÑ+FØ˜$Ÿ,™,¨°ó,÷ &Ñ"ð "&Ðð #Ò8Ð&8Ð8ð Gøð
 &Iøð&ús4   ‚B.˜B(™AB.Á)B*Á*0B.ÂB,ÂB.Â*B.Â,B.c              ‡   óP  K  — | j                  ||«      ƒ d{  –—† \  }}|rà|rÞ|j                  |«       |j                  rE|j                  j                  «       s+|j                  j	                  |«       t
        j                  ‚|j                  ret        |j                  «      r, |j                  ||g|¢­Ž ƒ d{  –—†  t
        j                  ‚ |j                  ||g|¢­Ž  t
        j                  ‚t        d«      ‚ | j                  ||g|¢­Ž ƒ d{  –—†  y7 �Œ7 Œc7 Œ
­w)aB  
        Resolves the future or calls the callback of the listener if the message has a matching listener.

        :param client: Client object to resolve or call with.
        :param message: Message object to resolve or call with.
        :param args: Arguments to call the callback with.
        :return: None
        Nz0Listener must have either a future or a callback)r0   Úremove_listenerÚfutureÚdoneÚ
set_resultr#   ÚStopPropagationr   r   Ú
ValueErrorr   )r   r   r   Úargsr/   r.   s         r   r   z)MessageHandler.resolve_future_or_callback|   s  è ø€ ð /3×.QÑ.QØ�Gó/
÷ )
Ñ%Ð˜Xñ Ñ+Ø×"Ñ" 8Ô,à�Š x§¡×';Ñ';Ô'=Ø—‘×*Ñ*¨7Ô3ä×.Ñ.Ð.Ø×"Ò"Ü& x×'8Ñ'8Ô9Ø+˜(×+Ñ+¨F°GÐC¸dÒC×CÐCô ×.Ñ.Ð.ð &�H×%Ñ% f¨gÐ=¸Ó=ä×.Ñ.Ð.ä Ð!SÓTÐTà(�$×(Ñ(¨°Ð@¸4Ò@×@Ñ@ð+)
ùð Døð Aús5   ‚D&˜D™B%D&Â>D"Â?AD&ÄD$ÄD&Ä"D&Ä$D&r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r0   r3   r   Ú__classcell__)r   s   @r   r
   r
      sX   ø„ ññ.C õ Cð(-Ð;Lð (-ÐW^ó (-ðT9Ð"3ð 9¸gó 9ð4AÐ7Hð AÐSZ÷ Ar   r
   )Úinspectr   Útypingr   r#   Úpyrogram.typesr   r   Úhandlerr   r
   © r   r   ú<module>rF      s&   ðõ& (Ý Û ç .å ô~A�Wõ ~Ar   