
    i                     J   S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	r	S SK
Jr  S SKJrJr  S SKJr  S SKJr  S SKJrJr  S SKJr  S SKJr  S S	KJrJrJrJrJrJr  S SK r S S
K J!r!J"r"J#r#J$r$J%r%  S SK&J'r'  S SK(J)r)J*r*J+r+J,r,J-r-J.r.J/r/J0r0J1r1J2r2J3r3J4r4  S SK5J6r6  S SK7J8r8  S SK9J:r:  S SK;J<r<J=r=  S SK>J?r?J@r@  S SKAJBrBJCrCJDrD  S SKEJFrF  SSKGJHrH  SSKIJJrJJKrK  SSKLJMrM  SSKNJOrOJPrPJQrQ  SSKRJRrR  SSKSJTrT  SSKUJVrV  \R                  " \X5      rY " S S\85      rZ " S S5      r[g)     N)ThreadPoolExecutor)datetime	timedelta)sha256)import_module)BytesIOStringIO)	MimeTypes)Path)AsyncGeneratorCallableListOptionalTypeUnion)__license____version__enumsrawutils)aes)AuthBytesInvalid
BadRequestCDNFileHashMismatchChannelPrivateFloodPremiumWait	FloodWaitPersistentTimestampInvalidPersistentTimestampOutdatedSessionPasswordNeededUnauthorizedVolumeLocNotFoundAuthTokenExpired)Handler)Methods)QRLogin)AuthSession)SQLiteStorageStorage)LinkPreviewOptionsTermsOfServiceUser)ainput   )
Connection)TCPTCPAbridged)
Dispatcher)FileIdFileTypeThumbnailSource)
mime_types)Parser)MsgIdc            T         ^  \ rS rSrSrS\ 3r\R                  " 5        S\R                  " 5        3r
\R                  " 5        S\R                  " 5        3rSrSrSr\" \R&                  S   5      R(                  r\R.                  " S5      r\R.                  " S	5      r\R.                  " S
5      r\R.                  " S5      r\" S\R<                  " 5       =(       d    SS-   5      r\r Sr!Sr"Sr#Sr$\%" 5       r&\&RO                  \(" \)5      5        SS\\
\\\\SSSSSSSSS\\ S\*RV                  RX                  SSS\-R\                  S\"\#\$S\*R^                  R`                  SSSSSS\1\2S4(S\3S\4\5\6\34      S\4\3   S\3S\3S\3S\3S\3S\3S\4\7   S\4\8   S\4\7   S \4\3   S!\4\3   S"\4\7   S#\4\3   S$\4\3   S%\4\3   S&\6S'\5\3\4   S(\4\8   S)S*S+\4\7   S,\4\7   S-\4\7   S.\6S/\4\7   S0\6S1\6S2\6S3\4\9   S4S5S6\4\:   S7\4\7   S8\4\7   S9\4\7   S:\4\7   S;\4\8   S<\;\1   S=\;\<   S>\4\=R|                     4RU 4S? jjjr?S@ r@SA rASB rBSC rCSD rDSE\E4SF jrF/ 4SG\G\6   SESH4SI jjrHS)\4S*   4SJ jrISK\G\5\JR                  R                  \JR                  R                  \JR                  R                  4      SE\74SL jrNSM rOSN rPSO rQSP rR     SmSQ\SSR\6SS\6ST\6SU\TSV\USE\V\WS4   4SW jjrX        SnSX\4\6   SY\4\7   SZ\4\7   S[\4\3   S\\4\7   S]\4\3   S^\4\6   S_\4\7   SES`4Sa jjrY    SoSX\6SY\7SZ\7S\7SESb4
Sc jjrZ   SpSX\4\6   S]\4\3   S^\4\6   4Sd jjr[\\SE\]4Se j5       r^Sf\64Sg jr_Sh\5\3\`4   SE\4\3   4Si jraSj\3SE\4\3   4Sk jrbSlrcU =rd$ )qClientJ   ao  Pyrogram Client, the main means for interacting with Telegram.

Parameters:
    name (``str``):
        A name for the client, e.g.: "my_account".

    api_id (``int`` | ``str``, *optional*):
        The *api_id* part of the Telegram API key, as integer or string.
        E.g.: 12345 or "12345".

    api_hash (``str``, *optional*):
        The *api_hash* part of the Telegram API key, as string.
        E.g.: "0123456789abcdef0123456789abcdef".

    app_version (``str``, *optional*):
        Application version.
        Defaults to "Pyrogram x.y.z".

    device_model (``str``, *optional*):
        Device model.
        Defaults to *platform.python_implementation() + " " + platform.python_version()*.

    system_version (``str``, *optional*):
        Operating System version.
        Defaults to *platform.system() + " " + platform.release()*.

    lang_pack (``str``, *optional*):
        Name of the language pack used on the client.
        Defaults to "" (empty string).

    lang_code (``str``, *optional*):
        Code of the language used on the client, in ISO 639-1 standard.
        Defaults to "en".

    system_lang_code (``str``, *optional*):
        Code of the language used on the system, in ISO 639-1 standard.
        Defaults to "en".

    ipv6 (``bool``, *optional*):
        Pass True to connect to Telegram using IPv6.
        If the session was previously used with IPv4,
        the first request will be made via IPv4,
        after which the server address will be updated (works both ways).
        Defaults to False (IPv4).

    proxy (``dict``, *optional*):
        The Proxy settings as dict.
        E.g.: *dict(scheme="socks5", hostname="11.22.33.44", port=1234, username="user", password="pass")*.
        The *username* and *password* can be omitted if the proxy doesn't require authorization.

    test_mode (``bool``, *optional*):
        Enable or disable login to the test servers.
        Only applicable for new sessions and will be ignored in case previously created sessions are loaded.
        Defaults to False.

    bot_token (``str``, *optional*):
        Pass the Bot API token to create a bot session, e.g.: "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11"
        Only applicable for new sessions.

    session_string (``str``, *optional*):
        Pass a session string to load the session in-memory.
        Implies ``in_memory=True``.

    in_memory (``bool``, *optional*):
        Pass True to start an in-memory session that will be discarded as soon as the client stops.
        In order to reconnect again using an in-memory session without having to login again, you can use
        :meth:`~pyrogram.Client.export_session_string` before stopping the client to get a session string you can
        pass to the ``session_string`` parameter.
        Defaults to False.

    phone_number (``str``, *optional*):
        Pass the phone number as string (with the Country Code prefix included) to avoid entering it manually.
        Only applicable for new sessions.

    phone_code (``str``, *optional*):
        Pass the phone code as string (for test numbers only) to avoid entering it manually.
        Only applicable for new sessions.

    password (``str``, *optional*):
        Pass the Two-Step Verification password as string (if required) to avoid entering it manually.
        Only applicable for new sessions.

    workers (``int``, *optional*):
        Number of maximum concurrent workers for handling incoming updates.
        Defaults to ``min(32, os.cpu_count() + 4)``.

    workdir (``str``, *optional*):
        Define a custom working directory.
        The working directory is the location in the filesystem where Pyrogram will store the session files.
        Defaults to the parent directory of the main script.

    plugins (``dict``, *optional*):
        Smart Plugins settings as dict, e.g.: *dict(root="plugins")*.

    parse_mode (:obj:`~pyrogram.enums.ParseMode`, *optional*):
        Set the global parse mode of the client. By default, texts are parsed using both Markdown and HTML styles.
        You can combine both syntaxes together.

    no_updates (``bool``, *optional*):
        Pass True to disable incoming updates.
        When updates are disabled the client can't receive messages or other updates.
        Useful for batch programs that don't need to deal with updates.
        Defaults to False (updates enabled and received).

    skip_updates (``bool``, *optional*):
        Pass True to skip pending updates that arrived while the client was offline.
        Doesn't work if *in_memory* is set to True.
        Defaults to True.

    takeout (``bool``, *optional*):
        Pass True to let the client use a takeout session instead of a normal one, implies *no_updates=True*.
        Useful for exporting Telegram data. Methods invoked inside a takeout session (such as get_chat_history,
        download_media, ...) are less prone to throw FloodWait exceptions.
        Only available for users, bots will ignore this parameter.
        Defaults to False (normal session).

    sleep_threshold (``int``, *optional*):
        Set a sleep threshold for flood wait exceptions happening globally in this client instance, below which any
        request that raises a flood wait will be automatically invoked again after sleeping for the required amount
        of time. Flood wait exceptions requiring higher waiting times will be raised.
        Defaults to 10 seconds.

    hide_password (``bool``, *optional*):
        Pass True to hide the password when typing it during the login.
        Defaults to False, because ``getpass`` (the library used) is known to be problematic in some
        terminal environments.

    max_concurrent_transmissions (``int``, *optional*):
        Set the maximum amount of concurrent transmissions (uploads & downloads).
        A value that is too high may result in network related issues.
        Defaults to 1.

    max_message_cache_size (``int``, *optional*):
        Set the maximum size of the message cache.
        Defaults to 1000.

    max_topic_cache_size (``int``, *optional*):
        Set the maximum size of the topic cache.
        Defaults to 1000.

    storage_engine (:obj:`~pyrogram.storage.Storage`, *optional*):
        Pass an instance of your own implementation of session storage engine.
        Useful when you want to store your session in databases like Mongo, Redis, etc.

    client_platform (:obj:`~pyrogram.enums.ClientPlatform`, *optional*):
        The platform where this client is running.
        Defaults to 'other'

    link_preview_options (:obj:`~pyrogram.types.LinkPreviewOptions`, *optional*):
        Global link preview options for the client.

    fetch_replies (``bool``, *optional*):
        Pass True to automatically fetch replies for messages.
        Defaults to True.

    fetch_topics (``bool``, *optional*):
        Pass True to automatically fetch forum topics.
        Defaults to True.

    fetch_stories (``bool``, *optional*):
        Pass True to automatically fetch stories if they are missing.
        Defaults to True.

    fetch_stickers (``bool``, *optional*):
        Pass True to automatically fetch names of sticker sets.
        Defaults to True.

    loop (:py:class:`asyncio.AbstractEventLoop`, *optional*):
        Event loop.

    init_connection_params (``dict``, *optional*):
        Additional initConnection parameters.
        For now, only the tz_offset field is supported, for specifying timezone offset in seconds.
z	Pyrogram   enr   zT^(?:https?://)?(?:www\.)?(?:t(?:elegram)?\.(?:org|me|dog)/(?:joinchat/|\+))([\w-]+)$zO^(?:https?://)?(?:www\.)?(?:t(?:elegram)?\.(?:org|me|dog)/(?:nft/|\+))([\w-]+)$z^(-\d+)_(\d+)$zQ^(?:https?://)?(?:www\.)?(?:t(?:elegram)?\.(?:org|me|dog)/(?:c/)?)([\w]+)(?:.+)?$       i  r/   i  NFTnameapi_idapi_hashapp_versiondevice_modelsystem_version	lang_pack	lang_codesystem_lang_codeipv6proxy	test_mode	bot_tokensession_string	in_memoryphone_number
phone_codepasswordworkersworkdirplugins
parse_modezenums.ParseMode
no_updatesskip_updatestakeoutsleep_thresholdhide_passwordmax_concurrent_transmissionsmax_message_cache_sizemax_topic_cache_sizestorage_engineclient_platformzenums.ClientPlatformlink_preview_optionsfetch_repliesfetch_topicsfetch_storiesfetch_stickersinit_connection_paramsconnection_factoryprotocol_factoryloopc*                   > [         T*U ]  5         Xl        U(       a  [        U5      OS U l        X0l        X@l        XPl        X`l        UR                  5       U l
        UR                  5       U l        U	R                  5       U l        Xl        Xl        Xl        Xl        Xl        Xl        UU l        UU l        UU l        UU l        [/        U5      U l        UU l        UU l        UU l        UU l        UU l        UU l        UU l        UU l         UU l!        UU l"        U U l#        U!U l$        U"U l%        U#U l&        U$U l'        U%U l(        U&U l)        U'U l*        U(U l+        [Y        U R,                  SS9U l-        U   U R"                  (       a0  []        U R                  U R0                  U R"                  SS9U l/        OvU R$                  (       a%  []        U R                  U R0                  SS9U l/        O@[a        U[b        5      (       a  UU l/        O#[]        U R                  U R0                  S9U l/        [e        U 5      U l3        [h        U l5        [l        Rl                  " 5       U l7        [l        Rp                  " 5       U l9        SU l:        [w        U 5      U l<        S U l=        0 U l>        0 U l?        0 U l@        [        R                  " 5       U lC        [        R                  " U R@                  5      U lE        [        R                  " U R@                  5      U lF        S U lG        S U lH        S U lI        S U lJ        S U lK        S U lL        S U lM        S U lN        [        U RB                  5      U lP        [        U RD                  5      U lQ        S U lR        [        R                  " 5       U lT        [        R                  " 5       U lW        [a        U)[        R                  5      (       a  U)U lY        O[        R                  " 5       U lY        S U l\        g )Nr$   )thread_name_prefixT)rU   rO   rP   )rU   rP   )rU   F)]super__init__rB   intrC   rD   rE   rF   rG   lowerrH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   r   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   ra   rb   rc   rd   re   rf   rg   rh   ri   r   executorr)   storage
isinstancer*   r3   
dispatcherr9   rnd_idtime_last_sync_time	monotonic_last_monotonic_is_server_time_syncedr8   parsersessionbusiness_connectionssessionsmedia_sessionsasyncioLocksessions_lock	Semaphoresave_file_semaphoreget_file_semaphoreis_connectedis_initialized
takeout_idstart_handlerstop_handlerconnect_handlerdisconnect_handlermeCachemessage_cachetopic_cacheupdates_watchdog_taskEventupdates_watchdog_eventr   nowlast_update_timeAbstractEventLooprj   r   get_event_loop_Client__config)+selfrB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   	__class__s+                                             </app/mltbenv/lib/python3.13/site-packages/pyrogram/client.pyrn   Client.__init__  s0   X 		%+c&k &(,"*"* 0 6 6 8	
"","($ G}$$(.*,H)&<#$8!.$8!*(*,&<#"4 0*4<<IV(		#22	DL ^^(DLLTXYDL00)DL(DLLIDL&0&6#yy{#~~/&+#$Tl*.$&! $\\^#*#4#4T5V5V#W ")"3"3D4U4U"V "! #"&"&"4#>#>? !:!:;
 &*"&-mmo# (dG5566DI,,.DI,0    c                 "    U R                  5       $ Nstartr   s    r   	__enter__Client.__enter__  s    zz|r   c                 F     U R                  5         g ! [         a     g f = fr   stopConnectionErrorr   argss     r   __exit__Client.__exit__  s"    	IIK 		s    
  c                 >   #    U R                  5       I S h  vN $  N7fr   r   r   s    r   
__aenter__Client.__aenter__  s     ZZ\!!!s   c                 b   #     U R                  5       I S h  vN   g  N! [         a     g f = f7fr   r   r   s     r   	__aexit__Client.__aexit__  s*     	))+ 		s(   /  / 
,/,/c                   #      [         R                  " U R                  R                  5       U R                  5      I S h  vN   g  N! [         R
                   a     Of = f[        R                  " 5       U R                  -
  [        U R                  S9:  aY  U R                  [        R                  R                  R                  5       5      I S h  vN    U R                  5       I S h  vN    M  7f)N)seconds)r   wait_forr   waitUPDATES_WATCHDOG_INTERVALTimeoutErrorr   r   r   r   invoker   	functionsupdatesGetStaterecover_gapsr   s    r   updates_watchdogClient.updates_watchdog  s     &&t'B'B'G'G'I4KiKijjj 	 k'' 
 ||~ 5 55	$JhJh8iikk#--"7"7"@"@"BCCC''))) sS   C5<A	 AA	 C5A	 	A C5A  A4C5CC5-C0.C5returnc                   #    U R                   (       a#  U R                  U R                   5      I S h  vN $ [        S[         S35        [        S[         S35          U R
                  (       d   [        SU R                  S9I S h  vN nU(       d  M&  [        SU S3U R                  S9I S h  vN nUR                  5       S	:X  a  OM\  S
U;   a  Xl         U R                  U5      I S h  vN $ Xl        U R                  U R
                  5      I S h  vN n UR                  [        R                  R                  :X  Ga)  [        S5           [        SU R                  S9I S h  vN nU(       d  M&  [        SU S3U R                  S9I S h  vN nUR                  5       S	:X  a  OM\  U R!                  ["        R$                  R&                  R)                  ["        R*                  R-                  U R
                  UR.                  S9US95      I S h  vN   [        SU R                  S9I S h  vN nU R!                  ["        R$                  R&                  R1                  ["        R*                  R-                  U R
                  UR.                  S9["        R*                  R3                  US9S95      I S h  vN n[5        U["        R*                  R&                  R6                  5      (       av  [5        UR8                  ["        R*                  R:                  R<                  5      (       a9  [?        SUR8                  R@                   UR8                  RB                   S35      eO[        R                  RD                  S[        R                  RF                  S[        R                  RH                  S[        R                  RJ                  S[        R                  RL                  S[        R                  RN                  S0n[        SXR                      35         U RP                  (       d!  [        SU R                  S9I S h  vN U l(         U RS                  U R
                  UR.                  U RP                  5      I S h  vN n	 [5        U	[j        5      (       a  U	$  [        S!U R                  S9I S h  vN n[        S"U R                  S9I S h  vN n U Rm                  U R
                  UR.                  UU5      I S h  vN n [5        U	[n        5      (       a>  [        S#U	Rp                  -   S#-   5        U Rs                  U	Rt                  5      I S h  vN   U$  GN9 GN GN GN GNa! [         a-  n[        UR                  5        S U l        S U l          S nAOS nAff = fGMY   GNM GN' GN GN GN! [         a  n[        UR                  5         S nAOS nAff = fGM   GN GNj! [         a'  n[        UR                  5        S U l(         S nAGOS nAf[T         Ga  n[        UR                  5         [        SRW                  U RY                  5       I S h  vN  5      5        U RZ                  (       d-  [        SU R\                  U R                  S9I S h  vN  U l-         U RZ                  (       d  [        SU R                  S9I S h  vN  nUR                  5       S	:X  a  U R_                  5       I S h  vN  n
[        SU
 35         [        S U R                  S9I S h  vN  n U Ra                  U5      I S h  vN  s S nA$ ! [         a  n[        UR                  5         S nAO+S nAf[b         a  n[d        Rg                  U5        e S nAff = fM  S U l-        O\U Ri                  U RZ                  5      I S h  vN  s S nA$ ! [         a&  n[        UR                  5        S U l-         S nAOS nAff = fGM  S nAff = fGM   GNb GNI GN! [         a  n[        UR                  5         S nAOS nAff = fGM   GN7f)$NzWelcome to Pyrogram (version )zaPyrogram is free software and comes with ABSOLUTELY NO WARRANTY. Licensed
under the terms of the z.
z!Enter phone number or bot token: rj   Is "" correct? (y/N): y:z&Setup email required for authorizationzEnter email: )rQ   phone_code_hash)purposeemailzEnter confirmation code: )code)r   verificationzYou need to pay ze or purchase premium to continue authorization process, which is currently not supported by Pyrogram.zTelegram appSMSz
phone callzphone flash callFragmentz
email codez(The confirmation code has been sent via Password hint: {}'Enter 2FA password (empty to recover): hiderj   !Confirm password recovery (y/N): #The recovery code has been sent to Enter recovery code: zEnter first name: z!Enter last name (empty to skip): 
);rN   sign_in_botprintr   r   rQ   r.   rj   rp   	send_coder   MESSAGEtyper   SentCodeTypeSETUP_EMAIL_REQUIREDr   r   r   accountSendVerifyEmailCodetypesEmailVerifyPurposeLoginSetupr   VerifyEmailEmailVerificationCoders   EmailVerifiedLogin	sent_codeauthSentCodePaymentRequiredr!   amountcurrencyAPPr   CALL
FLASH_CALLFRAGMENT_SMS
EMAIL_CODErR   sign_inr    formatget_password_hintrS   r\   send_recovery_coderecover_password	Exceptionlog	exceptioncheck_passwordr-   sign_upr,   textaccept_terms_of_serviceid)r   valueconfirmr   er   
email_codeemail_sent_codesent_code_descriptions	signed_inemail_patternrecovery_code
first_name	last_name	signed_ups                  r   	authorizeClient.authorize  s    >>))$..999-k]!<= ((3}C9 	: ((&,-PW[W`W`&a a$$(.eW<N/OVZV_V_(`"`"==?c1!  e|).%)%5%5e%<<<,1)"&..1B1B"CC	 >>U//DDD:;,&,_499&M M$$(.eW<N/OVZV_V_(`"`"==?c1!  ++--AA$'II$J$J-1->->090I0I %K % #( B    (..IPTPYPY'Z!ZJ,0KK--99$'II$J$J-1->->090I0I %K % *-)H)Hj)H)Y : - 'O "/3993D3D3W3WXX%o&?&?AgAghh"."2?3L3L3S3S2TUdUnUnUwUwTx yY !Y#   ""&&""&&""''""--/A""//""--|&" <=STbTb=c<def??(./JQUQZQZ(["[("&,,t/@/@)B[B[]a]l]l"mm	N i&&%&:KKJ$%HtyyYYI
"&,,%%--	# 	 i00$'$./..y||<<<I : !b
 #a  = D &aii $(!!%&+ D !N
 #a
 "['" " %!))$$%U x #\ n 'aii "&( !-aii -444;Q;Q;S5S5STU==.45^eiewew  C  H  H  /I  )I  )I-#}},23V]a]f]f,g&g&gG&}}#56:6M6M6O0O0O %(KM?&[ \&*:@AX_c_h_h:i4i4iM%.595J5J=5Y/Y/Y(Y+5 %9(-aii(8(8+4 %.(+a(8(-%. '+ 15)-)<)<T]])K#K#KK% -aii((,-9 !- d LY  !aii  ! $ =s  0a U++a )U: U.	(U: 1U12;U: -U4.U: 1a 2$U: U7U: 6a W *V7+(W V:BW V=W 5W 6B	W ?W B-W -C"a W5	a 4W; W8W; 0a `%a `( a %+`. `+`. Aa $a%a .U: 1U: 4U: 7U: :
V1#V,'a ,V11a 7W :W =W  W W 
W/W*%a *W//a 8W; ;
`X'!a '`59`.Y1/A `/Z20
`;(_$#[&$,_$\+_$<\?=_$]"]]"`a "
^.,^_$^.^))^.._$:`;_$__$`a $
`.`
````a (a +`. .
a8aa aa 
except_idsr-   c                   #    SSK Jn  [        X5      nUR                  5       I S h  vN   U" SS9n  [	        S[
         S[         S3SS	9  UR                  5         UR                  UR                  5        UR                  SS
9  [        R                  S5        UR                  5       I S h  vN nU(       a$  [        R                  SUR                   35        U$  g  N N3! [        R                    a2    [        R                  S5        UR                  5       I S h  vN     GO1["         a2    [        R                  S5        UR                  5       I S h  vN     GO[$         Ga  n[	        UR&                  5         [	        SR)                  U R+                  5       I S h  vN  5      5        U R,                  (       d-  [/        SU R0                  U R2                  S9I S h  vN  U l         U R,                  (       d  [/        SU R2                  S9I S h  vN  nUR5                  5       S:X  a  U R7                  5       I S h  vN  n[	        SU 35         [/        SU R2                  S9I S h  vN  n	 U R9                  U	5      I S h  vN  s S nA$ ! [:         a  n[	        UR&                  5         S nAO+S nAf[<         a  n[        R?                  U5        e S nAff = fM  S U l        O\U RA                  U R,                  5      I S h  vN  s S nA$ ! [:         a&  n[	        UR&                  5        S U l         S nAOS nAff = fGM  S nAff = fGM+  7f)Nr   )QRCoder/   )versionTz"[2J
Welcome to Pyrogram (version zc)
Pyrogram is free software and comes with ABSOLUTELY NO WARRANTY. Licensed
under the terms of the zf.
Scan the QR code below to login
Settings -> Privacy and Security -> Active Sessions -> Scan QR Code.)flush)ttyz"Waiting for QR code being scanned.zLogged in successfully as zRecreating QR code.z'Auth token expired. Recreating QR code.r   r   r   r   r   r   r   r   )!qrcoder  r&   recreater   r   r   clearadd_dataurlprint_asciir   infor   	full_namer   r   r#   r    r   r   r   rS   r.   r\   rj   rp   r   r   r   r   r   r   )
r   r
  r  qr_loginqrr  r   r   r  r  s
             r   authorize_qrClient.authorize_qrv  s    !4,!!!A>44?= A..9] ;[[  
HLL)4(=>"*--/1	HH9):M:M9NOP$$ X G 	"* 2
 '' *./'')))# *BC'')))( !-aii -444;Q;Q;S5S5STU==.45^eiewew  C  H  H  /I  )I  )I-#}},23V]a]f]f,g&g&gG&}}#56:6M6M6O0O0O %(KM?&[ \&*:@AX_c_h_h:i4i4iM%.595J5J=5Y/Y/Y(Y+5 %9(-aii(8(8+4 %.(+a(8(-%. '+ 15)-)<)<T]])K#K#KK% -aii((,-9 !-9 sH  %MC!MA;C% /C#0.C% M M#C% %<M!D$"M'M*1MEM!M$
M.9M'F*(A M(G+)
M4(LH,L	I
+L5I86L<JJJMM
K'%J?:L?K'K""K''L3M4LLLMM
M'MMMMMMc                     Xl         g)a  Set the parse mode to be used globally by the client.

When setting the parse mode with this method, all other methods having a *parse_mode* parameter will follow the
global value by default.

Parameters:
    parse_mode (:obj:`~pyrogram.enums.ParseMode`):
        By default, texts are parsed using both Markdown and HTML styles.
        You can combine both syntaxes together.

Example:
    .. code-block:: python

        from pyrogram import enums

        # Default combined mode: Markdown + HTML
        await app.send_message("me", "1. **markdown** and <i>html</i>")

        # Force Markdown-only, HTML is disabled
        app.set_parse_mode(enums.ParseMode.MARKDOWN)
        await app.send_message("me", "2. **markdown** and <i>html</i>")

        # Force HTML-only, Markdown is disabled
        app.set_parse_mode(enums.ParseMode.HTML)
        await app.send_message("me", "3. **markdown** and <i>html</i>")

        # Disable the parser completely
        app.set_parse_mode(enums.ParseMode.DISABLED)
        await app.send_message("me", "4. **markdown** and <i>html</i>")

        # Bring back the default combined mode
        app.set_parse_mode(enums.ParseMode.DEFAULT)
        await app.send_message("me", "5. **markdown** and <i>html</i>")
N)rW   )r   rW   s     r   set_parse_modeClient.set_parse_mode  s
    H %r   peersc                   #    Sn/ n/ nU GH  n[        USS5      (       a  SnM  / nS n[        U[        R                  R                  5      (       a  UR
                  nUR                  n	UR                  nUR                  (       a  SOSn
UR                  (       a+  UR                  UR                  R                  5       5        GOUR                  (       a"  UR                  S UR                   5       5        GO[        U[        R                  R                  [        R                  R                  45      (       a  UR
                  * nSn	Sn
GOm[        U[        R                  R                   5      (       a  ["        R$                  " UR
                  5      nUR                  n	UR&                  (       a  S	O'UR(                  (       a  S
OUR*                  (       a  SOSn
UR                  (       a*  UR                  UR                  R                  5       5        OUR                  (       a"  UR                  S UR                   5       5        On[        U[        R                  R,                  5      (       aB  ["        R$                  " UR
                  5      nUR                  n	UR(                  (       a  S
OSn
OGM  UR                  XX45        U(       d  GM  UR                  X45        GM     U R.                  R1                  U5      I S h  vN   U(       a#  U R.                  R3                  U5      I S h  vN   U$  N0 N7f)NFminTbotuserc              3   T   #    U  H  oR                   R                  5       v   M      g 7fr   usernamerp   .0r&  s     r   	<genexpr>%Client.fetch_peers.<locals>.<genexpr>        $^~8%6%6%<%<%>%>~   &(r   groupdirectchannelforum
supergroupc              3   T   #    U  H  oR                   R                  5       v   M      g 7fr   r%  r'  s     r   r)  r*    r+  r,  )getattrrs   r   r   r-   r   access_hashphoner"  r&  appendrp   	usernamesextendChatChatForbiddenChannelr   get_channel_id	monoforum	broadcastr0  ChannelForbiddenrr   update_peersupdate_usernames)r   r  is_minparsed_peersparsed_usernamespeerr7  rQ   peer_idr4  	peer_types              r   fetch_peersClient.fetch_peers  sO    DtUE**IL$		//''"..#zz%)XXE6	==$$T]]%8%8%:;^^$$$^t~~$^^D399>>3993J3J"KLL77(#	D#))"3"344..tww7"..(,HIhlhrhr]d  yE	==$$T]]%8%8%:;^^$$$^t~~$^^D#))"<"<==..tww7"..)-I\	y OPy ''(<=S V ll''555,,//0@AAA 	6 Bs*   KM5MM)M;M<MMc                   #    [         R                  " 5       U l        [        U[        R
                  R                  [        R
                  R                  45      (       Ga  [        U R                  UR                  5      I S h  vN U R                  UR                  5      I S h  vN 45      nUR                   Vs0 s H  o3R                  U_M     nnUR                   Vs0 s H  oUR                  U_M     nnUR                   GH  n[        [        [        USS 5      SS 5      SS 5      =(       d    [        USS 5      n[        USS 5      n	[        USS 5      n
U	(       aY  U R                  R!                  U(       a  ["        R$                  " U5      OSU	S UR&                  UR(                  45      I S h  vN   [        U[        R
                  R*                  5      (       a  [,        R/                  U5        [        U[        R
                  R0                  5      (       Ga  U(       Ga  UR2                  n[        U[        R
                  R4                  5      (       Gdo   U R7                  [        R8                  R                  R;                  U R=                  ["        R$                  " U5      5      I S h  vN [        R
                  R?                  [        R
                  RA                  UR2                  R                  UR2                  R                  S9/S9X-
  U	S	S
95      I S h  vN n[        U[        R
                  R                  RB                  5      (       dl  URE                  UR                   Vs0 s H  o3R                  U_M     sn5        URE                  UR                   Vs0 s H  oUR                  U_M     sn5        U RL                  RN                  RQ                  XtU45        GM     g [        U[        R
                  RR                  [        R
                  RT                  45      (       Ga  U R                  R!                  SURV                  S UR&                  S 45      I S h  vN   U R7                  [        R8                  R                  RY                  URV                  URZ                  -
  UR&                  SS95      I S h  vN nUR\                  (       a  U RL                  RN                  RQ                  [        R
                  R_                  UR\                  S   URV                  URZ                  S9UR                   Vs0 s H  o3R                  U_M     snUR                   Vs0 s H  oUR                  U_M     sn45        g UR`                  (       a6  U RL                  RN                  RQ                  UR`                  S   0 0 45        g g [        U[        R
                  Rb                  5      (       a3  U RL                  RN                  RQ                  URD                  0 0 45        g [        U[        R
                  Rd                  5      (       a  [,        R/                  U5        g g  GN GNs  snf s  snf  GN GN GNns  snf s  snf ! [F        [H        [J        4 a     GNf = f GNK GNs  snf s  snf 7f)NmessagerF  
channel_idpts	pts_countr   )min_idmax_id)rangesF)r/  filterrM  limitforce)rM  dateqts)rK  rM  rN  )3r   r   r   rs   r   r   UpdatesUpdatesCombinedanyrH  userschatsr   r   r3  rr   update_stater   r<  rV  seqUpdateChannelTooLongr   r  UpdateNewChannelMessagerK  MessageEmptyr   r   GetChannelDifferenceresolve_peerChannelMessagesFilterMessageRangeChannelDifferenceEmptyupdater   r   r   rt   updates_queue
put_nowaitUpdateShortMessageUpdateShortChatMessagerM  GetDifferencerN  new_messagesUpdateNewMessageother_updatesUpdateShortUpdatesTooLong)r   r   rB  ur[  cr\  rg  rL  rM  rN  rK  diffs                r   handle_updatesClient.handle_updates  s=     (g		 1 13993L3LMNN&&w}}55&&w}}55 F
 '.mm4mTT1WmE4&-mm4mTT1WmE4!//$"It$d $T 9 V\48  feT2#FK>	,,33@JE00<PQ #LL#KK   fcii&D&DEEHHV$fcii&G&GHHV$nnG%gsyy/E/EFFL)- # 5 5 J J262C2CEDXDXYcDd2e,e+.99+J+J03		0F0F39>>3D3D39>>3D3D 1G 1* 0+ ,K ,& ),*-*/ !K !"* $D" $.dCII4E4E4\4\#]#] %tzz-Jz!ddAgz-J K %tzz-Jz!ddAgz-J K--88&9OPi *j #))">">		@`@`!abb,,++KKLL   %%33g&7&77  4  D   --88II.. $ 1 1! 4#KK")"3"3 / 
 '+jj1jTT1Wj1&*jj1jTT1Wj1:  %%OO11<<d>P>PQR>SUWY[=\] &!6!677OO))44gnnb"5MN!9!9::HHW ;} 65 54( -f$$ .K-J !/0KMgh ! ! 21s   B[Z![&Z	
'[>Z[$Z:B>[8Z9B*[$AZ):Z;A3Z).Z/Z)3A[?Z
 [5Z$
B/[:[;A [[B[[
3[[C.[	[[Z)Z)
[)[>[[[[
[c                 	  #    U R                   R                  5       I S h  vN   [        U R                   R                  5       I S h  vN S L U R                   R	                  5       I S h  vN S L U R                   R                  5       I S h  vN S L U R                   R                  5       I S h  vN S L /5      nU(       Ga  U R                  (       a  U R                  (       d  [        S5      eU R                   R                  U R                  5      I S h  vN   U R                   R                  S5      I S h  vN   U R                  (       aZ  U R                   R                  U R                  (       a  SOS5      I S h  vN   U R                   R                  S5      I S h  vN   OYU R                   R                  U R                  (       a  SOS5      I S h  vN   U R                   R                  S5      I S h  vN   U R                   R                  S	5      I S h  vN   U R                   R                  U R                  5      I S h  vN   U R                   R	                  [        U U R                   R                  5       I S h  vN U R                   R                  5       I S h  vN U R                   R                  5       I S h  vN U R                   R                  5       I S h  vN 5      R!                  5       I S h  vN 5      I S h  vN   U R                   R                  S 5      I S h  vN   U R                   R                  S 5      I S h  vN   g U R                   R                  5       I S h  vN (       d  U R                  (       a.  U R                   R                  U R                  5      I S h  vN   g   [#        [%        S
U R&                  S9I S h  vN 5      nUS	::  a  [)        S5        M:  [%        SU S3U R&                  S9I S h  vN nUR+                  5       S:X  a$  U R                   R                  U5      I S h  vN   g  M  g  GN> GN GN GN GN GNT GN4 GN GN GN GN| GN\ GN2 GN GN GN GN GN GN~ GN^ GN> GN N N N NQ! [,         a  n[)        U5         S nANgS nAff = f7f)Nz_The API key is required for new authorizations. More info: https://docs.pyrogram.org/start/auth   z2001:67c:4e8:f002::ez149.154.167.40P   z2001:67c:4e8:f002::az149.154.167.51i  r   z&Enter the api_id part of the API key: r   zInvalid valuer   r   r   )rr   openrZ  rM   auth_keyuser_idis_botrC   rD   AttributeErrordc_idserver_addressrK   portrV  r'   createro   r.   rj   r   rp   r   )r   session_emptyr   r   r   s        r   load_sessionClient.load_session  s    ll!!!,,((**d2,,''))T1,,&&((D0,,%%''4/	
  ;;dmm$ &W X X ,,%%dkk222,,$$Q'''~~ll11DII2H[klllll''+++ll11DII2H[klllll'',,,,,##A&&&,,((888,,'',,,,..,,5577,,++--,,0022 &(   ,,&&t,,,,,%%d+++ ,,...;;,,--dkk:::%$'f5]dhdmdm.n(n$oE$z %o 6 (,2T%@R3SZ^ZcZc,d&dG&}}#5&*ll&9&9%&@ @ @ %  6 	 /S 	" +)(' 3' m+l,&8 /7-2 -+ /: )o 'e !A( %!!HH%s
  S
Q&S
Q!"S
*Q$
+"S
Q'"S
0Q*1A(S
Q-"S
<Q0=AS
Q3"S
&Q6'6S
Q9"S
 Q<"S
#Q?$,S
R<S
R S
.R/ S
R S
0R1S

RS
R"S
9R:"S
R"S
?R AS
R S

R( &R"'R(  S
R( R$6R( R&R( S
!S
$S
'S
*S
-S
0S
3S
6S
9S
<S
?S
S
S
S
S
S
S
S
S
S
S
 S
"R( $R( &R( (
S2S=S
SS
c                    U R                   (       a  U R                   R                  5       nS Hk  nUR                  U/ 5      (       d  M  U R                   U    Vs/ s H2  nUR                  5       S   UR                  5       SS  =(       d    S 4PM4     snX'   Mm     Og UR                  SS5      (       Ga%  US   nUR                  S/ 5      nUR                  S/ 5      nSnU(       GdC  [	        [        UR                  S	S
5      5      R                  S5      5       GH	  nS	R                  UR                  R                  UR                  4-   5      n	[        U	5      n
[        U
5      R                  5        H  n [        X5      R                    H  u  p[#        U[$        5      (       d  M  [#        U[&        5      (       d  M3  U R)                  X5        [*        R-                  SR/                  U R0                  [3        U5      R4                  XU	5      5        US-  nM     M     GM     GO#U GH  u  pUS	-   U-   n	Sn [        U	5      n
S[=        U
5      ;   a#  [*        R;                  SU R0                  U	5        MN  Uc  [        U
5      R                  5       nSnU H  n [        X5      R                    H  u  p[#        U[$        5      (       d  M  [#        U[&        5      (       d  M3  U R)                  X5        [*        R-                  SR/                  U R0                  [3        U5      R4                  XU	5      5        US-  nM     M     GM     U(       Ga#  U GH  u  pUS	-   U-   n	Sn [        U	5      n
S[=        U
5      ;   a#  [*        R;                  SU R0                  U	5        MN  Uc  [        U
5      R                  5       nSnU H  n [        X5      R                    H  u  p[#        U[$        5      (       d  M  [#        U[&        5      (       d  M3  U R?                  X5        [*        R-                  SR/                  U R0                  [3        U5      R4                  XU	5      5        US-  nM     M     GM     US:  a9  [*        R-                  SR/                  U R0                  XwS:  a  SOSU5      5        g [*        R;                  SU R0                  U5        g g s  snf ! [6         a     GMx  f = f! [8         a&    [*        R;                  SU R0                  U	5         GM  f = f! [6         a?    U(       a3  [*        R;                  SR/                  U R0                  X5      5         GM   GM  f = f! [8         a&    [*        R;                  SU R0                  U	5         GMH  f = f! [6         a?    U(       a3  [*        R;                  SR/                  U R0                  X5      5         GM"   GM&  f = f)N)includeexcluder   r/   enabledTrootr  r  ./z*.pyz*[{}] [LOAD] {}("{}") in group {} from "{}"z-[%s] [LOAD] Ignoring non-existent module "%s"__path__z#[%s] [LOAD] Ignoring namespace "%s"Fz9[{}] [LOAD] Ignoring non-existent function "{}" from "{}"z/[%s] [UNLOAD] Ignoring non-existent module "%s"z%[%s] [UNLOAD] Ignoring namespace "%s"z,[{}] [UNLOAD] {}("{}") from group {} in "{}"z;[{}] [UNLOAD] Ignoring non-existent function "{}" from "{}"z.[{}] Successfully loaded {} plugin{} from "{}"sr>   z[%s] No plugin loaded from "%s") rV   copygetsplitsortedr   replacerglobjoinparentpartsstemr   varskeysr3  handlersrs   r$   ro   add_handlerr   r  r   rB   r   __name__r   ImportErrorwarningdirremove_handler)r   rV   optionir  r  r  countpathmodule_pathmodulerB   handlerr-  r  warn_non_existent_functionss                   r   load_pluginsClient.load_plugins  s   <<ll'')G0;;vr** "&f!5'!5A 1qwwy}'<=!5'GO 1 ;;y$''6?Dkk)R0Gkk)R0GE"4S#(>#?#E#Ef#MND"%((4;;+<+<		|+K"LK*;7F $V 1 1 3
!29&2G2P2P#-gw#?#?JuVYDZDZ$($4$4W$D$'HH-Y-`-`(,		4=3I3I4Xc.e %f %*QJE 3Q !4	 O$ '.ND"&*t"3K26/!!.{!;
 "S[0$I499Vab '#'<#4#4#66;3 (C29&2G2P2P#-gw#?#?JuVYDZDZ$($4$4W$D$'HH-Y-`-`(,		4=3I3I4Xc.e %f %*QJE 3Q !)% '.D &-ND"&*t"3K26/!!.{!;
 "S[0$KTYYXcd '#'<#4#4#66;3 (C29&2G2P2P#-gw#?#?JuVYDZDZ$($7$7$G$'HH-[-b-b(,		4=3I3I4Xc.e %f %*QJE 3Q !)% '.D qyIPPIIuQYcBF G =tyy$OG ('<  ) ! ! ' !$SUYU^U^`kl !.  ) C: #,g,n,n$(IIt-B !C !C  ;C ' !$UW[W`W`bmn !.  ) C: #,i,p,p$(IIt-B !C !C  ;Cs   9S<-S"-S"AS" S4!-T'T')AT'+U3-V&=V&AV&"
S10S14+T$#T$'A U0/U03+V#"V#&A W/.W/c           
      V  #    Uu  p#pEpgnU(       d  [         R                  " USS9OS   [         R                  R                  [        R
                  " SS[         R                  R                  X45      5      5      S-   n	U(       a
  [        5       O[        U	S5      n
 U R                  X&SSXx5        S h  vN nU
R                  U5        M   N
 U(       a  XJl        U
$ U
R                  5         [         R                  R                  U	5      S   n[        R                  " X5        U$ ! [          au  nU(       d&  U
R                  5         [         R"                  " U	5        [%        U[&        R(                  5      (       a  Ue[%        U[*        [,        45      (       a  Ue S nAg S nAff = f7f)NT)exist_okz\\r  z.tempwbr   )osmakedirsr  abspathresubr  r   rz  get_filewriterB   closesplitextshutilmoveBaseExceptionremovers   r   CancelledErrorr   r   )r   packetfile_id	directory	file_namerP   	file_sizeprogressprogress_argstemp_file_pathfilechunk	file_pathr   s                 r   handle_downloadClient.handle_download2  s;    W]TI)}5>I-DRWW\\)=_)`adkk%wy4+E	!#}}WAx_ "e

5!"_ %	

GG,,^<Q?	N6  )  	

		.)!W3344!i)9:;;	sV   BF)D' /C3C4C7D' CD' AF)'
F&1A+F!F)!F&&F)r  r  rS  offsetr  r  c                  ^^#    U R                    IS h  vN   UR                  nU[        R                  :X  Ga  UR                  S:  a3  [
        R                  R                  UR                  UR                  S9nOUR                  S:X  a)  [
        R                  R                  UR                  * S9nOF[
        R                  R                  [        R                  " UR                  5      UR                  S9n[
        R                  R                  UUR                  UR                  [         R"                  :H  S9n	OU[        R$                  :X  aI  [
        R                  R'                  UR                  UR(                  UR*                  UR,                  S9n	OH[
        R                  R/                  UR                  UR(                  UR*                  UR,                  S9n	Sn
[1        U5      =(       d    SnSn[1        U5      U-  nUR2                  n U R5                  US	S
9I S h  vN nUR7                  [
        R8                  R:                  R=                  U	UUS9SS9I S h  vN n[?        U[
        R                  R:                  R@                  5      (       a   URB                  nU7v   U
S-  n
X-  nU(       a  [D        RF                  " UUS:w  a  [I        X5      OUU/UQ76 n[J        RL                  " U5      (       a  U" 5       I S h  vN   O.U RN                  RQ                  U RR                  U5      I S h  vN   [U        U5      U:  d  X:  a  GO,UR7                  [
        R8                  R:                  R=                  U	UUS9SS9I S h  vN nM  [?        U[
        R                  R:                  RV                  5      (       Ga  U R5                  US	S	S9I S h  vN n  UR7                  [
        R8                  R:                  RY                  URZ                  UUS95      I S h  vN n[?        U[
        R                  R:                  R\                  5      (       aV   UR7                  [
        R8                  R:                  R_                  URZ                  UR`                  S95      I S h  vN   M  URB                  nU RN                  RQ                  U RR                  [d        Rf                  UURh                  [k        URl                  S S US-  Ro                  SS5      -   5      5      I S h  vN mUR7                  [
        R8                  R:                  Rq                  URZ                  US95      I S h  vN mUU4S jnU RN                  RQ                  U RR                  U5      I S h  vN   T7v   U
S-  n
X-  nU(       a  [D        RF                  " UUS:w  a  [I        X5      OUU/UQ76 n[J        RL                  " U5      (       a  U" 5       I S h  vN   O.U RN                  RQ                  U RR                  U5      I S h  vN   [U        U5      U:  d  X:  a  OGM  URu                  5       I S h  vN   O S S S 5      IS h  vN   g  GN GNr GN6 GN GNd GN GN GN} GN! [b         a     MS  f = f GN GND GN N N~! [r         a  nUeS nAff = f Nd! URu                  5       I S h  vN    f = f! [v        Rx                   a    e [z        [|        4 a    e [r         a  n[~        R                  U5         S nANS nAff = f N! , IS h  vN  (       d  f       g = f7f)Nr   )r|  r4  )chat_id)rL  r4  )rE  photo_idbig)r   r4  file_reference
thumb_sizeii   Tis_media)locationr  rS     )r[   r/   )is_cdn	temporary)
file_tokenr  rS  )r  request_token   rA   r  )r  r  c                     > [        T5       Hb  u  pTUR                  U -  UR                  U S-   -   n[        R                  " UR                  [        U5      R                  5       :H  S5        Md     g )Nr/   z$h.hash == sha256(cdn_chunk).digest())	enumeraterS  r   checkhashr   digest)r  h	cdn_chunkdecrypted_chunkhashess      r   _check_all_hashes*Client.get_file.<locals>._check_all_hashes  sc    ,5f,=DA0?!QWWXY\]X]M^0_I$7$=$=()&2C2J2J2L(L(N%& ->r   )Ar   	file_typer5   
CHAT_PHOTOr  r   r   InputPeerUserchat_access_hashInputPeerChatInputPeerChannelr   r<  InputPeerPhotoFileLocationmedia_idthumbnail_sourcer6   CHAT_PHOTO_BIGPHOTOInputPhotoFileLocationr4  r  thumbnail_sizeInputDocumentFileLocationabsr  get_sessionr   r   uploadGetFilers   Filebytes	functoolspartialr!  inspectiscoroutinefunctionrj   run_in_executorrq   lenFileCdnRedirect
GetCdnFiler  CdnFileReuploadNeededReuploadCdnFiler  r"   r   ctr256_decryptencryption_key	bytearrayencryption_ivto_bytesGetCdnFileHashesr   r   pyrogramStopTransmissionr   r   r   r   )r   r  r  rS  r  r  r  r  rE  r  currenttotal
chunk_sizeoffset_bytesr  r|   rr  funccdn_sessionr2r  r   r  r  s                          @@r   r  Client.get_fileR  s     ***))IH///??Q&9922 '$+$<$< 3 D
 //14"yy66%,__$4  7    #yy99',';';GOO'L(/(@(@  :  
 99??$--00O4R4RR @ 
 hnn,99;;'' ' 3 3#*#9#9&55	 <  99>>'' ' 3 3#*#9#9&55	 ?  GJ/-E$Jv;3LMMEE! $ 0 0 0 FF!..MM((00!)+( 1 
 %' )   a!1!1!6!677 !#1$2##,#4#4 (#,> !$L <%1 )$ "/$D  '::8DD&*f&*ii&?&?t&T T Tu:
2g6F!")..MM0088)1'3&0 9 
 -/ #1 # 5 F  399#3#3#C#CDD(,(8(8tW[(8(\"\KK1"'2'9'9 # 4 4 ? ?/0||+7*4 !@ !"( "B  *"cii.>.>.T.TUU
!-*1..(+(<(<(L(L78||:<:J:J )M )*+& %& %& %-$&HHE 59II4M4M $ # 2 2 % ! 0 0 )!//#2*>,RTBTA^A^_`bgAh*h i5 /O ,3>> # 4 4 E E/0||+7 !F !", &F& #'))";";DMMK\"]]]"11#qLG(6L''0'8'8$,DMQRNC$@Xd$-(" &3	(" $+#>#>x#H#H*.&LL*.))*C*CDMMSW*X$X$X"5zJ6':J %M #T *..000_ E +**` G: !- T
 #]"%& (9 !*$)!*/&  ^  %1$X %    1k..000,, /0  !a  !g +***s  ]5Z]5H ]\	-Z.>\	,Z"-B(\	Z%.\	Z(\	]:\	Z+A\	(Z.)\	.A[4Z157[-AZ7;Z4<Z7 A>[>[?A[[4[<[=A([%[&.[[[-[+.[1\	[)\		]]5]]5\	"\	%\	(\	+\	.\	1[4Z77
[[[+[[[[[[
[&[!![&&[+)\	+\?\
 \\		.]7]]]]]5]2!]$"]2.]5r  r  r  business_connection_idexport_authorizationr  r  r  r(   c	           
      @  #    U(       d"  U R                   R                  5       I Sh  vN nU(       a  U R                  R                  U5      nUcy  U R                  R                  [        R                  R                  R                  US95      I Sh  vN n	U	R                  S   R                  R                  =oR                  U'   U R                   R                  5       I Sh  vN U:H  n
U(       d  U
(       a  U(       d  U R                  $ U(       a  U R                  OU R                  nU(       d  UR                  U5      (       a  X   $ U(       a  U(       dM  U R                  XU R                  US9I Sh  vN nU=(       d    UR                   nU=(       d    UR"                  nU(       a$  U R%                  U5      I Sh  vN R&                  nOoU
(       dF  [)        U UUUU R                   R+                  5       I Sh  vN 5      R-                  5       I Sh  vN nO"U R                   R'                  5       I Sh  vN n[/        U UUUUU R                   R+                  5       I Sh  vN US9nU(       d  XU'   UR1                  5       I Sh  vN   U
(       d  U(       a  [3        S5       H  nU R                  [        R                  R4                  R7                  US95      I Sh  vN n UR                  [        R                  R4                  R9                  UR:                  UR<                  S95      I Sh  vN     U$    URA                  5       I Sh  vN   [>        eU$  GNC GN GN GN GN GNv GN_ GN? GN N N NH! [>         a     M  f = f N>7f)	a  Get existing session or create a new one.

Parameters:
    dc_id (``int``, *optional*):
        Datacenter identifier.

    is_media (``bool``, *optional*):
        Pass True to get or create a media session.

    is_cdn (``bool``, *optional*):
        Pass True to get or create a cdn session.

    business_connection_id (``str``, *optional*):
        Business connection identifier.

    export_authorization (``bool``, *optional*):
        Pass True to export authorization after creating the session.
        Used only when creating a new session.

    server_address (``str``, *optional*):
        Custom server address to connect to.
        Used only when creating a new session.

    port (``int``, *optional*):
        Custom port to connect to.
        Used only when creating a new session.

    temporary (``bool``, *optional*):
        Create temporary session instead of getting from storage.
        Used only when uploading/downloading and don't forget to stop it.
N)connection_idr   )r  rK   r  r     )r  )r   r  )!rr   r  r}   r  r|   r   r   r   r   GetBotBusinessConnectionr   
connectionr   r~   get_dc_optionrK   
ip_addressr  r  r{  r'   rM   r  r(   r   ranger   ExportAuthorizationImportAuthorizationr   r  r   r   )r   r  r  r  r  r  r  r  r  r  is_current_dcr~   	dc_optionr{  r|   _exported_auths                    r   r  Client.get_session  s    T ,,,,..E!--112HIE}#'<<#6#6MM))BB&< C $ 
 MWL^L^_`LaLlLlLrLrr112HI"ll0022e;]8<<*24&&X\\%00?"T"00PTPYPYbh0iiI+Cy/C/CN)9>>D"..u55??H !%",,0022" &( "&!6!6!88,,((**
 %UOmmo!51X&*kkMM&&::# ; ' !
!..**>>,//"/"5"5 ?    
 - & lln$$&&e / 3 j 6 3 9 + 	! ( 
 %s  %NM*A,NM-AN'M0(BN<M3=A	NM6<NM9NM<"N M?+N,N-%NNAN,N-N2AN N	NNNN-N0N3N6N9N<N?NNNN	N
NNNNzraw.types.DcOptionc                 ^  #    U R                  [        R                  R                  R	                  5       5      I S h  vN U l        Uc  U R
                  R                  nU R
                  R                   Vs/ s H(  oUR                  U:X  d  M  UR                  U:X  d  M&  UPM*     nnU(       d  [        SU S35      eU(       aH  U Vs/ s H  oUR                  (       d  M  UPM     nnU(       a  US   $ [        R                  SU5        SnU(       aF  U Vs/ s H  oUR                  (       d  M  UPM     nnU(       a  US   $ [        R                  SU5        U Vs/ s H  oUR                  (       a  M  UPM     n	nU	(       a  U	S   $ [        S5      e GNYs  snf s  snf s  snf s  snf 7f)NDCz
 not foundr   z:No CDN datacenter found for DC%s, falling back to media DCTz;No media datacenter found for DC%s, falling back to prod DCzNo suitable DC found)r   r   r   help	GetConfigr   this_dc
dc_optionsr   rK   
ValueErrorcdnr   debug
media_only)
r   r  r  r  rK   dcoptionscdn_optionsmedia_optionsprod_optionss
             r   r  Client.get_dc_option  sZ     #kk#--*<*<*F*F*HII=MM))E $ 8 8_ 8"EEUN2rwwZ^2 8_r%
344(/:"662K:"1~%IIL
 H*1C'B]]R'MC$Q''IIM
 &-BWrMMWB?"/00O J
 ` ; D Csc   ;F-F:F-8FF!F'#F-
F"F(1F-F#1F#7(F-F(7F(=F-F-c                   #    U R                   (       dD  U R                  [        R                  R                  R                  5       5      I Sh  vN U l         U=(       d    U R                   R                  nU R                  XR                  S9I Sh  vN nU=(       d    UR                  nU=(       d    UR                  nU R                  R                  U5      I Sh  vN   U R                  R                  U5      I Sh  vN   U R                  R                  U5      I Sh  vN   U R                  R                  U:w  d  U R                  R                  U:w  aZ  X R                  l        X0R                  l
        U R                  R                  5       I Sh  vN   [         R#                  SXU5        g[         R#                  SXU5        g GN GNA N N N N@7f)ay  Set configuration for the specified datacenter.

.. note::

    Be careful with this method, you can easily break your session.

Parameters:
    dc_id (``int``, *optional*):
        Datacenter identifier.
        Defaults to the current datacenter.

    server_address (``str``, *optional*):
        Custom server address.

    port (``int``, *optional*):
        Custom port.
N)rK   z%Changed session DC%s address to %s:%sz%Session DC%s address is already %s:%s)r   r   r   r   r(  r)  r*  r  rK   r  r  rr   r  r  r|   restartr   r  )r   r  r  r  r"  s        r   set_dcClient.set_dc  sV    . }}"&++cmm.@.@.J.J.L"MMDM...,,U,CC	'?9+?+?%y~~ll  '''ll)).999ll%%%<<&&.8DLL<M<MQU<U*8LL' $LL,,&&(((HH<eUYZHH<eUYZ' N D
 	(9% )so   AGGAGGAG G!"GG"G&G'A5GG5GGGGGGc                 `    U R                   [        R                  " 5       U R                  -
  -   $ r   )rw   rv   rx   ry   r   s    r   server_timeClient.server_time  s%    ##t~~'7$:N:N'NOOr   msg_idc                     U R                   (       a  g U[        S5      -  U l        [        R                  " 5       U l        SU l         [        R                  S[        R                  " U R                  5       35        g )Nl        TzTime synced: )
rz   floatrw   rv   rx   ry   r   r  r   timestamp_to_datetime)r   r=  s     r   _set_server_timeClient._set_server_time  s[    &&%e4#~~/&*#=!<!<T=Q=Q!R STUr   filenamec                     [        U[        5      (       a(  U R                  R                  UR                  5      S   $ U R                  R                  U5      S   $ )Nr   )rs   r   	mimetypes
guess_typerB   )r   rC  s     r   guess_mime_typeClient.guess_mime_type  sG    h((>>,,X]];A>>~~((2155r   	mime_typec                 8    U R                   R                  U5      $ r   )rE  guess_extension)r   rI  s     r   rK  Client.guess_extension   s    ~~--i88r   )E__configrz   ry   rw   rD   rC   rE   rN   r}   ra   r   rh   rF   r   rt   rq   rc   rf   re   rd   r   r\   rP   rg   rK   r   r   rI   rH   r   rb   rj   r]   r^   r_   r   r   r   rB   rX   rW   r{   rS   rR   rQ   rV   ri   rL   ru   r   r|   rO   r~   r   rY   r[   r   r   rr   rJ   rG   rZ   r   rM   r   r   r   rU   rT   )r   r   r   N )NFFNTNNF)NFFF)NNN)er  
__module____qualname____firstlineno____doc__r   APP_VERSIONplatformpython_implementationpython_versionDEVICE_MODELsystemreleaseSYSTEM_VERSION	LANG_PACK	LANG_CODESYSTEM_LANG_CODEr   sysargvr  
PARENT_DIRr  compileINVITE_LINK_REUPGRADED_GIFT_RESAVED_GIFT_RECHANNEL_MESSAGE_LINK_REr!  r  	cpu_countWORKERSWORKDIRr   MAX_CONCURRENT_TRANSMISSIONSMAX_MESSAGE_CACHE_SIZEMAX_TOPIC_CACHE_SIZEr
   rE  readfpr	   r7   r   	ParseModeDEFAULTr(   SLEEP_THRESHOLDClientPlatformOTHERr0   r2   strr   r   ro   booldictr*   r+   r   r1   r   r   rn   r   r   r   r   r   r-   r  r   r  r  r   r   r9  r;  rH  ru  r  r  r  r4   r   tupler   r  r  r  r  r8  propertyr?  r;  rA  r   rG  rK  __static_attributes____classcell__)r   s   @r   r;   r;   J   s   m^ k]+K4467q9P9P9R8STL )*!H,<,<,>+?@NIIchhqk"))JZZ wxNzz"tuJJ01M jj)}~"r||~*a/0GG !(#$ !IXj)*
 -1"&&(,"" 0$ $$)#'(,$(&*$("&$+"&(-(?(?%)'+"&&66(-,H&<$8,0272F2F2L2L=A(,'+(,)-15/9&148UX1X1 sCx)X1 3-	X1
 X1 X1 X1 X1 X1 X1 tnX1 ~X1 D>X1 C=X1 !X1  D>!X1" sm#X1$ SM%X1& 3-'X1( )X1* sDy!+X1, $-X1. &/X10 TN1X12 tn3X14 $5X16 7X18  ~9X1: '*;X1< !$=X1> "?X1@ !)AX1B 0CX1D ''9:EX1F  ~GX1H tnIX1J  ~KX1L !MX1N !)OX1P !,QX1R s)SX1T w001UX1 X1t"*f fP :< GT#Y G GR$%2C)D $%L5tE#))..#))..RUR[R[RcRc2c,d'e 5jn 5ndL<%|pPd!F !!}!}! }! 	}!
 }! }! }! 
t	$}!B  $#(!&04/3(,"$)}}} 4.} 	}
 !)} 'tn} !} sm} D>} 
}B .1.1 .1 	.1
 .1 
.1d  $(,"	+[}+[ !+[ sm	+[Z PU P PVs V6c7l(; 6 69 9# 9 9r   r;   c                   .    \ rS rSrS\4S jrS rS rSrg)r   i  capacityc                     Xl         0 U l        g r   rz  store)r   rz  s     r   rn   Cache.__init__  s     
r   c                 :    U R                   R                  US 5      $ r   )r}  r  )r   keys     r   __getitem__Cache.__getitem__	  s    zz~~c4((r   c                 6   XR                   ;   a  U R                   U	 X R                   U'   [        U R                   5      U R                  :  aL  [        U R                  S-  S-   5       H,  nU R                   [	        [        U R                   5      5      	 M.     g g )Nrx  r/   )r}  r  rz  r  nextiter)r   r  r   r#  s       r   __setitem__Cache.__setitem__  sr    **

3

3tzz?T]]*4==A-12JJtD$456 3 +r   r|  N)	r  rO  rP  rQ  ro   rn   r  r  rw  rN  r   r   r   r     s     )7r   r   )\r   r  r  loggingr  rT  r  r  r^  rv   concurrent.futures.threadr   r   r   hashlibr   	importlibr   ior   r	   rE  r
   pathlibr   typingr   r   r   r   r   r   r
  r   r   r   r   r   pyrogram.cryptor   pyrogram.errorsr   r   r   r   r   r   r   r   r    r!   r"   r#   pyrogram.handlers.handlerr$   pyrogram.methodsr%   pyrogram.qrloginr&   pyrogram.sessionr'   r(   pyrogram.storager)   r*   pyrogram.typesr+   r,   r-   pyrogram.utilsr.   r  r0   connection.transportr1   r2   rt   r3   r  r4   r5   r6   r7   r{   r8   session.internalsr9   	getLoggerr  r   r;   r   rN  r   r   <module>r     s   &     	  	  
  8 (  #     H H  @ @     . $ $ * 3 C C ! " 2 " 6 6 "  $!w9W w9t-7 7r   