+
    ÁFñj2  ã                   ó†  € ^ RI t ^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHt ^ RIt^ RIHt  ^ R	IHt R
t^ RIHt ^ RIHt ^ RIHt ]'       d   ^ RIHt ]! ]RR7      t ! R R4      t ! R R]P>                  P@                  4      t! ! R R]P>                  PD                  4      t#R#   ] d    Rt Li ; i)é    N)Ú
HTTPStatus)ÚPath)Úsocket)Ú
SSLContext)ÚTracebackType)ÚTYPE_CHECKING)Ú
HTTPServer)Úbind_unix_socketTF)ÚUpdate)Ú
get_logger)ÚExtBot)ÚBotÚUpdater)Ú
class_namec                   óf   a € ] tR t^4t o RtR	tR
V 3R lR lltR
V 3R lR lltV 3R lR ltR	t	V t
R# )ÚWebhookServerz6Thin wrapper around ``tornado.httpserver.HTTPServer``.Nc                ór   <€ V ^8„  d   QhRS[ RS[RRRS[R,          RS[ S[,          S[,          R,          /# )é   ÚlistenÚportÚwebhook_appÚWebhookAppClassÚssl_ctxNÚunix)ÚstrÚintr   r   r   )ÚformatÚ__classdict__s   "€ÚX/opt/hermes-site/venv/lib/python3.14/site-packages/telegram/ext/_utils/webhookhandler.pyÚ__annotate__ÚWebhookServer.__annotate__A   sP   ø€ ÷ -ñ -áð-ñ ð-ð 'ð	-ñ
 ˜dÕ"ð-ñ ‘D�j™6Õ! DÕ(ñ-ó    c                óŽ  € V'       d   \         '       g   \        R 4      h\        W4R7      V n        Wn        W n        RV n        RV n        V'       d   \        V\        4      '       d   WPn        M!V'       d   \        \        V4      4      V n        \        P                  ! 4       V n        \        P                  ! 4       V n        R# )z.This OS does not support binding unix sockets.)Ússl_optionsFN)ÚUNIX_AVAILABLEÚRuntimeErrorr	   Ú_http_serverr   r   Ú
is_runningr   Ú
isinstancer   r
   r   ÚasyncioÚLockÚ_server_lockÚ_shutdown_lock)Úselfr   r   r   r   r   s   &&&&&&r   Ú__init__ÚWebhookServer.__init__A   s   € ÷ Ÿ›ÜÐOÓPÐPÜ& {ÔHˆÔØŒØŒ	ØˆŒØˆŒ	ß”J˜t¤V×,Ò,Ø�IßÜ(¬¨T«Ó3ˆDŒIÜ#ŸLšL›NˆÔÜ%Ÿlšl›nˆÖr"   c                óF   <€ V ^8„  d   QhRS[ P                  R,          RR/# )r   ÚreadyNÚreturn)r*   ÚEvent)r   r   s   "€r   r    r!   W   s$   ø€ ÷ 5ñ 5©¯©¸Õ)=ð 5Èñ 5r"   c              ƒ  óÜ  "  € V P                   ;_uu_4       GR j  x€L
  V P                  '       d'   V P                  P                  V P                  4       M1V P                  P	                  V P
                  V P                  R7       RV n        Ve   VP                  4        \        P                  R4       R R R 4      GR j  x€L
  R #  L¯ L  + GR j  x€L 
 '       g   i     R # ; i5i)N)ÚaddressTzWebhook Server started.)
r,   r   r'   Ú
add_socketr   r   r(   ÚsetÚ_LOGGERÚdebug)r.   r2   s   &&r   Úserve_foreverÚWebhookServer.serve_foreverW   s�   é € Ø×$×$×$Ó$Ø�y�yˆyØ×!Ñ!×,Ñ,¨T¯Y©YÕ7à×!Ñ!×(Ñ(¨¯©¸D¿K¹KÐ(ÔHà"ˆDŒOØÒ Ø—	‘	”ä�M‰MÐ3Ô4÷ %×$×$×$×$×$üsK   ‚C,›CœC,ŸBCÂ9C,ÃCÃC,ÃC,ÃC)	ÃCÃ
C)	Ã!C)	Ã#	C,c                ó   <€ V ^8„  d   QhRR/# ©r   r3   N© )r   r   s   "€r   r    r!   d   s   ø€ ÷ 4ñ 4 ñ 4r"   c              ƒ  óÖ  "  € V P                   ;_uu_4       GR j  x€L
  V P                  '       g)   \        P                  R4        R R R 4      GR j  x€L
  R # RV n        V P                  P                  4        V P                  P                  4       G R j  x€L
  \        P                  R4       R R R 4      GR j  x€L
  R #  L¨ Lr L/ L  + GR j  x€L 
 '       g   i     R # ; i5i)Nz.Webhook Server is already shut down. ReturningFzWebhook Server stopped)r-   r(   r9   r:   r'   ÚstopÚclose_all_connections©r.   s   &r   ÚshutdownÚWebhookServer.shutdownd   s–   é € Ø×&×&×&Ó&Ø—?—?�?Ü—‘ÐNÔOØ÷ '×&Ñ&ð $ˆDŒOØ×Ñ×"Ñ"Ô$Ø×#Ñ#×9Ñ9Ó;×;Ð;Ü�M‰MÐ2Ô3÷ '×&Õ&ñ <÷ '×&×&Ó&üsz   ‚C)›CœC)Ÿ)CÁC)ÁCÁC)Á>CÂCÂCÂ2C)Â=C
Â>C)ÃC)ÃCÃ
C)ÃC&	ÃCÃ
C&	ÃC&	Ã 	C))r'   r,   r-   r(   r   r   r   ©N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú	__slots__r/   r;   rD   Ú__static_attributes__Ú__classdictcell__©r   s   @r   r   r   4   s-   ø‡ € Ù@ð€I÷-ò -÷,5ò 5÷4ö 4r"   r   c                   óL   a € ] tR t^ot o RtRV 3R lR lltV 3R lR ltRtV tR# )	r   z!Application used in the WebserverNc          	      óR   <€ V ^8„  d   QhRS[ RRRS[P                  RS[ R,          /# )r   Úwebhook_pathÚbotr   Úupdate_queueÚsecret_tokenN)r   r*   ÚQueue)r   r   s   "€r   r    ÚWebhookAppClass.__annotate__r   s;   ø€ ÷ 9ñ 9áð9ð ð9ñ —m‘mð	9ñ
 ˜D•jñ9r"   c                ó    € R VRVRV/V n         V R2\        V P                   3.p\        P                  P                  P                  W4       R# )rS   rT   rU   z/?N)Úshared_objectsÚTelegramHandlerÚtornadoÚwebÚApplicationr/   )r.   rR   rS   rT   rU   Úhandlerss   &&&&& r   r/   ÚWebhookAppClass.__init__r   sS   € ð �3Ø˜LØ˜Lð
ˆÔð
 &˜ bÐ)¬?¸D×<OÑ<OÐPÐQˆÜ�‰×Ñ×(Ñ(¨Ö8r"   c                óL   <€ V ^8„  d   QhRS[ P                  P                  RR/# )r   Úhandlerr3   N)r[   r\   ÚRequestHandler)r   r   s   "€r   r    rW   �   s)   ø€ ÷ Xñ X¡7§;¡;×#=Ñ#=ð XÀ$ñ Xr"   c                ó   € R# )zIOverrides the default implementation since we have our own logging setup.Nr?   )r.   ra   s   &&r   Úlog_requestÚWebhookAppClass.log_request�   s   ‚ r"   )rY   rF   )	rG   rH   rI   rJ   rK   r/   rd   rM   rN   rO   s   @r   r   r   o   s   ø‡ € Ù+÷9ò 9÷Xö Xr"   r   c                   ó†   a € ] tR t^†t o RtRtRtV 3R lR ltV 3R lR ltV 3R lR lt	V 3R lR	 lt
V 3R
 lR ltRtV tR# )rZ   z:BaseHandler that processes incoming requests from Telegramc                óB   <€ V ^8„  d   QhRRRS[ P                  RS[RR/# )r   rS   r   rT   rU   r3   N)r*   rV   r   )r   r   s   "€r   r    ÚTelegramHandler.__annotate__�   s/   ø€ ÷ 	ñ 	˜eð 	±7·=±=ð 	ÑPSð 	ÐX\ñ 	r"   c                óh   € Wn         W n        W0n        V'       d   \        P	                  R4       R# R# )zFInitialize for each request - that's the interface provided by tornadozLThe webhook server has a secret token, expecting it in incoming requests nowN)rS   rT   rU   r9   r:   )r.   rS   rT   rU   s   &&&&r   Ú
initializeÚTelegramHandler.initialize�   s,   € ð ŒØ(ÔØ(ÔßÜ�M‰MØ^öñ r"   c                ó   <€ V ^8„  d   QhRR/# r>   r?   )r   r   s   "€r   r    rh   ˜   s   ø€ ÷ Mñ M Tñ Mr"   c                ó*   € V P                  RR4       R# )zSets default headersúContent-Typez!application/json; charset="utf-8"N)Ú
set_headerrC   s   &r   Úset_default_headersÚ#TelegramHandler.set_default_headers˜   s   € à�‰˜Ð(KÖLr"   c                ó   <€ V ^8„  d   QhRR/# r>   r?   )r   r   s   "€r   r    rh   œ   s   ø€ ÷ "0ñ "0˜Dñ "0r"   c              ƒ  óB  "  € \         P                  R4       V P                  4        V P                  P                  P                  4       p\        P                  ! V4      pV P                  \        P                  4       \         P                  RV4        \        P                  ! W P                  4      pT'       d�   \         P                  RTP(                  4       \+        T P                  \,        4      '       d   T P                  P/                  T4       T P0                  P3                  T4      G Rj  x€L
  R# R#   \         dN   p\         P                  RTTR7       \         P"                  P%                  \        P&                  RR7      ThRp?ii ; i Lc5i)	zHandle incoming POST requestzWebhook triggeredzWebhook received data: %szySomething went wrong processing the data received from Telegram. Received data was *not* processed! Received data was: %r©Úexc_infozUpdate could not be processed©ÚreasonNz%Received Update with ID %d on Webhook)r9   r:   Ú_validate_postÚrequestÚbodyÚdecodeÚjsonÚloadsÚ
set_statusr   ÚOKr   Úde_jsonrS   Ú	ExceptionÚcriticalr[   r\   Ú	HTTPErrorÚBAD_REQUESTÚ	update_idr)   r   Úinsert_callback_datarT   Úput)r.   Újson_stringÚdataÚupdateÚexcs   &    r   ÚpostÚTelegramHandler.postœ   s>  é € ä�‰Ð)Ô*Ø×ÑÔà—l‘l×'Ñ'×.Ñ.Ó0ˆÜ�zŠz˜+Ó&ˆØ�‰œ
Ÿ™Ô&Ü�‰Ð1°;Ô?ð	Ü—^’^ D¯(©(Ó3ˆF÷ Ü�M‰MØ7à× Ñ ôô ˜$Ÿ(™(¤F×+Ò+Ø—‘×-Ñ-¨fÔ5à×#Ñ#×'Ñ'¨Ó/×/Ò/ñ øô ô 		Ü×ÑðKàØð	 ô ô —+‘+×'Ñ'Ü×&Ñ&Ð/Nð (ó àðûð		úñ, 0ùs>   ‚BFÂ E Â8FÃ A9FÄ9FÄ:FÅFÅAFÆFÆFc                ó   <€ V ^8„  d   QhRR/# r>   r?   )r   r   s   "€r   r    rh   À   s   ø€ ÷ ñ  ñ r"   c                óf  € V P                   P                  P                  RR4      pVR8w  d.   \        P                  P                  \        P                  4      hV P                  eÉ   V P                   P                  P                  R4      pV'       gE   \        P                  R4       \        P                  P                  \        P                  RR7      hW P                  8w  dF   \        P                  RV4       \        P                  P                  \        P                  RR7      hR# R# )	z+Only accept requests with content type JSONrn   Nzapplication/jsonzX-Telegram-Bot-Api-Secret-Tokenz(Request did not include the secret tokenrv   z&Request had the wrong secret token: %sz"Request had the wrong secret token)ry   ÚheadersÚgetr[   r\   rƒ   r   Ú	FORBIDDENrU   r9   r:   )r.   Ú	ct_headerÚtokens   &  r   rx   ÚTelegramHandler._validate_postÀ   sð   € à—L‘L×(Ñ(×,Ñ,¨^¸TÓBˆ	ØÐ*Ô*Ü—+‘+×'Ñ'¬
×(<Ñ(<Ó=Ð=à×ÑÒ(Ø—L‘L×(Ñ(×,Ñ,Ð-NÓOˆEßÜ—‘ÐHÔIÜ—k‘k×+Ñ+Ü×(Ñ(Ð1[ð ,ó ð ð ×)Ñ)Ô)Ü—‘ÐFÈÔNÜ—k‘k×+Ñ+Ü×(Ñ(Ð1Uð ,ó ð ñ *ñ )r"   c                ój   <€ V ^8„  d   QhRS[ S[,          R,          RS[R,          RS[R,          RR/# )r   ÚtypNÚvalueÚtbr3   )ÚtypeÚBaseExceptionr   )r   r   s   "€r   r    rh   Ó   sG   ø€ ÷ 
ñ 
á‘-Õ  4Õ'ð
ñ ˜tÕ#ð
ñ ˜DÕ ð	
ð
 
ñ
r"   c                ó˜   € \         P                  RV P                  P                  RV'       d   V'       d   V'       d   WV3MTR7       R# )z@Override the default logging and instead use our custom logging.z%s - %szException in TelegramHandlerrt   N)r9   r:   ry   Ú	remote_ip)r.   r—   r˜   r™   s   &&&&r   Úlog_exceptionÚTelegramHandler.log_exceptionÓ   s8   € ô 	�‰ØØ�L‰L×"Ñ"Ø*ß),·¿2�c "Ñ%À5ð	 	ö 	
r"   )rS   rU   rT   N)ÚPOST)rG   rH   rI   rJ   rK   rL   ÚSUPPORTED_METHODSrj   rp   rŒ   rx   rž   rM   rN   rO   s   @r   rZ   rZ   †   sH   ø‡ € ÙDà7€Ià!Ð÷	ð 	÷Mð M÷"0ð "0÷Hð ÷&
ö 
r"   rZ   )$r*   r|   Úhttpr   Úpathlibr   r   Ússlr   Útypesr   Útypingr   Útornado.webr[   Útornado.httpserverr	   Útornado.netutilr
   r%   ÚImportErrorÚtelegramr   Útelegram._utils.loggingr   Útelegram.ext._extbotr   r   rG   r9   r   r\   r]   r   rb   rZ   r?   r"   r   Ú<module>r®      s¥   ðó( Û Ý Ý Ý Ý Ý Ý  ó Ý )ðÝ0à€Nõ Ý .Ý 'çÝñ �X¨)Ô
4€÷84ñ 84ôvX�g—k‘k×-Ñ-ô Xô.Y
�g—k‘k×0Ñ0ö Y
øðA ô Ø‚Nðús   ¸B4 Â4	C Â?C 