Ë
    S"“jd%  ã                   ó”   — d dl Z d dlZd dlZddlmZ ddlmZmZ ddlm	Z	m
Z
 ej                  rddlmZ  G d„ d	«      Z G d
„ d«      Zy)é    Né   )Ú_NOT_A_REQUESTé   )ÚhelpersÚutils)Ú	functionsÚ	TLRequest)ÚTelegramClientc                   ó´   ‡ — e Zd ZdZdZd„ Zed„ «       Zej                  d„ «       Zd„ Z	d„ Z
ej                  Zej                  Zdd„Zˆ fd	„Zd
„ Zˆ fd„Zˆ xZS )Ú_TakeoutClientz'
    Proxy object over the client.
    )Ú	__enter__Ú__exit__Ú
__aenter__Ú	__aexit__c                 ó<   — || _         || _        || _        d | _        y ©N)Ú_TakeoutClient__finalizeÚ_TakeoutClient__clientÚ_TakeoutClient__requestÚ_TakeoutClient__success)ÚselfÚfinalizeÚclientÚrequests       úX/var/www/api.ozpay.ru/ozpay/venv/lib/python3.12/site-packages/telethon/client/account.pyÚ__init__z_TakeoutClient.__init__   s    € ð #ˆŒØˆŒØ ˆŒØˆ�ó    c                 ó   — | j                   S r   ©r   )r   s    r   Úsuccessz_TakeoutClient.success   s   € à�~‰~Ðr   c                 ó   — || _         y r   r   )r   Úvalues     r   r    z_TakeoutClient.success"   s	   € àˆ�r   c              ƒ   óî   K  — | j                   }|j                  j                  €5 || j                  «      ƒ d {  –—† j                  |j                  _        | S | j                  �t        d«      ‚| S 7 Œ8­w)NzgCan't send a takeout request while another takeout for the current session still not been finished yet.)r   ÚsessionÚ
takeout_idr   ÚidÚ
ValueError)r   r   s     r   r   z_TakeoutClient.__aenter__&   sp   è ø€ à—‘ˆØ�>‰>×$Ñ$Ð,Ù/5°d·n±nÓ/E×)E×(IÑ(IˆF�N‰NÔ%ð ˆð �^‰^Ð'Üð Oó Pð Pàˆð	 *Fús   ‚8A5ºA3»9A5c              ƒ   ó  K  — | j                   €| j                  r	|d u | _         | j                   �V | t        j                  j	                  | j                   «      «      ƒ d {  –—† }|st        d«      ‚d | j                  _        y y 7 Œ$­w)NzFailed to finish the takeout.)r   r   r   ÚaccountÚFinishTakeoutSessionRequestr'   r$   r%   )r   Úexc_typeÚ	exc_valueÚ	tracebackÚresults        r   r   z_TakeoutClient.__aexit__0   sz   è ø€ Ø�>‰>Ð! d§o¢oØ%¨Ð-ˆDŒNà�>‰>Ð%Ù¤	× 1Ñ 1× MÑ MØ—‘ó! ó !÷ !ˆFáÜ Ð!@ÓAÐAØ&*ˆD�L‰LÕ#ð &ð!ús   ‚A B	Á"BÁ#%B	c              ƒ   ó¶  K  — | j                   j                  j                  }|€t        d«      ‚t	        j
                  |«       }|r|fn|}g }|D ]_  }t        |t        «      s
t        «       ‚|j                  | t        «      ƒ d {  –—†  |j                  t        j                  ||«      «       Œa | j                  |r|d   n||¬«      ƒ d {  –—† S 7 ŒM7 Œ­w)NzJTakeout mode has not been initialized (are you calling outside of "with"?)r   )Úordered)r   r$   r%   r'   r   Úis_list_likeÚ
isinstancer	   r   ÚresolveÚappendr   ÚInvokeWithTakeoutRequest)r   r   r0   r%   ÚsingleÚrequestsÚwrappedÚrs           r   Ú__call__z_TakeoutClient.__call__>   sâ   è ø€ Ø—]‘]×*Ñ*×5Ñ5ˆ
ØÐÜð 7ó 8ð 8ô ×'Ñ'¨Ó0Ð0ˆÙ"(�W‘J¨gˆØˆØò 	NˆAÜ˜a¤Ô+Ü$Ó&Ð&Ø—)‘)˜D¤%Ó(×(Ð(Ø�N‰Nœ9×=Ñ=¸jÈ!ÓLÕMð		Nð —]‘]Ù ˆG�AŠJ g°wð #ó @÷ @ð 	@ð )øð@ús%   ‚BCÂCÂACÃCÃCÃCc                 ó~   •— |j                  d«      r|t        | «      j                  vrt        ‚t        ‰| �  |«      S )NÚ__)Ú
startswithÚtypeÚ_TakeoutClient__PROXY_INTERFACEÚAttributeErrorÚsuperÚ__getattribute__)r   ÚnameÚ	__class__s     €r   rB   z_TakeoutClient.__getattribute__P   s:   ø€ ð �?‰?˜4Ô  T´°d³×1MÑ1MÑ%MÜ Ð ô ‰wÑ'¨Ó-Ð-r   c                 óÄ   — t        | j                  |«      }t        j                  |«      r4t	        j
                  t        | j                  j                  |«      | «      S |S r   )Úgetattrr   ÚinspectÚismethodÚ	functoolsÚpartialrD   )r   rC   r"   s      r   Ú__getattr__z_TakeoutClient.__getattr__]   sR   € Ü˜Ÿ™ tÓ,ˆÜ×Ñ˜EÔ"ô ×$Ñ$Ü˜Ÿ™×/Ñ/°Ó6¸ó>ð >ð ˆr   c                 óÖ   •— |j                  dj                  t        | «      j                  j	                  d«      «      «      rt
        ‰| �  ||«      S t        | j                  ||«      S )Nz_{}__Ú_)	r=   Úformatr>   Ú__name__ÚlstriprA   Ú__setattr__Úsetattrr   )r   rC   r"   rD   s      €r   rQ   z_TakeoutClient.__setattr__g   sR   ø€ Ø�?‰?˜7Ÿ>™>¬$¨t«*×*=Ñ*=×*DÑ*DÀSÓ*IÓJÔKä‘7Ñ& t¨UÓ3Ð3Ü�t—}‘} d¨EÓ2Ð2r   )F)rO   Ú
__module__Ú__qualname__Ú__doc__r?   r   Úpropertyr    Úsetterr   r   r   Ú_sync_enterr   Ú
_sync_exitr   r:   rB   rK   rQ   Ú__classcell__)rD   s   @r   r   r      s~   ø„ ñð MÐòð ñó ðð ‡^�^ñó ðòò	+ð ×#Ñ#€IØ×!Ñ!€Hó@ô$.ò÷3ð 3r   r   c                   óf   — e Zd Z	 dddddddddœdddedededed	ed
edededdfd„Zdddedefd„Zy)ÚAccountMethodsN)ÚcontactsÚusersÚchatsÚ
megagroupsÚchannelsÚfilesÚmax_file_sizer   r
   r   r]   r^   r_   r`   ra   rb   rc   Úreturnc          	      óô   — t        |||||||¬«      }	d„ |	j                  «       D «       }
| j                  j                  �t	        |
«      r t        j                  j                  di |	¤Ž}nd}t        || |«      S )a~  
        Returns a :ref:`telethon-client` which calls methods behind a takeout session.

        It does so by creating a proxy object over the current client through
        which making requests will use :tl:`InvokeWithTakeoutRequest` to wrap
        them. In other words, returns the current client modified so that
        requests are done as a takeout:

        Some of the calls made through the takeout session will have lower
        flood limits. This is useful if you want to export the data from
        conversations or mass-download media, since the rate limits will
        be lower. Only some requests will be affected, and you will need
        to adjust the `wait_time` of methods like `client.iter_messages
        <telethon.client.messages.MessageMethods.iter_messages>`.

        By default, all parameters are `None`, and you need to enable those
        you plan to use by setting them to either `True` or `False`.

        You should ``except errors.TakeoutInitDelayError as e``, since this
        exception will raise depending on the condition of the session. You
        can then access ``e.seconds`` to know how long you should wait for
        before calling the method again.

        There's also a `success` property available in the takeout proxy
        object, so from the `with` body you can set the boolean result that
        will be sent back to Telegram. But if it's left `None` as by
        default, then the action is based on the `finalize` parameter. If
        it's `True` then the takeout will be finished, and if no exception
        occurred during it, then `True` will be considered as a result.
        Otherwise, the takeout will not be finished and its ID will be
        preserved for future usage as `client.session.takeout_id
        <telethon.sessions.abstract.Session.takeout_id>`.

        Arguments
            finalize (`bool`):
                Whether the takeout session should be finalized upon
                exit or not.

            contacts (`bool`):
                Set to `True` if you plan on downloading contacts.

            users (`bool`):
                Set to `True` if you plan on downloading information
                from users and their private conversations with you.

            chats (`bool`):
                Set to `True` if you plan on downloading information
                from small group chats, such as messages and media.

            megagroups (`bool`):
                Set to `True` if you plan on downloading information
                from megagroups (channels), such as messages and media.

            channels (`bool`):
                Set to `True` if you plan on downloading information
                from broadcast channels, such as messages and media.

            files (`bool`):
                Set to `True` if you plan on downloading media and
                you don't only wish to export messages.

            max_file_size (`int`):
                The maximum file size, in bytes, that you plan
                to download for each message with media.

        Example
            .. code-block:: python

                from telethon import errors

                try:
                    async with client.takeout() as takeout:
                        await client.get_messages('me')  # normal call
                        await takeout.get_messages('me')  # wrapped through takeout (less limits)

                        async for message in takeout.iter_messages(chat, wait_time=0):
                            ...  # Do something with the message

                except errors.TakeoutInitDelayError as e:
                    print('Must wait', e.seconds, 'before takeout')
        )r]   Úmessage_usersÚmessage_chatsÚmessage_megagroupsÚmessage_channelsrb   Úfile_max_sizec              3   ó$   K  — | ]  }|d u–— Œ
 y ­wr   © )Ú.0Úargs     r   ú	<genexpr>z)AccountMethods.takeout.<locals>.<genexpr>Ô   s   è ø€ ÒL¨S˜ DœÑLùs   ‚Nrl   )	ÚdictÚvaluesr$   r%   Úanyr   r)   ÚInitTakeoutSessionRequestr   )r   r   r]   r^   r_   r`   ra   rb   rc   Úrequest_kwargsÚarg_specifiedr   s               r   ÚtakeoutzAccountMethods.takeouto   s…   € ôx ØØØØ)Ø%ØØ'ô
ˆñ M°N×4IÑ4IÓ4KÔLˆà�<‰<×"Ñ"Ð*¬c°-Ô.@Ü×'Ñ'×AÑAñ "Ø ñ"‰Gð ˆGä˜h¨¨gÓ6Ð6r   r    c              ƒ   ó¸   K  — 	 t        d| d«      4 ƒd{  –—† }||_        ddd«      ƒd{  –—†  y7 Œ7 Œ# 1 ƒd{  –—†7  sw Y   yxY w# t        $ r Y yw xY w­w)ap  
        Finishes the current takeout session.

        Arguments
            success (`bool`):
                Whether the takeout completed successfully or not.

        Returns
            `True` if the operation was successful, `False` otherwise.

        Example
            .. code-block:: python

                await client.end_takeout(success=False)
        TNF)r   r    r'   )r   r    rv   s      r   Úend_takeoutzAccountMethods.end_takeoutÞ   sl   è ø€ ð 	Ü% d¨D°$Ó7÷ *ð *¸7Ø")�”÷*÷ *ð ð	*øð *ø÷ *÷ *ð *ð ûô ò 	Ùð	üsl   ‚A„A •2–A ™6¡A ¬4­A ±A²A ´A ¶A¼?½AÁA ÁAÁA Á	AÁAÁAÁA)T)rO   rS   rT   Úboolrv   rx   rl   r   r   r\   r\   n   s°   „ ð "ðm7ð "ØØØ#Ø!ØØ"&òm7Ø"ðm7àðm7ð ð	m7ð
 ðm7ð ðm7ð ðm7ð ðm7ð ðm7ð  ðm7ð ,<óm7ð^Ð 0ð ¸4ð ÀDô r   r\   )rI   rG   Útypingr^   r   Ú r   r   Útlr   r	   ÚTYPE_CHECKINGÚtelegramclientr
   r   r\   rl   r   r   ú<module>r      s<   ðÛ Û Û å !ß ß %à	×ÒÝ.÷
\3ñ \3÷~Eò Er   