o
    Xzjô  ã                   @   s>   d dl mZ ddl mZmZmZ ddl mZ G dd„ dƒZdS )	é   )ÚDrafté   )ÚTLObjectÚtypesÚ	functionsé   )Úutilsc                   @   sL   e Zd ZdZdd„ Zdd„ Zddd„Zdd
d„Zdd„ Zdd„ Z	dd„ Z
dS )ÚDialoga|
  
    Custom class that encapsulates a dialog (an open "conversation" with
    someone, a group or a channel) providing an abstraction to easily
    access the input version/normal entity/message etc. The library will
    return instances of this class when calling :meth:`.get_dialogs()`.

    Args:
        dialog (:tl:`Dialog`):
            The original ``Dialog`` instance.

        pinned (`bool`):
            Whether this dialog is pinned to the top or not.

        folder_id (`folder_id`):
            The folder ID that this dialog belongs to.

        archived (`bool`):
            Whether this dialog is archived or not (``folder_id is None``).

        message (`Message <telethon.tl.custom.message.Message>`):
            The last message sent on this dialog. Note that this member
            will not be updated when new messages arrive, it's only set
            on creation of the instance.

        date (`datetime`):
            The date of the last message sent on this dialog.

        entity (`entity`):
            The entity that belongs to this dialog (user, chat or channel).

        input_entity (:tl:`InputPeer`):
            Input version of the entity.

        id (`int`):
            The marked ID of the entity, which is guaranteed to be unique.

        name (`str`):
            Display name for this dialog. For chats and channels this is
            their title, and for users it's "First-Name Last-Name".

        title (`str`):
            Alias for `name`.

        unread_count (`int`):
            How many messages are currently unread in this dialog. Note that
            this value won't update when new messages arrive.

        unread_mentions_count (`int`):
            How many mentions are currently unread in this dialog. Note that
            this value won't update when new messages arrive.

        unread_reactions_count (`int`):
            How many reactions are currently unread in this dialog. Note that
            this value won't update when new messages arrive.

        unread_poll_votes_count (`int`):
            How many poll votes are currently unread in this dialog. Note that
            this value won't update when new messages arrive.

        draft (`Draft <telethon.tl.custom.draft.Draft>`):
            The draft object in this dialog. It will not be `None`,
            so you can call ``draft.set_message(...)``.

        is_user (`bool`):
            `True` if the `entity` is a :tl:`User`.

        is_group (`bool`):
            `True` if the `entity` is a :tl:`Chat`
            or a :tl:`Channel` megagroup.

        is_channel (`bool`):
            `True` if the `entity` is a :tl:`Channel`.
    c                 C   s  || _ || _t|jƒ| _|j| _|jd u| _|| _t| jdd ƒ| _|t	 
|j¡ | _t	 | j¡| _t	 
| j¡| _t	 | j¡ | _| _|j| _|j| _|j| _|j| _t|| j| jjƒ| _t| jtjƒ| _t| jtjtjfƒpxt| jtjƒox| jj | _!t| jtjƒ| _"d S )NÚdate)#Ú_clientÚdialogÚboolÚpinnedÚ	folder_idÚarchivedÚmessageÚgetattrr
   r   Úget_peer_idÚpeerÚentityÚget_input_peerÚinput_entityÚidÚget_display_nameÚnameÚtitleÚunread_countÚunread_mentions_countÚunread_reactions_countÚunread_poll_votes_countr   ÚdraftÚ
isinstancer   ÚUserÚis_userÚChatÚChatForbiddenÚChannelÚ	megagroupÚis_groupÚ
is_channel)ÚselfÚclientr   Úentitiesr   © r-   úT/var/www/kodo/tsheker/venv/lib/python3.10/site-packages/telethon/tl/custom/dialog.pyÚ__init__P   s*   þzDialog.__init__c                 Ï   s$   �| j j| jg|¢R i |¤ŽI dH S )z–
        Sends a message to this dialog. This is just a wrapper around
        ``client.send_message(dialog.input_entity, *args, **kwargs)``.
        N)r   Úsend_messager   )r*   ÚargsÚkwargsr-   r-   r.   r0   m   s   €ÿÿÿzDialog.send_messageFc                 Ã   s   �| j j| j|d�I dH  dS )a  
        Deletes the dialog from your dialog list. If you own the
        channel this won't destroy it, only delete it from the list.

        Shorthand for `telethon.client.dialogs.DialogMethods.delete_dialog`
        with ``entity`` already set.
        )ÚrevokeN)r   Údelete_dialogr   )r*   r3   r-   r-   r.   Údeleteu   s   €zDialog.deleter   c                 Ã   s(   �|   tj tj| j|d�g¡¡I dH S )aþ  
        Archives (or un-archives) this dialog.

        Args:
            folder (`int`, optional):
                The folder to which the dialog should be archived to.

                If you want to "un-archive" it, use ``folder=0``.

        Returns:
            The :tl:`Updates` object that the request produces.

        Example:

            .. code-block:: python

                # Archiving
                dialog.archive()

                # Un-archiving
                dialog.archive(0)
        )r   N)r   r   ÚfoldersÚEditPeerFoldersRequestr   ÚInputFolderPeerr   )r*   Úfolderr-   r-   r.   Úarchive‚   s   €
ÿzDialog.archivec                 C   s   d| j | j| j| j| jdœS )Nr	   )Ú_r   r
   r    r   r   )r   r
   r    r   r   ©r*   r-   r-   r.   Úto_dict�   s   úzDialog.to_dictc                 C   s   t  |  ¡ ¡S )N©r   Úpretty_formatr=   r<   r-   r-   r.   Ú__str__§   s   zDialog.__str__c                 C   s   t j|  ¡ dd�S )Né    )Úindentr>   r<   r-   r-   r.   Ú	stringifyª   s   zDialog.stringifyN)F)r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r/   r0   r5   r:   r=   r@   rC   r-   r-   r-   r.   r	      s    I


r	   N)Ú r   r   r   r   r   r	   r-   r-   r-   r.   Ú<module>   s    