Ë
    :É„j  ã                   ó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 )ÚBotBusinessMessageHandlera¶  The Bot Business Message handler class. Used to handle new bot business 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_bot_business_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      €úe/var/www/html/GAP/venv/lib/python3.12/site-packages/pyrogram/handlers/bot_business_message_handler.pyr   z"BotBusinessMessageHandler.__init__4   s    ø€ Ø!)ˆÔÜ‰Ñ˜×8Ñ8¸'ÕBó    Úclientzpyrogram.ClientÚmessagec           	   ƒ   ó`  K  — |j                   }|r|j                  nd}|r|j                  nd}t        |dt        |dd«      «      }t	        ||j
                  j                  |j
                  j                  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)Ú	from_userr   ÚusernameÚgetattrr   ÚchatÚget_listener_matching_with_dataÚpyrogramÚenumsÚListenerTypesÚMESSAGEr   Úcallabler   Ú__call__ÚloopÚrun_in_executor)r   r   r   r   r   Úfrom_user_usernamer   ÚdataÚlistenerÚlistener_does_matchr   s              r   Úcheck_if_has_matching_listenerz8BotBusinessMessageHandler.check_if_has_matching_listener8   s3  è ø€ ð ×%Ñ%ˆ	Ù'0�y—|’|°dˆÙ3<˜Y×/Ò/À$Ðä˜W d¬G°G¸\È4Ó,PÓQˆ
äØ!Ø—\‘\—_‘_ g§l¡l×&;Ñ&;Ð<Ø&Ð(:Ð;ô
ˆð ×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$   ‚C/D.Ã1D*Ã2)D.ÄD,ÄD.Ä,D.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)r/   r'   r   r   r(   r)   r*   )r   r   r   r.   Úhandler_does_matchs        r   ÚcheckzBotBusinessMessageHandler.check_   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)r/   Úremove_listenerÚfutureÚdoneÚ
set_resultr#   ÚStopPropagationr   r   Ú
ValueErrorr   )r   r   r   Úargsr.   r-   s         r   r   z4BotBusinessMessageHandler.resolve_future_or_callbacky   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   r/   r2   r   Ú__classcell__)r   s   @r   r
   r
      sX   ø„ ññ.C õ Cð%-Ð;Lð %-ÐW^ó %-ðN9Ð"3ð 9¸gó 9ð4AÐ7Hð AÐSZ÷ Ar   r
   )Úinspectr   Útypingr   r#   Úpyrogram.typesr   r   Úhandlerr   r
   © r   r   ú<module>rE      s&   ðõ& (Ý Û ç .å ô{A õ {Ar   