§
    ­eîiù#  ã                   óâ   — d Z ddlZddlZddlm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 dd
lmZmZ erddlmZ  e
d¦  «        Z G d„ deeeef         ¦  «        ZdS )z4This module contains the CallbackQueryHandler class.é    N)ÚCallable)ÚMatchÚPattern)ÚTYPE_CHECKINGÚAnyÚTypeVarÚcast)ÚUpdate)ÚDEFAULT_TRUE)ÚDVType)ÚBaseHandler)ÚCCTÚHandlerCallback)ÚApplicationÚRTc                   óú   ‡ — e Zd ZdZdZddefdddeeee	f         de
ee
         z  ez  eegef         z  dz  de
ee
         z  dz  d	ee         f
ˆ fd
„Zdedeez  dz  fd„Zdededddeee
         z  ddf
d„Zˆ xZS )ÚCallbackQueryHandleraÇ  Handler class to handle Telegram
    :attr:`callback queries <telegram.Update.callback_query>`. Optionally based on a regex.

    Read the documentation of the :mod:`re` module for more information.

    Note:
        * If your bot allows arbitrary objects as
          :paramref:`~telegram.InlineKeyboardButton.callback_data`, it may happen that the
          original :attr:`~telegram.InlineKeyboardButton.callback_data` for the incoming
          :class:`telegram.CallbackQuery` can not be found. This is the case when either a
          malicious client tempered with the :attr:`telegram.CallbackQuery.data` or the data was
          simply dropped from cache or not persisted. In these
          cases, an instance of :class:`telegram.ext.InvalidCallbackData` will be set as
          :attr:`telegram.CallbackQuery.data`.

          .. versionadded:: 13.6

        * If neither :paramref:`pattern` nor :paramref:`game_pattern` is set, `any`
          ``CallbackQuery`` will be handled. If only :paramref:`pattern` is set, queries with
          :attr:`~telegram.CallbackQuery.game_short_name` will `not` be considered and vice versa.
          If both patterns are set, queries with either :attr:
          `~telegram.CallbackQuery.game_short_name` or :attr:`~telegram.CallbackQuery.data`
          matching the defined pattern will be handled

          .. versionadded:: 21.5

    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.

    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`.
        pattern (:obj:`str` | :func:`re.Pattern <re.compile>` | :obj:`callable` | :obj:`type`,             optional):
            Pattern to test :attr:`telegram.CallbackQuery.data` against. If a string or a regex
            pattern is passed, :func:`re.match` is used on :attr:`telegram.CallbackQuery.data` to
            determine if an update should be handled by this handler. If your bot allows arbitrary
            objects as :paramref:`~telegram.InlineKeyboardButton.callback_data`, non-strings will
            be accepted. To filter arbitrary objects you may pass:

            - a callable, accepting exactly one argument, namely the
              :attr:`telegram.CallbackQuery.data`. It must return :obj:`True` or
              :obj:`False`/:obj:`None` to indicate, whether the update should be handled.
            - a :obj:`type`. If :attr:`telegram.CallbackQuery.data` is an instance of that type
              (or a subclass), the update will be handled.

            If :attr:`telegram.CallbackQuery.data` is :obj:`None`, the
            :class:`telegram.CallbackQuery` update will not be handled.

            .. seealso:: :wiki:`Arbitrary callback_data <Arbitrary-callback_data>`

            .. versionchanged:: 13.6
               Added support for arbitrary callback data.
        game_pattern (:obj:`str` | :func:`re.Pattern <re.compile>` | optional)
            Pattern to test :attr:`telegram.CallbackQuery.game_short_name` against. If a string or
            a regex pattern is passed, :func:`re.match` is used on
            :attr:`telegram.CallbackQuery.game_short_name` to determine if an update should be
            handled by this handler.

            .. versionadded:: 21.5
        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.
        pattern (:func:`re.Pattern <re.compile>` | :obj:`callable` | :obj:`type`): Optional.
            Regex pattern, callback or type to test :attr:`telegram.CallbackQuery.data` against.

            .. versionchanged:: 13.6
               Added support for arbitrary callback data.
        game_pattern (:func:`re.Pattern <re.compile>`): Optional.
            Regex pattern to test :attr:`telegram.CallbackQuery.game_short_name`
        block (:obj:`bool`): Determines whether the return value of the callback should be
            awaited before processing the next handler in
            :meth:`telegram.ext.Application.process_update`.

    )Úgame_patternÚpatternNÚselfzCallbackQueryHandler[CCT, RT]Úcallbackr   r   Úblockc                 ór  •— t          ¦   «                              ||¬¦  «         t          |¦  «        r#t          j        |¦  «        rt          d¦  «        ‚t          |t          ¦  «        rt          j	        |¦  «        }t          |t          ¦  «        rt          j	        |¦  «        }|| _
        || _        d S )N)r   zQThe `pattern` must not be a coroutine function! Use an ordinary function instead.)ÚsuperÚ__init__ÚcallableÚasyncioÚiscoroutinefunctionÚ	TypeErrorÚ
isinstanceÚstrÚreÚcompiler   r   )r   r   r   r   r   Ú	__class__s        €úo/home/div/.hermes/hermes-agent/venv/lib/python3.11/site-packages/telegram/ext/_handlers/callbackqueryhandler.pyr   zCallbackQueryHandler.__init__‚   s²   ø€ õ 	‰Œ×Ò˜¨ÐÑ/Ô/Ð/å�GÑÔð 	¥Ô!<¸WÑ!EÔ!Eð 	ÝØcñô ð õ �g�sÑ#Ô#ð 	*Ý”j Ñ)Ô)ˆGå�l¥CÑ(Ô(ð 	4Ýœ: lÑ3Ô3ˆLØT[ˆŒØ7CˆÔÐÐó    ÚupdateÚreturnc                 ó6  — t          |t          ¦  «        r|j        sdS |j        j        }|j        j        }t          | j        | j        g¦  «        sdS |r—| j        sdS t          | j        t          ¦  «        rt          || j        ¦  «        S t          | j        ¦  «        r|                      |¦  «        S t          |t          ¦  «        sdS t          j        | j        |¦  «        x}r|S n,|r(| j        sdS t          j        | j        |¦  «        x}r|S ndS dS )zäDetermines whether an update should be passed to this handler's :attr:`callback`.

        Args:
            update (:class:`telegram.Update` | :obj:`object`): Incoming update.

        Returns:
            :obj:`bool`

        NTF)r    r
   Úcallback_queryÚdataÚgame_short_nameÚanyr   r   Útyper   r!   r"   Úmatch)r   r'   Úcallback_datar,   r/   s        r%   Úcheck_updatez!CallbackQueryHandler.check_update—   sE  € õ ˜6¥6Ñ*Ô*ð 	¨vÔ/Dð 	Ø�4àÔ-Ô2ˆØ Ô/Ô?ˆå�D”L $Ô"3Ð4Ñ5Ô5ð 	Ø�4ð ð 	Ø”<ð Ø�uÝ˜$œ,­Ñ-Ô-ð ?Ý! -°´Ñ>Ô>Ð>Ý˜œÑ%Ô%ð 3Ø—|’| MÑ2Ô2Ð2Ý˜m­SÑ1Ô1ð Ø�uÝœ ¤¨}Ñ=Ô=Ð=ˆuð Ø�ðð ð 	ØÔ$ð Ø�uÝœ Ô!2°OÑDÔDÐDˆuð Ø�ðð �4Øˆur&   ÚcontextÚapplicationz)Application[Any, CCT, Any, Any, Any, Any]Úcheck_resultc                 óH   — | j         rt          d|¦  «        }|g|_        dS dS )z‘Add the result of ``re.match(pattern, update.callback_query.data)`` to
        :attr:`CallbackContext.matches` as list with one element.
        r   N)r   r	   Úmatches)r   r2   r'   r3   r4   s        r%   Úcollect_additional_contextz/CallbackQueryHandler.collect_additional_contextÂ   s4   € ð Œ<ð 	-Ý ¨Ñ6Ô6ˆLØ+˜nˆGŒOˆOˆOð	-ð 	-r&   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r   r
   r   r   r!   r   r.   r   ÚobjectÚboolr   r   r1   r   r7   Ú__classcell__)r$   s   @r%   r   r   '   sW  ø€ € € € € ðVð Vðp ,€Ið
 PTØ26Ø*ðDð DØ-ðDà! &¨#¨r /Ô2ðDð �w˜s”|Ñ# dÑ*¨X°v°hÀ°nÔ-EÑEÈÑLðDð ˜G CœLÑ(¨4Ñ/ð	Dð
 �dŒ|ðDð Dð Dð Dð Dð Dð*) 6ð )¨d°V©m¸dÑ.Bð )ð )ð )ð )ðV-àð-ð ð-ð Að	-ð
 ˜U 3œZÑ'ð-ð 
ð-ð -ð -ð -ð -ð -ð -ð -r&   r   )r;   r   r"   Úcollections.abcr   r   r   Útypingr   r   r   r	   Útelegramr
   Útelegram._utils.defaultvaluer   Útelegram._utils.typesr   Ú"telegram.ext._handlers.basehandlerr   Útelegram.ext._utils.typesr   r   Útelegram.extr   r   r   © r&   r%   ú<module>rI      s=  ðð& ;Ð :à €€€Ø 	€	€	€	Ø $Ð $Ð $Ð $Ð $Ð $Ø Ð Ð Ð Ð Ð Ð Ð Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4à Ð Ð Ð Ð Ð Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø (Ð (Ð (Ð (Ð (Ð (Ø :Ð :Ð :Ð :Ð :Ð :Ø :Ð :Ð :Ð :Ð :Ð :Ð :Ð :àð )Ø(Ð(Ð(Ð(Ð(Ð(à€WˆT�]„]€ðg-ð g-ð g-ð g-ð g-˜; v¨s°B Ô7ñ g-ô g-ð g-ð g-ð g-r&   