+
    kHàjš	  ã                  ó¼   € R t ^ RIHt ^ RIt^ RIHtHt ^ RIHtH	t	 ]P                  ! R4      tR R ltR R	 ltR
 R lt]P                  ! R4      tR tR R ltR# )z¿Helpers for Telegram Bot API chat identifiers: a ``chat_id`` is a numeric ID (int) or an ``@username``
string for public channels/groups; a bare ``int(chat_id)`` crashes on the username form.)ÚannotationsN)ÚAnyÚUnion)Úparse_nonemptyÚregex_groups_parserz@[A-Za-z0-9_]{4,32}c               ó    € V ^8„  d   QhRRRR/# )é   Úchat_idr   Úreturnz	int | str© )Úformats   "ÚL/home/ubuntu/.hermes/hermes-agent/plugins/platforms/telegram/telegram_ids.pyÚ__annotate__r      s   € ÷ ñ ¨ð °	ñ ó    c                ó~   € \        V 4      P                  4       p \        V4      #   \        \        3 d    Tu # i ; i)zšBot API-compatible chat_id: numeric values (incl. negative channel IDs) as ``int``, anything
else (e.g. ``@username``) as a stripped string; never raises.)ÚstrÚstripÚintÚ	TypeErrorÚ
ValueError)r	   Úchat_id_strs   & r   Únormalize_telegram_chat_idr      s@   € ô �g“,×$Ñ$Ó&€KðÜ�;ÓÐøÜ”zÐ"ô ØÒðús   ›
& ¦<»<c               ó    € V ^8„  d   QhRRRR/# )r   r	   r   r
   Úboolr   )r   s   "r   r   r      s   € ÷ Gñ G¨#ð G°$ñ Gr   c                ól   € \        \        P                  \        V 4      P	                  4       4      4      # )zHTrue when the value is an ``@username``-format Telegram chat identifier.)r   Ú_TELEGRAM_USERNAME_REÚ	fullmatchr   r   )r	   s   &r   Úlooks_like_telegram_usernamer      s&   € äÔ%×/Ñ/´°G³×0BÑ0BÓ0DÓEÓFÐFr   c               ó    € V ^8„  d   QhRRRR/# )r   Ú
target_refr   r
   z
str | Noner   )r   s   "r   r   r      s   € ÷ Bñ B¨sð B°zñ Br   c                ó^   € \        V 4      P                  4       p\        V4      '       d   V# R# )zCReturn the value when it is an ``@username`` target, else ``None``.N)r   r   r   )r   Úvalues   & r   Úparse_telegram_username_targetr"      s)   € ä�
‹O×!Ñ!Ó#€EÜ0°×7Ò7ˆ5ÐA¸TÐAr   z^\s*(-?\d+)(?::(\d+))?\s*$c                ó|   € \        \        4      ! V 4      pV'       d   V# \        \        V 4      ;'       g    R4      # )z<``target_ref_syntax_fn`` for the Telegram ``PlatformEntry``.Ú )r   Ú_SEND_TARGET_REr   r"   )ÚrefÚparseds   & r   Úparse_send_targetr(   '   s4   € ô !¤Ô1°#Ó6€FßØˆÜÔ8¸Ó=×CÐCÀÓDÐDr   c               ó    € V ^8„  d   QhRRRR/# )r   r!   r   r
   z
int | Noner   )r   s   "r   r   r   0   s   € ÷ Vñ V Sð V¨Zñ Vr   c                óD  € \        V \        4      '       d   R# \        V \        4      '       d   V ^ 8”  d   V # R# V e   \        V 4      P	                  4       MRpVP                  4       '       d2   VP                  4       '       d   \        V4      ^ 8”  d   \        V4      # R# )aL  A reply anchor as a Telegram message id (a positive int), or ``None`` when it is not one.

Anchors are opaque event ids upstream: a route wake (kanban-wake, loop-tick) carries a synthetic
JSON identity, and raw ``int()`` on it failed every reply into the session (#139611); an
unanchored reply is strictly better than a failed send.Nr$   )Ú
isinstancer   r   r   r   ÚisasciiÚisdigit)r!   Útexts   & r   Úparse_telegram_message_idr/   0   sy   € ô �%œ×ÒÙÜ�%œ×ÒØ œ	ˆuÐ+ tÐ+Ø!&Ò!2Œ3ˆu‹:×ÑÔ¸€DØŸ™Ÿš¨4¯<©<¯>ª>¼cÀ$»iÈ!¼mŒ3ˆt‹9ÐUÐQUÐUr   )Ú__doc__Ú
__future__r   ÚreÚtypingr   r   Úgateway.platforms.send_targetsr   r   Úcompiler   r   r   r"   r%   r(   r/   r   r   r   Ú<module>r6      sY   ðñ\õ #ã 	ß ç Nð Ÿ
š
Ð#9Ó:Ð õõGõ
Bð —*’*Ð:Ó;€òE÷Vr   