+
    kHàjk
  ã                  óÐ   € R t ^ RIHt ^ RIt^ RIHtHtHtHt ^ RI	H
t
 ^ RIHt ^ RIHt ]P                  ! ]4      t]].]]]]]3,          ,          ,          3,          tR R ltR# )	aÈ  Opt-in root-DM -> fresh topic transfer for Telegram ``/topic`` mode (``dm_topic_auto_transfer``).

Off by default: a root-DM message keeps the v0.22 lobby recovery and is answered in the user's
most recently bound topic (#136567). With the key on, the runner's transfer hook creates a new
topic and the message (and its reply) move there before session keying; if creating the topic
fails, the hook answers with the lobby-recovery topic instead (#139136).
)ÚannotationsN)ÚAnyÚ	AwaitableÚCallableÚOptional)Ú coerce_plaintext_gateway_command)ÚMessageEvent)Úreplace_sourcec               ó$   € V ^8„  d   QhRRRRRR/# )é   Úadapterr   Úeventr   ÚreturnÚNone© )Úformats   "ÚW/home/ubuntu/.hermes/hermes-agent/plugins/platforms/telegram/telegram_topic_transfer.pyÚ__annotate__r      s!   € ÷  %ñ  %°ð  %¸Lð  %ÈTñ  %ó    c              ƒ  ó:  "  € \        V RR4      p\        VRR4      pVe   Ve   \        VRR4      R8w  d   R# \        VRR4      '       d   \        V4       \        VRR4      '       g   VP                  4       '       d   R# \        VP                  ;'       g    / P                  R	4      ;'       g    R
4      P                  4       '       d   R# V P                  VP                  VP                  VP                  4      RJ d   R#  V! V4      G Rj  x€L
 pT'       g   R# Tw  rVT'       g   \        T\        T4      R7      Tn        R# \        T\        T4      RR7      Tn        R
Tn        R#  L\  \         d    \        P                  RRR7        R# i ; i5i)a  Rewrite ``event.source`` onto the topic the transfer hook picks; no-op when it declines.

Runs at adapter ingress, before session keying, so the turn, its session and its reply all use
the new topic. Commands, internal wakes, routed events and non-DM traffic are never moved.
Ú_topic_transfer_fnNÚsourceÚ	chat_typeÚdmÚallow_gateway_controlFÚinternalÚgateway_session_keyÚ z#telegram topic transfer hook failedT)Úexc_info)Ú	thread_id)r   Ú
message_id)Úgetattrr   Úget_commandÚstrÚmetadataÚgetÚstripÚ_is_sender_authorizedÚuser_idr   Úchat_idÚ	ExceptionÚloggerÚdebugr	   r   Úreply_anchor_override)r   r   Útransferr   Údecidedr   Úcreateds   &&     r   Úapply_root_dm_topic_transferr1      sZ  é € ô +2°'Ð;OÐQUÓ*V€HÜ�U˜H dÓ+€FØÒ˜6š>¬W°V¸[È$Ó-OÐSWÔ-WÙÜˆuÐ-¨u×5Ò5Ü(¨Ô/Üˆu�j %×(Ò(¨E×,=Ñ,=×,?Ò,?ÙÜ
ˆE�N‰N× Ð ˜b×%Ñ%Ð&;Ó<×BÐBÀÓC×IÑI×KÒKÙØ×$Ñ$ V§^¡^°V×5EÑ5EÀvÇ~Á~ÓVÐZ_Ó_ÙðÙ  Ó(×(ˆ÷ ÙØ Ñ€IßÜ% f¼¸I»ÔGˆŒÙô " &´C¸	³NÈtÔT€E„LØ"$€EÖñ )øÜô Ü�‰Ð:ÀTˆÔJÚðüs[   ‚A=FÂ FÂFÂ3FÃ9FÄE2 ÄE0ÄE2 ÄFÄ AFÅ0E2 Å2"FÆFÆFÆF)Ú__doc__Ú
__future__r   ÚloggingÚtypingr   r   r   r   Úgateway.platforms.baser   Úgateway.platforms.eventr   Úgateway.session_identityr	   Ú	getLoggerÚ__name__r+   Útupler#   ÚboolÚTopicTransferFnr1   r   r   r   Ú<module>r>      s\   ðñõ #ã ß 5Ó 5å CÝ 0Ý 3à	×	Ò	˜8Ó	$€ð ˜C˜5 )¨H°U¸3À¸9Õ5EÕ,FÕ"GÐGÕH€÷ %r   