Ë
    £| k�  ã                  óê   — d Z ddlmZ ddlZddlmZ ddlmZmZ ddl	m
Z
mZ dZ ej                  d	ej                  «      Z ej                  d
ej                  «      Zdd„Zdd„Zdd„Zddd„Zdd„Zy)a’  What TELEGRAM does to a channel (not what an admin does): the copyright notice and its relatives.

A channel that gets a copyright strike shows "This message couldn't be displayed on your device due to copyright
infringement." in place of its posts. That is not an edit by an admin, so nothing here ever treats it as one: the sync
leaves My posts as saved, and the link fixer does not edit such posts.
é    )ÚannotationsN)ÚOptional)ÚerrorsÚ	functionsé   )Úexplain_rpcÚflood_retryz+Telegram shows a notice instead of the postzÔ^this (?:message|post|channel|media|content|file|video)\b.{0,80}?\b(?:can.?t|cannot|can not|couldn.?t|could not|isn.?t|is not|won.?t|will not)\b.{0,40}?\b(?:displayed|shown|viewed|available|accessible)\b.{0,160}$zPcopyright|infring|device|country|region|terms of service|violat|restrict|\blaw\bc                óH   — dj                  | xs dj                  «       «      S )NÚ Ú )ÚjoinÚsplit)Útexts    ú/app/app/restrictions.pyÚ	norm_textr      s   € Ø�8‰8�T’Z˜R×&Ñ&Ó(Ó)Ð)ó    c                óÊ   — t        | «      }dt        |«      cxk  xr dk  nc xr> t        t        j	                  |«      «      xr t        t
        j                  |«      «      S )zkThe notice Telegram's apps show in place of a post it holds back (copyright, terms of service, region ...).r   i  )r   ÚlenÚboolÚ_NOTICEÚmatchÚ_NOTICE_WHYÚsearch)r   Úts     r   Úis_placeholder_textr       sH   € ä�$‹€AØŒs�1‹vÖ˜ÔÒW¤¤g§m¡m°AÓ&6Ó!7ÒW¼DÄ×ASÑASÐTUÓAVÓ<WÐWr   c                ó*  — t        | dd«      }|rq|D �cg c]4  }t        t        t        |dd«      xs t        |dd«      xs d«      «      ‘Œ6 }}dj                  t        j                  d„ |D «       «      «      dd xs d	S t        | d
d«      ry	yc c}w )zmWhat Telegram says about a restricted channel or message (its own words), or None when nothing is restricted.Úrestriction_reasonNr   r   Úreasonz; c              3  ó&   K  — | ]	  }|sŒ|–— Œ y ­w©N© )Ú.0r   s     r   Ú	<genexpr>z!restriction_of.<locals>.<genexpr>+   s   è ø€ Ð&=±%¨Qº1¤q±%ùs   ‚Šéð   zrestricted by TelegramÚ
restricted)Úgetattrr   Ústrr   ÚdictÚfromkeys)ÚobjÚreasonsÚrÚtextss       r   Úrestriction_ofr.   &   s•   € ä�cÐ/°Ó6€GÙÙcjÓkÑcjÐ^_”œ3œw q¨&°"Ó5ÒW¼ÀÀHÈbÓ9QÒWÐUWÓXÕYÐcjˆÐkØ�y‰yœŸ™Ñ&=±%Ó&=Ó=Ó>¸tÀÐDÒ`ÐH`Ð`Üˆs�L $Ô'Ø'Øùò	 ls   ”9Bc                ó–   — t        | «      }|r|S | j                  xs d}t        |«      r|�t        |«      t        |«      k7  rt        S y)a3  Why this message must not be taken over as it looks now, or None. Telegram marks a message it holds back
    (restriction_reason); some places hand out its notice as the text instead. `saved_text` is the saved copy's text: a
    text that the saved copy already has is the owner's own wording, not a notice.r   N)r.   Úmessager   r   ÚPLACEHOLDER_NOTE)ÚmÚ
saved_textÚwhyÚlives       r   Úmessage_restrictionr6   1   sJ   € ô ˜Ó
€CÙ
Øˆ
Ø�9‰9Š?˜€DÜ˜4Ô  jÐ&8¼IÀd»OÌyÐYcÓOdÒ<dÜÐØr   c              ƒ  ór  ‡ ‡K  — 	 t        ˆ ˆfd„«      ƒ d{  –—† }t	        t	        |dd«      dd«      }|€yt	        ‰dd«      }d}t	        |dd«      xs g D ]  }t	        |dd«      |k(  sŒt        |«      }Œ  t        |«      |dfS 7 Œn# t        j                  $ r}ddt        |«      fcY d}~S d}~ww xY w­w)	z¦(the channel's event counter, why Telegram restricts the channel or None, None) - or (None, None, why not).
    The counter is never lower than the newest message id.c                 óN   •—  ‰ t         j                  j                  ‰«      «      S r    )r   ÚchannelsÚGetFullChannelRequest)ÚclientÚpeers   €€r   Ú<lambda>zprobe_channel.<locals>.<lambda>B   s   ø€ ©´	×0BÑ0B×0XÑ0XÐY]Ó0^Ô)_r   NÚ	full_chatÚpts)NNz2Telegram did not say how far the channel has come.Ú
channel_idÚchatsÚid)r	   r   ÚRPCErrorr   r&   r.   Úint)r;   r<   ÚfullÚer?   Úcidr4   Úchats   ``      r   Úprobe_channelrI   >   sÁ   ùè ø€ ð*Ü Ô!_Ó`×`ˆô ”'˜$ ¨TÓ2°E¸4Ó
@€CØ
€{ØOÜ
�$˜ dÓ
+€CØ
€CÜ˜˜g tÓ,Ò2°Ò2ˆÜ�4˜˜tÓ$¨Ó+Ü  Ó&‰Cð 3ô ˆs‹8�S˜$ÐÐð aùÜ�?‰?ò *Ø�Tœ; q›>Ð)Õ)ûð*üsJ   „B7†B	 ˜B™B	 �AB7Á,B7ÂB	 Â	B4ÂB/Â)B4Â*B7Â/B4Â4B7)r   úOptional[str]Úreturnr'   )r   rJ   rK   r   )rK   rJ   r    )r3   rJ   rK   rJ   )rK   Útuple)Ú__doc__Ú
__future__r   ÚreÚtypingr   Útelethonr   r   Útgutilr   r	   r1   ÚcompileÚIr   r   r   r   r.   r6   rI   r!   r   r   Ú<module>rU      sx   ðñõ #ã 	Ý ç &ç ,à@Ð ð ˆ"�*‰*ðDð ‡D�Dó	€ð ˆb�j‰jÐlÐnp×nrÑnrÓs€ó*óXóô
ôr   