§
    «eîiñ  ã            	       óò   — d Z dZddl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mZ 	 dd
edededz  defd„Zdeez  dedefd„Zddeez  dededefd„Zdddedz  fd„Z	 ddededz  dedefd„ZdS )zÎThis module contains convenience helper functions.

.. versionchanged:: 20.0
   Previously, the contents of this module were available through the (no longer existing)
   module ``telegram.utils.helpers``.
)Úcreate_deep_linked_urlÚeffective_message_typeÚescape_markdownÚmention_htmlÚmention_markdowné    N©Úescape)ÚTYPE_CHECKING)ÚMarkdownVersion)ÚMessageLimitÚMessageType©ÚMessageÚUpdateé   ÚtextÚversionÚentity_typeÚreturnc                 óì   — t          |¦  «        dk    rd}n3t          |¦  «        dk    r|dv rd}n|dv rd}nd}nt          d	¦  «        ‚t          j        d
t          j        |¦  «        › d�d| ¦  «        S )a²  Helper function to escape telegram markup symbols.

    .. versionchanged:: 20.3
        Custom emoji entity escaping is now supported.

    Args:
        text (:obj:`str`): The text.
        version (:obj:`int` | :obj:`str`): Use to specify the version of telegrams Markdown.
            Either ``1`` or ``2``. Defaults to ``1``.
        entity_type (:obj:`str`, optional): For the entity types
            :tg-const:`telegram.MessageEntity.PRE`, :tg-const:`telegram.MessageEntity.CODE` and
            the link part of :tg-const:`telegram.MessageEntity.TEXT_LINK` and
            :tg-const:`telegram.MessageEntity.CUSTOM_EMOJI`, only certain characters need to be
            escaped in :tg-const:`telegram.constants.ParseMode.MARKDOWN_V2`. See the `official API
            documentation <https://core.telegram.org/bots/api#formatting-options>`_ for details.
            Only valid in combination with ``version=2``, will be ignored else.
    r   z_*`[é   )ÚpreÚcodez\`)Ú	text_linkÚcustom_emojiz\)z\_*[]()~`>#+-=|{}.!z'Markdown version must be either 1 or 2!z([z])z\\\1)ÚintÚ
ValueErrorÚreÚsubr	   )r   r   r   Úescape_charss       úT/home/div/.hermes/hermes-agent/venv/lib/python3.11/site-packages/telegram/helpers.pyr   r   -   s’   € õ( ˆ7�|„|�qÒÐØˆˆÝ	ˆW‰Œ˜Ò	Ð	Ø˜/Ð)Ð)Ø ˆLˆLØÐ9Ð9Ð9Ø ˆLˆLà1ˆLˆLåÐBÑCÔCÐCåŒ6Ð2•r”y Ñ.Ô.Ð2Ð2Ð2°G¸TÑBÔBÐBó    Úuser_idÚnamec                 ó.   — d| › dt          |¦  «        › d�S )a  
    Helper function to create a user mention as HTML tag.

    Args:
        user_id (:obj:`int`): The user's id which you want to mention.
        name (:obj:`str`): The name the mention is showing.

    Returns:
        :obj:`str`: The inline mention for the user as HTML.
    z<a href="tg://user?id=z">z</a>r   )r#   r$   s     r!   r   r   P   s$   € ð B GÐAÐA­v°d©|¬|ÐAÐAÐAÐAr"   c                 óZ   — d| › �}|dk    r	d|› d|› d�S dt          ||¬¦  «        › d|› d�S )a·  
    Helper function to create a user mention in Markdown syntax.

    Args:
        user_id (:obj:`int`): The user's id which you want to mention.
        name (:obj:`str`): The name the mention is showing.
        version (:obj:`int` | :obj:`str`): Use to specify the version of Telegram's Markdown.
            Either ``1`` or ``2``. Defaults to ``1``.

    Returns:
        :obj:`str`: The inline mention for the user as Markdown.
    ztg://user?id=r   Ú[z](ú))r   )r   )r#   r$   r   Útg_links       r!   r   r   ^   sY   € ð (˜gÐ'Ð'€GØ�!‚|€|Ø%�4Ð%Ð%˜7Ð%Ð%Ð%Ð%ØC�˜t¨WÐ5Ñ5Ô5ÐCÐC¸ÐCÐCÐCÐCr"   ÚentityzMessage | Updatec                 óê   — ddl m}m} t          | |¦  «        r| }nAt          | |¦  «        r| j        sdS | j        }n t          dt          | ¦  «        › d�¦  «        ‚t          D ]}||         r|c S ŒdS )aÏ  
    Extracts the type of message as a string identifier from a :class:`telegram.Message` or a
    :class:`telegram.Update`.

    Args:
        entity (:class:`telegram.Update` | :class:`telegram.Message`): The ``update`` or
            ``message`` to extract from.

    Returns:
        :obj:`str` | :obj:`None`: One of :class:`telegram.constants.MessageType` if the entity
        contains a message that matches one of those types. :obj:`None` otherwise.

    r   r   Nz/The entity is neither Message nor Update (got: r(   )Útelegramr   r   Ú
isinstanceÚeffective_messageÚ	TypeErrorÚtyper   )r*   r   r   ÚmessageÚmessage_types        r!   r   r   q   sÇ   € ðð ð ð ð ð ð ð õ
 �&˜'Ñ"Ô"ð [ØˆˆÝ	�F˜FÑ	#Ô	#ð [ØÔ'ð 	Ø�4ØÔ*ˆˆåÐYÍ$ÈvÉ,Ì,ÐYÐYÐYÑZÔZÐZå#ð  ð  ˆØ�<Ô ð 	 ØÐÐÐð	 ð ˆ4r"   FÚbot_usernameÚpayloadÚgroupc                 ó8  — | �t          | ¦  «        dk    rt          d¦  «        ‚d| › �}|s|S t          |¦  «        t          j        k    rt          dt          j        › d�¦  «        ‚t	          j        d|¦  «        st          d¦  «        ‚|rd	nd
}|› d|› d|› �S )ab  
    Creates a deep-linked URL for this :paramref:`~create_deep_linked_url.bot_username` with the
    specified :paramref:`~create_deep_linked_url.payload`. See
    https://core.telegram.org/bots/features#deep-linking to learn more.

    The :paramref:`~create_deep_linked_url.payload` may consist of the following characters:
    ``A-Z, a-z, 0-9, _, -``

    Note:
        Works well in conjunction with
        ``CommandHandler("start", callback, filters=filters.Regex('payload'))``

    Examples:
        * ``create_deep_linked_url(bot.get_me().username, "some-params")``
        * :any:`Deep Linking <examples.deeplinking>`

    Args:
        bot_username (:obj:`str`): The username to link to.
        payload (:obj:`str`, optional): Parameters to encode in the created URL.
        group (:obj:`bool`, optional): If :obj:`True` the user is prompted to select a group to
            add the bot to. If :obj:`False`, opens a one-on-one conversation with the bot.
            Defaults to :obj:`False`.

    Returns:
        :obj:`str`: An URL to start the bot with specific parameters.

    Raises:
        :exc:`ValueError`: If the length of the :paramref:`payload` exceeds         :tg-const:`telegram.constants.MessageLimit.DEEP_LINK_LENGTH` characters,
            contains invalid characters, or if the :paramref:`bot_username` is less than 4
            characters.
    Né   z&You must provide a valid bot_username.zhttps://t.me/z)The deep-linking payload must not exceed z characters.z^[A-Za-z0-9_-]+$zVOnly the following characters are allowed for deep-linked URLs: A-Z, a-z, 0-9, _ and -Ú
startgroupÚstartú?Ú=)Úlenr   r   ÚDEEP_LINK_LENGTHr   Úmatch)r3   r4   r5   Úbase_urlÚkeys        r!   r   r   •   s×   € ðF Ð�s <Ñ0Ô0°AÒ5Ð5ÝÐAÑBÔBÐBà-˜|Ð-Ð-€HØð Øˆå
ˆ7�|„|•lÔ3Ò3Ð3ÝØc½Ô8UÐcÐcÐcñ
ô 
ð 	
õ Œ8Ð'¨Ñ1Ô1ð 
Ýð+ñ
ô 
ð 	
ð
  Ð
,ˆ,ˆ, W€CàÐ(Ð(˜Ð(Ð(˜wÐ(Ð(Ð(r"   )r   N)r   )NF)Ú__doc__Ú__all__r   Úhtmlr	   Útypingr
   Útelegram._utils.typesr   Útelegram.constantsr   r   r,   r   r   Ústrr   r   r   r   r   Úboolr   © r"   r!   ú<module>rJ      sÊ  ðð&ð ð€ð 
€	€	€	Ø Ð Ð Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  à 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8àð )Ø(Ð(Ð(Ð(Ð(Ð(Ð(Ð(ð HLð Cð  CØ
ð CØ'ð CØ:=À¹*ð Càð Cð  Cð  Cð  CðFB˜# ™)ð B¨3ð B°3ð Bð Bð Bð BðDð D˜c C™ið D¨sð D¸_ð DÐUXð Dð Dð Dð Dð&!Ð#5ð !¸#À¹*ð !ð !ð !ð !ðJ BGð7)ð 7)Øð7)Ø # d¡
ð7)Ø:>ð7)àð7)ð 7)ð 7)ð 7)ð 7)ð 7)r"   