Ë
    :É„j  ã                   ój   — d dl mZ d dlmZmZ d dlZd dlmZ d dlm	Z	m
Z
mZ ddlmZ  G d„ d	e«      Zy)
é    )Úiscoroutinefunction)ÚCallableÚTupleN)ÚPyromodConfig)ÚCallbackQueryÚ
IdentifierÚListeneré   )ÚHandlerc                   ót   ‡ — e Zd ZdZddefˆ fd„Zdefd„Zdddedee	e
f   fd	„Zdddefd
„Zdddefd„Zˆ xZS )ÚCallbackQueryHandleraä  The CallbackQuery handler class. Used to handle callback queries coming from inline buttons.
    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_callback_query` decorator.

    Parameters:
        callback (``Callable``):
            Pass a function that will be called when a new CallbackQuery arrives. It takes *(client, callback_query)*
            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 callback queries 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.

        callback_query (:obj:`~pyrogram.types.CallbackQuery`):
            The received callback query.
    Úcallbackc                 óH   •— || _         t        ‰| �	  | j                  |«       y ©N)Úoriginal_callbackÚsuperÚ__init__Úresolve_future_or_callback)Úselfr   ÚfiltersÚ	__class__s      €ú_/var/www/html/GAP/venv/lib/python3.12/site-packages/pyrogram/handlers/callback_query_handler.pyr   zCallbackQueryHandler.__init__7   s    ø€ Ø!)ˆÔÜ‰Ñ˜×8Ñ8¸'ÕBó    Úqueryc           	      ó´  — |j                   }|r|j                  nd}|r|j                  nd}d}d}|j                  r‚t	        |j                  dt	        |j                  dd«      «      }|j                  j
                  r@|j                  j
                  j                  |j                  j
                  j                  g}t        ||||g|j                  ¬«      S )z²
        Composes an Identifier object from a CallbackQuery object.

        :param query: The CallbackQuery object to compose of.
        :return: An Identifier object.
        NÚidÚ
message_id)r   Úchat_idÚfrom_user_idÚinline_message_id)Ú	from_userr   ÚusernameÚmessageÚgetattrÚchatr   r    )r   r   r!   r   Úfrom_user_usernamer   r   s          r   Úcompose_data_identifierz,CallbackQueryHandler.compose_data_identifier;   s»   € ð —O‘Oˆ	Ù'0�y—|’|°dˆÙ3<˜Y×/Ò/À$ÐàˆØˆ
à�=Š=Ü Ø—‘˜t¤W¨U¯]©]¸LÈ$Ó%OóˆJð �}‰}×!Ò!Ø Ÿ=™=×-Ñ-×0Ñ0°%·-±-×2DÑ2D×2MÑ2MÐN�äØ!ØØ&Ð(:Ð;Ø#×5Ñ5ô	
ð 	
r   Úclientzpyrogram.ClientÚreturnc              ƒ   ó†  K  — | j                  |«      }|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)a³  
        Checks if the CallbackQuery object has a matching listener.

        :param client: The Client object to check with.
        :param query: The CallbackQuery object to check with.
        :return: A tuple of a boolean and a Listener object. The boolean indicates whether
        the found listener has filters and its filters matches with the CallbackQuery object.
        The Listener object is the matching listener.
        FNT)r'   Úget_listener_matching_with_dataÚpyrogramÚenumsÚListenerTypesÚCALLBACK_QUERYr   Úcallabler   Ú__call__ÚloopÚrun_in_executor)r   r(   r   ÚdataÚlistenerÚlistener_does_matchr   s          r   Úcheck_if_has_matching_listenerz3CallbackQueryHandler.check_if_has_matching_listenerX   s×   è ø€ ð ×+Ñ+¨EÓ2ˆà×9Ñ9Ø”(—.‘.×.Ñ.×=Ñ=ó
ˆð $ÐáØ×&Ñ&ˆGÜ˜Ô Ü& w×'7Ñ'7Ô8Ù07¸ÀÓ0F×*FÐ'ð # HÐ,Ð,ð 17·±×0KÑ0KØ˜g v¨uó1÷ +Ð'ð # HÐ,Ð,ð '+Ð#à" HÐ,Ð,ð +Gøð+ús$   ‚BCÂB=Â)CÂ.B?Â/CÂ?Cc              ƒ   óê  K  — | j                  ||«      ƒ d{  –—† \  }}t        | j                  «      rkt        | j                  j                  «      r| j                  ||«      ƒ d{  –—† }n3|j
                  j                  d| j                  ||«      ƒ d{  –—† }nd}| j                  |«      }t        j                  r t        |j                  |j                  |j                  d¬«      }|j                  |«      }|r`|r^|s\|j                  rPt        |j                  t         «      r|j                  nt        j"                  }	|j%                  |	«      ƒ d{  –—†  y|xs |S 7 �ŒQ7 �Œ7 ŒÔ7 Œ­w)aU  
        Checks if the CallbackQuery object has a matching listener or handler.

        :param client: The Client object to check with.
        :param query: The CallbackQuery object to check with.
        :return: A boolean indicating whether the CallbackQuery object has a matching listener or the handler
        filter matches.
        NT)r   r   r    r   F)r7   r0   r   r   r1   r2   r3   r'   r   Úunallowed_click_alertr   r   r   r    ÚmatchesÚ
isinstanceÚstrÚunallowed_click_alert_textÚanswer)
r   r(   r   r6   r5   Úhandler_does_matchr4   Úpermissive_identifierr:   Úalerts
             r   ÚcheckzCallbackQueryHandler.checkz   sX  è ø€ ð /3×.QÑ.QØ�Eó/
÷ )
Ñ%Ð˜Xô �D—L‘LÔ!Ü" 4§<¡<×#8Ñ#8Ô9Ø+/¯<©<¸ÀÓ+F×%FÑ"à+1¯;©;×+FÑ+FØ˜$Ÿ,™,¨°ó,÷ &Ñ"ð "&Ðà×+Ñ+¨EÓ2ˆä×.Ò.ä$.ØŸ™ØŸ?™?Ø"&×"8Ñ"8Ø!ô	%Ð!ð ,×3Ñ3°DÓ9ˆGñ ÙÑ%8Ø×2Ò2ô " (×"@Ñ"@Ä#ÔFð ×2Ò2ä&×AÑAð ð
 —l‘l 5Ó)×)Ð)Øð #Ò8Ð&8Ð8ðU)
ùð &Gùð&øð: *úsG   ‚E3˜E)™AE3Á)E,Á*0E3ÂE/ÂCE3ÅE1ÅE3Å,E3Å/E3Å1E3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)aZ  
        Resolves the future or calls the callback of the listener. Will call the original handler if no listener.

        :param client: The Client object to resolve or call with.
        :param query: The CallbackQuery object to resolve or call with.
        :param args: The arguments to call the callback with.
        :return: None
        Nz0Listener must have either a future or a callback)r7   Úremove_listenerÚfutureÚdoneÚ
set_resultr,   ÚStopPropagationr   r   Ú
ValueErrorr   )r   r(   r   Úargsr6   r5   s         r   r   z/CallbackQueryHandler.resolve_future_or_callback¯   s  è ø€ ð /3×.QÑ.QØ�Eó/
÷ )
Ñ%Ð˜Xñ Ñ+Ø×"Ñ" 8Ô,à�Š x§¡×';Ñ';Ô'=Ø—‘×*Ñ*¨5Ô1ä×.Ñ.Ð.Ø×"Ò"Ü& x×'8Ñ'8Ô9Ø+˜(×+Ñ+¨F°EÐA¸DÒA×AÐAô ×.Ñ.Ð.ð &�H×%Ñ% f¨eÐ;°dÓ;ä×.Ñ.Ð.ä Ð!SÓTÐTà(�$×(Ñ(¨°Ð>¸Ò>×>Ñ>ð+)
ùð Bøð ?ús5   ‚D&˜D™B%D&Â>D"Â?AD&ÄD$ÄD&Ä"D&Ä$D&r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r'   r   Úboolr	   r7   rB   r   Ú__classcell__)r   s   @r   r   r      ss   ø„ ññ.C õ Cð
¨]ó 
ð: -Ø'ð -Ø0=ð -à	ˆt�Xˆ~Ñ	ó -ðD39Ð"3ð 39¸Mó 39ðj ?Ø'ð ?Ø0=÷ ?r   r   )Úasyncior   Útypingr   r   r,   Úpyrogram.utilsr   Úpyrogram.typesr   r   r	   Úhandlerr   r   © r   r   ú<module>rW      s*   ðõ( (ß "ã å (ß >Ñ >å ôp?˜7õ p?r   