§
    ®eîi¾  ã                   óÊ   — d Z ddlZddlmZmZmZ ddlmZ ddlm	Z	 ddl
mZ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 )z-This module contains the PrefixHandler class.é    N)ÚTYPE_CHECKINGÚAnyÚTypeVar)ÚUpdate)ÚDEFAULT_TRUE)ÚSCTÚDVType)Úfilters)ÚBaseHandler)ÚCCTÚHandlerCallback)ÚApplicationÚRTc                   ó$  ‡ — e Zd ZdZdZdefdddee         dee         dee	e
ef         d	ej        dz  d
ee         fˆ fd„Zdedeeee         eeeef         z  dz  f         z  dz  fd„Zde
de	dddeeee         ef         z  dz  ddf
d„Zˆ xZS )ÚPrefixHandlera°  Handler class to handle custom prefix commands.

    This is an intermediate handler between :class:`MessageHandler` and :class:`CommandHandler`.
    It supports configurable commands with the same options as :class:`CommandHandler`. It will
    respond to every combination of :paramref:`prefix` and :paramref:`command`.
    It will add a :obj:`list` to the :class:`CallbackContext` named :attr:`CallbackContext.args`,
    containing a list of strings, which is the text following the command split on single or
    consecutive whitespace characters.

    Examples:

        Single prefix and command:

        .. code:: python

            PrefixHandler("!", "test", callback)  # will respond to '!test'.

        Multiple prefixes, single command:

        .. code:: python

            PrefixHandler(["!", "#"], "test", callback)  # will respond to '!test' and '#test'.

        Multiple prefixes and commands:

        .. code:: python

            PrefixHandler(
                ["!", "#"], ["test", "help"], callback
            )  # will respond to '!test', '#test', '!help' and '#help'.


    By default, the handler listens to messages as well as edited messages. To change this behavior
    use :attr:`~filters.UpdateType.EDITED_MESSAGE <telegram.ext.filters.UpdateType.EDITED_MESSAGE>`

    Note:
        * :class:`PrefixHandler` does *not* handle (edited) channel posts.

    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.

    .. versionchanged:: 20.0

        * :class:`PrefixHandler` is no longer a subclass of :class:`CommandHandler`.
        * Removed the attributes ``command`` and ``prefix``. Instead, the new :attr:`commands`
          contains all commands that this handler listens to as a :class:`frozenset`, which
          includes the prefixes.
        * Updating the prefixes and commands this handler listens to is no longer possible.

    Args:
        prefix (:obj:`str` | Collection[:obj:`str`]):
            The prefix(es) that will precede :paramref:`command`.
        command (:obj:`str` | Collection[:obj:`str`]):
            The command or list of commands this handler should listen for. Case-insensitive.
        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`.
        filters (:class:`telegram.ext.filters.BaseFilter`, optional): A filter inheriting from
            :class:`telegram.ext.filters.BaseFilter`. Standard filters can be found in
            :mod:`telegram.ext.filters`. Filters can be combined using bitwise
            operators (``&`` for :keyword:`and`, ``|`` for :keyword:`or`, ``~`` for :keyword:`not`)
        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:
        commands (frozenset[:obj:`str`]): The commands that this handler will listen for, i.e. the
            combinations of :paramref:`prefix` and :paramref:`command`.
        callback (:term:`coroutine function`): The callback function for this handler.
        filters (:class:`telegram.ext.filters.BaseFilter`): Optional. Only allow updates with these
            Filters.
        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`.

    )Úcommandsr
   NÚselfzPrefixHandler[CCT, RT]ÚprefixÚcommandÚcallbackr
   Úblockc                 ó¼  •— t          ¦   «                              ||¬¦  «         t          |t          ¦  «        r|                     ¦   «         hnd„ |D ¦   «         }t          |t          ¦  «        r|                     ¦   «         hnd„ |D ¦   «         }t          d„ t          j        ||¦  «        D ¦   «         ¦  «        | _        |�|nt          j
        j        | _        d S )N)r   r   c                 ó6   — h | ]}|                      ¦   «         ’ŒS © ©Úlower©Ú.0Úxs     úh/home/div/.hermes/hermes-agent/venv/lib/python3.11/site-packages/telegram/ext/_handlers/prefixhandler.pyú	<setcomp>z)PrefixHandler.__init__.<locals>.<setcomp>ˆ   s!   € ÐD_ÐD_ÐD_ÐSTÀQÇWÂWÁYÄYÐD_ÐD_ÐD_ó    c                 ó6   — h | ]}|                      ¦   «         ’ŒS r   r   r   s     r    r!   z)PrefixHandler.__init__.<locals>.<setcomp>Š   s!   € ÐFbÐFbÐFbÐUVÀqÇwÂwÁyÄyÐFbÐFbÐFbr"   c              3   ó&   K  — | ]\  }}||z   V — Œd S )Nr   )r   ÚpÚcs      r    ú	<genexpr>z)PrefixHandler.__init__.<locals>.<genexpr>Œ   s;   è è € ð 2
ð 2
Ù�a˜ˆA�‰Eð2
ð 2
ð 2
ð 2
ð 2
ð 2
r"   )ÚsuperÚ__init__Ú
isinstanceÚstrr   Ú	frozensetÚ	itertoolsÚproductr   Úfilters_moduleÚ
UpdateTypeÚMESSAGESr
   )	r   r   r   r   r
   r   Úprefixesr   Ú	__class__s	           €r    r)   zPrefixHandler.__init__~   sã   ø€ õ 	‰Œ×Ò (°%ÐÑ8Ô8Ð8å'1°&½#Ñ'>Ô'>Ð_�F—L’L‘N”NÐ#Ð#ÐD_ÐD_ÐX^ÐD_ÑD_ÔD_ˆå(2°7½CÑ(@Ô(@Ðb�G—M’M‘O”OÐ$Ð$ÐFbÐFbÐZaÐFbÑFbÔFbˆå(1ð 2
ð 2
Ý'Ô/°¸(ÑCÔCð2
ñ 2
ô 2
ñ )
ô )
ˆŒð Ð*ˆGˆGµÔ0IÔ0Rð 	Œˆˆr"   ÚupdateÚreturnc                 ó&  — t          |t          ¦  «        r{|j        rt|j        }|j        rf|j                             ¦   «         }|d                              ¦   «         | j        vrdS | j                             |¦  «        }|r|dd…         |fS dS dS )a  Determines whether an update should be passed to this handler's :attr:`callback`.

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

        Returns:
            :obj:`list`: The list of args for the handler.

        r   Né   F)	r*   r   Úeffective_messageÚtextÚsplitr   r   r
   Úcheck_update)r   r4   ÚmessageÚ	text_listÚfilter_results        r    r;   zPrefixHandler.check_update“   s¡   € õ �f�fÑ%Ô%ð 
	¨&Ô*Bð 
	ØÔ.ˆGàŒ|ð Ø#œL×.Ò.Ñ0Ô0�	Ø˜Q”<×%Ò%Ñ'Ô'¨t¬}Ð<Ð<Ø˜4Ø $¤× 9Ò 9¸&Ñ AÔ A�Ø ð 8Ø$ Q R Rœ=¨-Ð7Ð7Ø�uØˆtr"   ÚcontextÚapplicationz)Application[Any, CCT, Any, Any, Any, Any]Úcheck_resultc                 ó¾   — t          |t          ¦  «        rE|d         |_        t          |d         t          ¦  «        r|                     |d         ¦  «         dS dS dS )z³Add text after the command to :attr:`CallbackContext.args` as list, split on single
        whitespaces and add output of data filters to :attr:`CallbackContext` as well.
        r   r7   N)r*   ÚtupleÚargsÚdictr4   )r   r?   r4   r@   rA   s        r    Úcollect_additional_contextz(PrefixHandler.collect_additional_context¬   sg   € õ �l¥EÑ*Ô*ð 	0Ø'¨œ?ˆGŒLÝ˜, qœ/­4Ñ0Ô0ð 0Ø—’˜|¨AœÑ/Ô/Ð/Ð/Ð/ð	0ð 	0ð0ð 0r"   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r   r+   r   r   r   r   r/   Ú
BaseFilterr	   Úboolr)   ÚobjectrC   ÚlistrE   r   r;   rF   Ú__classcell__)r3   s   @r    r   r   %   s_  ø€ € € € € ðSð Sðl (€Ið 59Ø*ð
ð 
Ø&ð
à�C”ð
ð �S”ð
ð " &¨#¨r /Ô2ð	
ð
  Ô*¨TÑ1ð
ð �dŒ|ð
ð 
ð 
ð 
ð 
ð 
ð*Øðà	��d˜3”i ¨¨S°#¨X¬Ñ!6¸Ñ!=Ð=Ô>Ñ	>ÀÑ	Eðð ð ð ð20àð0ð ð0ð Að	0ð
 ˜U 4¨¤9¨d ?Ô3Ñ3°dÑ:ð0ð 
ð0ð 0ð 0ð 0ð 0ð 0ð 0ð 0r"   r   )rJ   r-   Útypingr   r   r   Útelegramr   Útelegram._utils.defaultvaluer   Útelegram._utils.typesr   r	   Útelegram.extr
   r/   Ú"telegram.ext._handlers.basehandlerr   Útelegram.ext._utils.typesr   r   r   r   r   r   r"   r    ú<module>rX      s  ðð& 4Ð 3à Ð Ð Ð Ø .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .à Ð Ð Ð Ð Ð Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø :Ð :Ð :Ð :Ð :Ð :Ø :Ð :Ð :Ð :Ð :Ð :Ð :Ð :àð )Ø(Ð(Ð(Ð(Ð(Ð(à€WˆT�]„]€ðT0ð T0ð T0ð T0ð T0�K ¨¨R Ô0ñ T0ô T0ð T0ð T0ð T0r"   