Ë
    S"“jZ2  ã                   ó˜   — d dl Z d dlZd dlZddlmZmZmZ ddlmZ ddl	m
Z
 ddlmZ dZd	Zi Zd
Z G d„ d«      Ze G d„ de«      «       Zy)é    Né   )ÚEventBuilderÚEventCommonÚname_inner_eventé   )Úutils)Útypes)ÚSenderGetteréd   é   g      à?c                   ó"   — e Zd ZdZd„ Zd„ Zd„ Zy)Ú	AlbumHackaö  
    When receiving an album from a different data-center, they will come in
    separate `Updates`, so we need to temporarily remember them for a while
    and only after produce the event.

    Of course events are not designed for this kind of wizardy, so this is
    a dirty hack that gets the job done.

    When cleaning up the code base we may want to figure out a better way
    to do this, or just leave the album problem to the users; the update
    handling code is bad enough as it is.
    c                 óä   — t        j                  |«      | _        || _        |j                  j                  «       t        z   | _        |j                  j                  | j                  «       «       y ©N)
ÚweakrefÚrefÚ_clientÚ_eventÚloopÚtimeÚ_HACK_DELAYÚ_dueÚcreate_taskÚdeliver_event)ÚselfÚclientÚevents      úV/var/www/api.ozpay.ru/ozpay/venv/lib/python3.12/site-packages/telethon/events/album.pyÚ__init__zAlbumHack.__init__#   sO   € ô —{‘{ 6Ó*ˆŒØˆŒØ—K‘K×$Ñ$Ó&¬Ñ4ˆŒ	à�‰×Ñ × 2Ñ 2Ó 4Õ5ó    c                 óÀ   — | j                  «       }|rL| j                  j                  j                  |«       |j                  j                  «       t        z   | _        y y r   )r   r   ÚmessagesÚextendr   r   r   r   )r   r"   r   s      r   r#   zAlbumHack.extend,   sF   € Ø—‘“ˆÙØ�K‰K× Ñ ×'Ñ'¨Ô1ØŸ™×(Ñ(Ó*¬[Ñ8ˆD�Ið r    c              ƒ   ó  K  — 	 | j                  «       }|€y | j                  |j                  j                  «       z
  }|dk  r$|j	                  | j
                  «      ƒ d {  –—†  y ~t        j                  |«      ƒ d {  –—†  Œ‚7 Œ$7 Œ­w)Nr   )r   r   r   r   Ú_dispatch_eventr   ÚasyncioÚsleep)r   r   Údiffs      r   r   zAlbumHack.deliver_event2   s€   è ø€ ØØ—\‘\“^ˆFØˆ~Øà—9‘9˜vŸ{™{×/Ñ/Ó1Ñ1ˆDØ�qŠyð ×,Ñ,¨T¯[©[Ó9×9Ð9ØàÜ—-‘- Ó%×%Ð%ð ð :øð &ús$   ‚AB
Á!BÁ"B
Â BÂB
ÂB
N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r#   r   © r    r   r   r      s   „ ñò6ò9ó&r    r   c                   ób   ‡ — e Zd ZdZ	 d
dddœˆ fd„Zedd„«       Zˆ fd„Z G d„ d	ee	«      Z
ˆ xZS )ÚAlbumaç  
    Occurs whenever you receive an album. This event only exists
    to ease dealing with an unknown amount of messages that belong
    to the same album.

    Example
        .. code-block:: python

            from telethon import events

            @client.on(events.Album)
            async def handler(event):
                # Counting how many photos or videos the album has
                print('Got an album with', len(event), 'items')

                # Forwarding the album as a whole to some chat
                event.forward_to(chat)

                # Printing the caption
                print(event.text)

                # Replying to the fifth item in the album
                await event.messages[4].reply('Cool!')
    NF©Úblacklist_chatsÚfuncc                ó*   •— t         ‰| �  |||¬«       y )Nr0   )Úsuperr   )r   Úchatsr1   r2   Ú	__class__s       €r   r   zAlbum.__init__^   s   ø€ ä‰Ñ˜°ÀdÐÕKr    c           
      ób  — |g}t        |t        j                  t        j                  f«      �rvt        |j                  t        j
                  «      sy |j                  j                  }|€y t        j                  t        |«      d «      ry t        j                  «       }t        t        «      t        kD  r@t        j                  «       D ��cg c]  \  }}||z
  t        kD  sŒ|‘Œ c}}D ]	  }t        |= Œ |D ]  }||usŒ|t        t        |«      <   Œ | j                  |D �cg c]u  }t        |t        j                  t        j                  f«      rIt        |j                  t        j
                  «      r%|j                  j                  |k(  r|j                  ‘Œw c}«      S y c c}}w c c}w r   )Ú
isinstancer	   ÚUpdateNewMessageÚUpdateNewChannelMessageÚmessageÚMessageÚ
grouped_idÚ_IGNORE_DICTÚpopÚidr   ÚlenÚ_IGNORE_MAX_SIZEÚitemsÚ_IGNORE_MAX_AGEÚEvent)	ÚclsÚupdateÚothersÚself_idÚgroupÚnowÚiÚtÚus	            r   ÚbuildzAlbum.buildb   sf  € ð
 �ˆä�fÜ×-Ñ-¬u×/LÑ/LÐMõOä˜fŸn™n¬e¯m©mÔ<Øà—N‘N×-Ñ-ˆEØˆ}Øô
 ×Ñ¤ 6£
¨DÔ1Øô —)‘)“+ˆCÜ”<Ó Ô#3Ò3Ü(4×(:Ñ(:Ó(<×Z¡  1ÀÀaÁÌ/Ó@Yš!ÓZò (�AÜ$ Q™ð(ð ò .�Ø˜F’?Ø*-”L¤ A£Ò'ð.ð
 —9‘9Ø#)öØÜ˜q¤5×#9Ñ#9¼5×;XÑ;XÐ"YÔZÜ" 1§9¡9¬e¯m©mÔ<ØŸ	™	×,Ñ,°Ò5ð —	“	òó ð ð9Oùó& [ùòs   ÃF&Ã#F&Ä$A:F,c                 óT   •— t        |j                  «      dkD  rt        ‰| �  |«      S y ©Nr   )rA   r"   r4   Úfilter)r   r   r6   s     €r   rR   zAlbum.filterŒ   s(   ø€ äˆu�~‰~Ó Ò"Ü‘7‘> %Ó(Ð(ð #r    c                   óÄ   ‡ — e Zd ZdZˆ fd„Zˆ fd„Zed„ «       Zed„ «       Zed„ «       Z	ed„ «       Z
ed„ «       Zd	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zddœd„Zd„ Zd„ Zd„ Zˆ xZS )úAlbum.EventzÛ
        Represents the event of a new album.

        Members:
            messages (Sequence[`Message <telethon.tl.custom.message.Message>`]):
                The list of messages belonging to the same album.
        c                 óÐ   •— |d   }t         ‰| �  |j                  |j                  t	        |j
                  «      ¬«       t        j                  | |j                  «       || _        y )Nr   )Ú	chat_peerÚmsg_idÚ	broadcast)	r4   r   Úpeer_idr@   ÚboolÚpostr
   Ú	sender_idr"   )r   r"   r;   r6   s      €r   r   zAlbum.Event.__init__™   sT   ø€ Ø˜q‘kˆGÜ‰GÑ w§¡Ø$+§J¡J¼$¸w¿|¹|Ó:Lð ô Nä×!Ñ! $¨×(9Ñ(9Ô:Ø$ˆD�Mr    c                 ó  •— t         ‰| �  |«       t        j                  | j                  | j
                  |j                  «      \  | _        | _        | j                  D ]  }|j                  || j
                  d «       Œ! t        | j                  «      dk(  rg|j                  j                  | j                  «      }|€$t        || «      |j                  | j                  <   y |j!                  | j                  «       y y rQ   )r4   Ú_set_clientr   Ú_get_entity_pairr\   Ú	_entitiesÚ_mb_entity_cacheÚ_senderÚ_input_senderr"   Ú_finish_initrA   Ú_albumsÚgetr=   r   r#   )r   r   ÚmsgÚhackr6   s       €r   r^   zAlbum.Event._set_client    sÉ   ø€ Ü‰GÑ Ô'Ü/4×/EÑ/EØ—‘ §¡°×0GÑ0Gó0IÑ,ˆDŒL˜$Ô,ð —}‘}ò ?�Ø× Ñ  ¨¯©¸Õ>ð?ô �4—=‘=Ó! QÒ&à—~‘~×)Ñ)¨$¯/©/Ó:�Ø�<Ü6?ÀÈÓ6M�F—N‘N 4§?¡?Ò3à—K‘K §¡Õ.ð 'r    c                 ó4   — | j                   d   j                  S )zM
            The shared ``grouped_id`` between all the messages.
            r   )r"   r=   ©r   s    r   r=   zAlbum.Event.grouped_id°   s   € ð
 —=‘= Ñ#×.Ñ.Ð.r    c                 ó<   — t        d„ | j                  D «       d«      S )zŠ
            The message text of the first photo with a caption,
            formatted using the client's default parse mode.
            c              3   óN   K  — | ]  }|j                   sŒ|j                   –— Œ y ­wr   )Útext©Ú.0Úms     r   ú	<genexpr>z#Album.Event.text.<locals>.<genexpr>½   s   è ø€ ÒA A¸!¿&»&˜Ÿ�ÑAùó   ‚%”%Ú ©Únextr"   rj   s    r   rm   zAlbum.Event.text·   s   € ô ÑA¨¯©ÔAÀ2ÓFÐFr    c                 ó<   — t        d„ | j                  D «       d«      S )zv
            The raw message text of the first photo
            with a caption, ignoring any formatting.
            c              3   óN   K  — | ]  }|j                   sŒ|j                   –— Œ y ­wr   )Úraw_textrn   s     r   rq   z'Album.Event.raw_text.<locals>.<genexpr>Å   s   è ø€ ÒI¨¸a¿j»j˜Ÿ�ÑIùrr   rs   rt   rj   s    r   rx   zAlbum.Event.raw_text¿   s   € ô ÑI¨T¯]©]ÔIÈ2ÓNÐNr    c                 ó4   — | j                   d   j                  S )a  
            `True` if the album is a reply to some other message.

            Remember that you can access the ID of the message
            this one is replying to through `reply_to_msg_id`,
            and the `Message` object with `get_reply_message()`.
            r   )r"   Úis_replyrj   s    r   rz   zAlbum.Event.is_replyÇ   s   € ð —=‘= Ñ#×,Ñ,Ð,r    c                 ó4   — | j                   d   j                  S )zœ
            The `Forward <telethon.tl.custom.forward.Forward>`
            information for the first message in the album if it was forwarded.
            r   )r"   Úforwardrj   s    r   r|   zAlbum.Event.forwardÓ   s   € ð —=‘= Ñ#×+Ñ+Ð+r    c              ƒ   óX   K  — | j                   d   j                  «       ƒ d{  –—† S 7 Œ­w)z¿
            The `Message <telethon.tl.custom.message.Message>`
            that this album is replying to, or `None`.

            The result will be cached after its first use.
            r   N)r"   Úget_reply_messagerj   s    r   r~   zAlbum.Event.get_reply_messageà   s&   è ø€ ð Ÿ™ qÑ)×;Ñ;Ó=×=Ð=Ð=ús   ‚!*£(¤*c              �   ó\   K  —  | j                   d   j                  |i |¤Žƒ d{  –—† S 7 Œ­w)z»
            Responds to the album (not as a reply). Shorthand for
            `telethon.client.messages.MessageMethods.send_message`
            with ``entity`` already set.
            r   N)r"   Úrespond©r   ÚargsÚkwargss      r   r€   zAlbum.Event.respondé   s/   è ø€ ð 2˜Ÿ™ qÑ)×1Ñ1°4ÐB¸6ÑB×BÐBÐBúó   ‚#,¥*¦,c              �   ó\   K  —  | j                   d   j                  |i |¤Žƒ d{  –—† S 7 Œ­w)zß
            Replies to the first photo in the album (as a reply). Shorthand
            for `telethon.client.messages.MessageMethods.send_message`
            with both ``entity`` and ``reply_to`` already set.
            r   N)r"   Úreplyr�   s      r   r†   zAlbum.Event.replyñ   s/   è ø€ ð 0˜Ÿ™ qÑ)×/Ñ/°Ð@¸Ñ@×@Ð@Ð@úr„   c              �   óÈ   K  — | j                   rN| j                  |d<   | j                  «       ƒ d{  –—† |d<    | j                   j                  |i |¤Žƒ d{  –—† S y7 Œ,7 Œ­w)zË
            Forwards the entire album. Shorthand for
            `telethon.client.messages.MessageMethods.forward_messages`
            with both ``messages`` and ``from_peer`` already set.
            r"   NÚ	from_peer)r   r"   Úget_input_chatÚforward_messagesr�   s      r   Ú
forward_tozAlbum.Event.forward_toù   s^   è ø€ ð �|Š|Ø%)§]¡]��zÑ"Ø,0×,?Ñ,?Ó,A×&A��{Ñ#Ø:˜TŸ\™\×:Ñ:¸DÐKÀFÑK×KÐKð à&AøØKús!   ‚/A"±A²&A"ÁA ÁA"Á A"c              �   óÒ   K  — | j                   D ]*  }|j                  sŒ |j                  |i |¤Žƒ d{  –—† c S   | j                   d   j                  |i |¤Žƒ d{  –—† S 7 Œ.7 Œ­w)aÎ  
            Edits the first caption or the message, or the first messages'
            caption if no caption is set, iff it's outgoing. Shorthand for
            `telethon.client.messages.MessageMethods.edit_message`
            with both ``entity`` and ``message`` already set.

            Returns `None` if the message was incoming,
            or the edited `Message` otherwise.

            .. note::

                This is different from `client.edit_message
                <telethon.client.messages.MessageMethods.edit_message>`
                and **will respect** the previous state of the message.
                For example, if the message didn't have a link preview,
                the edit won't add one by default, and you should force
                it by setting it to `True` if you want it.

                This is generally the most desired and convenient behaviour,
                and will work for link previews and message buttons.
            Nr   )r"   rx   Úedit)r   r‚   rƒ   rg   s       r   r�   zAlbum.Event.edit  sj   è ø€ ð, —}‘}ò ;�Ø—<“<Ø!) §¡¨4Ð!:°6Ñ!:×:Ò:ð;ð /˜Ÿ™ qÑ)×.Ñ.°Ð?¸Ñ?×?Ð?ð ;øà?ús&   ‚A'ŸA'´A#µ)A'ÁA%ÁA'Á%A'c              �   ó¾   K  — | j                   rI | j                   j                  | j                  «       ƒ d{  –—† | j                  g|¢­i |¤Žƒ d{  –—† S y7 Œ 7 Œ­w)aH  
            Deletes the entire album. You're responsible for checking whether
            you have the permission to do so, or to except the error otherwise.
            Shorthand for
            `telethon.client.messages.MessageMethods.delete_messages` with
            ``entity`` and ``message_ids`` already set.
            N)r   Údelete_messagesr‰   r"   r�   s      r   ÚdeletezAlbum.Event.delete   s`   è ø€ ð �|Š|Ø9˜TŸ\™\×9Ñ9Ø×-Ñ-Ó/×/°·±ðàòà#ñ÷ ð ð à/øðús!   ‚6A¸A¹AÁAÁAÁAc              ƒ   óÒ   K  — | j                   rS| j                   j                  | j                  «       ƒ d{  –—† | j                  d   j                  ¬«      ƒ d{  –—†  yy7 Œ+7 Œ­w)zþ
            Marks the entire album as read. Shorthand for
            `client.send_read_acknowledge()
            <telethon.client.messages.MessageMethods.send_read_acknowledge>`
            with both ``entity`` and ``message`` already set.
            Néÿÿÿÿ)Úmax_id)r   Úsend_read_acknowledger‰   r"   r@   rj   s    r   Ú	mark_readzAlbum.Event.mark_read.  sb   è ø€ ð �|Š|Ø—l‘l×8Ñ8Ø×-Ñ-Ó/×/¸¿¹ÀbÑ8I×8LÑ8Lð 9ó N÷ Nñ Nð à/øðNús!   ‚5A'·A#¸$A'ÁA%ÁA'Á%A'F©Únotifyc             ƒ   ó\   K  — | j                   d   j                  |¬«      ƒ d{  –—† S 7 Œ­w)zÊ
            Pins the first photo in the album. Shorthand for
            `telethon.client.messages.MessageMethods.pin_message`
            with both ``entity`` and ``message`` already set.
            r   r–   N)r"   Úpin)r   r—   s     r   r™   zAlbum.Event.pin9  s+   è ø€ ð Ÿ™ qÑ)×-Ñ-°VÐ-Ó<×<Ð<Ð<úr„   c                 ó,   — t        | j                  «      S )zx
            Return the amount of messages in the album.

            Equivalent to ``len(self.messages)``.
            )rA   r"   rj   s    r   Ú__len__zAlbum.Event.__len__A  s   € ô �t—}‘}Ó%Ð%r    c                 ó,   — t        | j                  «      S )zu
            Iterate over the messages in the album.

            Equivalent to ``iter(self.messages)``.
            )Úiterr"   rj   s    r   Ú__iter__zAlbum.Event.__iter__I  s   € ô ˜Ÿ™Ó&Ð&r    c                 ó    — | j                   |   S )zq
            Access the n'th message in the album.

            Equivalent to ``event.messages[n]``.
            )r"   )r   Úns     r   Ú__getitem__zAlbum.Event.__getitem__Q  s   € ð —=‘= Ñ#Ð#r    )r)   r*   r+   r,   r   r^   Úpropertyr=   rm   rx   rz   r|   r~   r€   r†   r‹   r�   r�   r•   r™   r›   rž   r¡   Ú__classcell__©r6   s   @r   rE   rT   ‘   s»   ø„ ñ	ô	%ô	/ð  
ñ	/ó 
ð	/ð 
ñ	Gó 
ð	Gð 
ñ	Oó 
ð	Oð 
ñ		-ó 
ð		-ð 
ñ	,ó 
ð	,ò	>ò	Cò	Aò		Lò	@ò8	ò		Nð ',ô 	=ò	&ò	'ö	$r    rE   r   )NN)r)   r*   r+   r,   r   ÚclassmethodrO   rR   r   r
   rE   r£   r¤   s   @r   r/   r/   C   sN   ø„ ñð4 ðLØ16¸TöLð ò'ó ð'ôR)ô
F$�˜\÷ F$ð F$r    r/   )r&   r   r   Úcommonr   r   r   rs   r   Útlr	   Útl.custom.sendergetterr
   rB   rD   r>   r   r   r/   r-   r    r   ú<module>r©      s_   ðÛ Û Û ç ?Ñ ?Ý Ý Ý 1àÐ Ø€ð
 €ð €÷*&ñ *&ðZ ôS$ˆLó S$ó ñS$r    