
    |jQ                        U d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	m
Z
 ddlmZ ddlmZmZ dZded	<   d
Zded<    G d de      Zedd	 	 	 	 	 	 	 	 	 ddZddZddZddZedk(  r e e             y)zNBounded Telegram getMe readiness gate; never calls getUpdates or writes state.    )annotationsN)Callable)Path)AnyFinaldual_coach_pilot_test_botr   EXPECTED_BOT@e788f5d56aef04da3097007e2ab79614f2060607d4331162169733b1208d9377	SUCCESSORc                      e Zd ZdZy)ProbeFailurez'Fail-closed transport readiness result.N)__name__
__module____qualname____doc__     m.omo/evidence/task26/task26-continuous-lifecycle-observer-st_01a007da-v2-e788f5d5/telegram_transport_probe.pyr   r      s    1r   r         $@)expected_usernametimeoutc                 K   | j                         st        d       ||       }	 |4 d{    t        j                  |j	                         |       d{   }ddd      d{    t        dd      }||k7  rt        d      dd	t        d
ddddS 7 l7 A7 3# 1 d{  7  sw Y   CxY w# t
        $ r}t        d      |d}~wt        $ r}t        d      |d}~ww xY ww)z;Call only Bot API getMe and require the bound bot identity.ztelegram token unavailableNr   ztelegram getMe timeoutz telegram getMe transport failureusernamez$telegram getMe bot identity mismatchz&task26-telegram-transport-readiness-v1READY_TELEGRAM_TRANSPORTz
Bot.get_meF)schemastatus	successormethodconsumes_updatesmutates_cursorwrites_state)	stripr   asynciowait_forget_meTimeoutError	Exceptiongetattrr   )tokenbot_factoryr   r   botidentityexcr   s           r   
getme_gater/      s      ;;=788
e
CH3$--cjjlGLLH 3 xT2H$$ABB:,!  L 333 >34#= H=>CGHs   $C*B5 BB5 )B BB B5 *B+B5 /+C*B5 B B5  B2&B)'B2.B5 5	C'>C

C'C""C''C*c                   t        | j                               t        j                  d<   t        j                  |        t        j                  d      }|j                         }|j                  j                  |j                  j                        }||j                  r|j                  st        d      |j                  S )zCLoad the existing profile configuration without exposing its token.HERMES_HOMEzgateway.configz*enabled Telegram configuration unavailable)strresolveosenvironchdir	importlibimport_moduleload_gateway_config	platformsgetPlatformTELEGRAMenabledr*   r   )profilegateway_configconfigplatforms       r   
load_tokenrC   8   s     #GOO$5 6BJJ}HHW,,-=>N//1F##N$;$;$D$DEHx//x~~GHH>>r   c                    t        j                  d      }t        j                  d      }|j                  dddd      }|j                  | |      S )Ntelegramztelegram.requestg      @)connect_timeoutread_timeoutwrite_timeoutpool_timeout)r*   request)r7   r8   HTTPXRequestBot)r*   rE   telegram_requestrJ   s       r   production_bot_factoryrN   D   sZ    &&z2H ../AB++	 , G <<eW<55r   c                 X   t        j                         } | j                  ddt               | j                  ddt               | j                         }d|j                  cxk  rdk  sn t        d	t        j                  
       y	 t        j                  t        t        |j                        t        |j                              }t        t'        j(                  |dd             y# t         t"        t$        f$ r(}t        d| t        j                  
       Y d }~yd }~ww xY w)Nz	--profileT)requiredtypez	--timeoutr   )defaultrQ   r   
   z(FAIL_TELEGRAM_TRANSPORT: invalid timeout)file   r   zFAIL_TELEGRAM_TRANSPORT:    ),:)	sort_keys
separators)argparseArgumentParseradd_argumentr   float
parse_argsr   printsysstderrr$   runr/   rC   r?   rN   r   OSError
ValueErrorjsondumps)parserargsresultr.   s       r   mainrk   P   s    $$&F
d>
T>Dt||!r!8szzJ
4<<(&
 
$**Vt

CD	 ':. )#/cjjAs   	AC- -D)D$$D)__main__)
r*   r2   r+   zCallable[[str], Any]r   r2   r   r^   returnzdict[str, object])r?   r   rm   r2   )r*   r2   rm   r   )rm   int)r   
__future__r   r[   r$   r7   rf   r4   ra   collections.abcr   pathlibr   typingr   r   r	   __annotations__r   RuntimeErrorr   r/   rC   rN   rk   r   
SystemExitr   r   r   <module>rv      s    T "     	 
 $  1e 1U	5 U2< 2 *% 	
  @		6. z
TV
 r   