
    ;Si                     R    d dl Z ddlmZmZ ddlmZ  G d de j                        Zy)    N   )errorsutils)typesc                       e Zd ZdZddddddZed        Zd Zed        Zd Z	ed	        Z
ed
        Zed        Zed        Zd Zy)
ChatGetterz
    Helper base class that introduces the `chat`, `input_chat`
    and `chat_id` properties and `get_chat` and `get_input_chat`
    methods.
    N)
input_chatchat	broadcastc                J    || _         || _        || _        || _        d | _        y N)
_chat_peer_input_chat_chat
_broadcast_client)self	chat_peerr	   r
   r   s        b/var/www/OnlineNewsSite/project/venv/lib/python3.12/site-packages/telethon/tl/custom/chatgetter.py__init__zChatGetter.__init__   s&    #%
#    c                     | j                   S )a|  
        Returns the :tl:`User`, :tl:`Chat` or :tl:`Channel` where this object
        belongs to. It may be `None` if Telegram didn't send the chat.

        If you only need the ID, use `chat_id` instead.

        If you need to call a method which needs
        this chat, use `input_chat` instead.

        If you're using `telethon.events`, use `get_chat()` instead.
        )r   r   s    r   r
   zChatGetter.chat   s     zzr   c                   K   | j                   t        | j                   dd      rW| j                          d{   r?	 | j                  j	                  | j
                         d{   | _         | j                   S | j                   S 7 O7 ## t        $ r' | j                          d{  7   Y | j                   S w xY ww)a  
        Returns `chat`, but will make an API call to find the
        chat unless it's already cached.

        If you only need the ID, use `chat_id` instead.

        If you need to call a method which needs
        this chat, use `get_input_chat()` instead.
        Nmin)r   getattrget_input_chatr   
get_entityr   
ValueError_refetch_chatr   s    r   get_chatzChatGetter.get_chat#   s      JJ'$**eT"B--///+,,11$2B2BCC 
 zztzz 0 D +((***zz+sP   7C B	C (B 'B(	B 1C B B=)B,*B=/C <B==C c                 ^   | j                   || j                  rp| j                  rd	 | j                  j                  j	                  t        j                  | j                  d            j                         | _         | j                   S | j                   S # t        $ r Y | j                   S w xY w)a  
        This :tl:`InputPeer` is the input version of the chat where the
        message was sent. Similarly to `input_sender
        <telethon.tl.custom.sendergetter.SenderGetter.input_sender>`, this
        doesn't have things like username or similar, but still useful in
        some cases.

        Note that this might not be available if the library doesn't
        have enough information available.
        F)add_mark)	r   r   r   _mb_entity_cachegetr   get_peer_id_as_input_peerAttributeErrorr   s    r   r	   zChatGetter.input_chat7   s     #DLL#'<<#@#@#D#D))$//EJ$LLZNL\  
 t " s   AB 	B,+B,c                   K   | j                   | j                  r|| j                  rp	 | j                  }| j                  j                  d      2 3 d{   }|j                  |k(  s|j
                  | _        |j                  | _         | j                  S | j                  S 7 O6 	 | j                  S # t        j                  $ r Y | j                  S w xY ww)z|
        Returns `input_chat`, but will make an API call to find the
        input chat unless it's already cached.
        Nd   )r	   chat_idr   iter_dialogsidentityr   input_entityr   r   RPCError)r   targetds      r   r   zChatGetter.get_input_chatL   s     
 ??"t||	#||88=  !ttv~%&XX
+,>>( t=  ?? sX   %C'B3 B%B#B%B3 (#B3 C#B%%B3 'C3CCCCc                 \    | j                   rt        j                  | j                         S dS )a  
        Returns the marked chat integer ID. Note that this value **will
        be different** from ``peer_id`` for incoming private messages, since
        the chat *to* which the messages go is to your own person, but
        the *chat* itself is with the one who sent the message.

        TL;DR; this gets the ID that you expect.

        If there is a chat in the object, `chat_id` will *always* be set,
        which is why you should use it instead of `chat.id <chat>`.
        N)r   r   r&   r   s    r   r+   zChatGetter.chat_id_   s$     6:__u  1N$Nr   c                 f    | j                   r$t        | j                   t        j                        S dS )z
        `True` if the message was sent as a private message.

        Returns `None` if there isn't enough information
        (e.g. on `events.MessageDeleted <telethon.events.messagedeleted.MessageDeleted>`).
        N)r   
isinstancer   PeerUserr   s    r   
is_privatezChatGetter.is_privaten   s&     ?Cooz$//5>>:WSWWr   c                 R   | j                   :t        | j                  d      r$t        | j                  j                        | _         t        | j                  t        j                        r| j                   y| j                    S t        | j                  t        j                        S )z
        True if the message was sent on a group or megagroup.

        Returns `None` if there isn't enough information
        (e.g. on `events.MessageDeleted <telethon.events.messagedeleted.MessageDeleted>`).
        Nr   )
r   hasattrr
   boolr   r5   r   r   PeerChannelPeerChatr   s    r   is_groupzChatGetter.is_groupx   st     ??"wtyy+'F"499#6#67DOdoou'8'89&??**$//5>>::r   c                 J    t        | j                  t        j                        S )z9`True` if the message was sent on a megagroup or channel.)r5   r   r   r;   r   s    r   
is_channelzChatGetter.is_channel   s    
 $//5+<+<==r   c                    K   yw)zB
        Re-fetches chat information through other means.
        N r   s    r   r    zChatGetter._refetch_chat   s     s   r   )__name__
__module____qualname____doc__r   propertyr
   r!   r	   r   r+   r7   r=   r?   r    rA   r   r   r   r      s    
TPT   (    ( & O O X X ; ;& > >r   r   )abc r   r   tlr   ABCr   rA   r   r   <module>rK      s     
  O Or   