o
    Xzj#  ã                   @   s&   d dl mZ dd„ ZG dd„ dƒZdS )é   )Útypesc                    s   ‡ fdd„}||dœS )zÖ
    Helper method to build properties that return `True` if the user is an
    administrator of a normal chat, or otherwise return `True` if the user
    has a specific permission being an admin of a channel.
    c                    s"   | j sdS | jr
dS t| jjˆ ƒS )NFT)Úis_adminÚis_chatÚgetattrÚparticipantÚadmin_rights©Úself©Ú
field_name© úd/var/www/kodo/tsheker/venv/lib/python3.10/site-packages/telethon/tl/custom/participantpermissions.pyÚfget
   s
   z_admin_prop.<locals>.fget)r   Údocr   )r   r   r   r   r
   r   Ú_admin_prop   s   
r   c                   @   s  e Zd ZdZdefdd„Zedd„ ƒZedd„ ƒZed	d
„ ƒZ	edd„ ƒZ
edd„ ƒZedd„ ƒZed$i eddƒ¤ŽZed$i eddƒ¤ŽZed$i eddƒ¤ŽZed$i eddƒ¤ŽZed$i eddƒ¤ŽZed$i eddƒ¤ŽZed$i eddƒ¤ŽZed$i edd ƒ¤ŽZed$i ed!d"ƒ¤ŽZd#S )%ÚParticipantPermissionsa�  
    Participant permissions information.

    The properties in this objects are boolean values indicating whether the
    user has the permission or not.

    Example
        .. code-block:: python

            permissions = ...

            if permissions.is_banned:
                "this user is banned"
            elif permissions.is_admin:
                "this user is an administrator"
    Úchatc                 C   s   || _ || _d S )N)r   r   )r	   r   r   r   r   r   Ú__init__&   s   
zParticipantPermissions.__init__c                 C   s   | j pt| jtjtjfƒS )z¦
        Whether the user is an administrator of the chat or not. The creator
        also counts as begin an administrator, since they have all permissions.
        )Ú
is_creatorÚ
isinstancer   r   ÚChannelParticipantAdminÚChatParticipantAdminr   r   r   r   r   *   s   þzParticipantPermissions.is_adminc                 C   s   t | jtjtjfƒS )zE
        Whether the user is the creator of the chat or not.
        )r   r   r   ÚChannelParticipantCreatorÚChatParticipantCreatorr   r   r   r   r   5   s   þz!ParticipantPermissions.is_creatorc                 C   s   t | jtjtjtjfƒS )z”
        Whether the user is a normal user of the chat (not administrator, but
        not banned either, and has no restrictions applied).
        )r   r   r   ÚChannelParticipantÚChatParticipantÚChannelParticipantSelfr   r   r   r   Úhas_default_permissions?   s
   ýz.ParticipantPermissions.has_default_permissionsc                 C   ó   t | jtjƒS )z9
        Whether the user is banned in the chat.
        )r   r   r   ÚChannelParticipantBannedr   r   r   r   Ú	is_bannedK   ó   z ParticipantPermissions.is_bannedc                 C   r   )z1
        Whether the user left the chat.
        )r   r   r   ÚChannelParticipantLeftr   r   r   r   Úhas_leftR   r!   zParticipantPermissions.has_leftc                 C   s    | j sdS | jr| jS | jjjS )z{
        Whether the administrator can add new administrators with the same or
        less permissions than them.
        F)r   r   r   r   r   Ú
add_adminsr   r   r   r   r$   Y   s
   
z!ParticipantPermissions.add_adminsÚ	ban_userszC
        Whether the administrator can ban other users or not.
    Úpin_messagesz@
        Whether the administrator can pin messages or not.
    Úinvite_userszF
        Whether the administrator can add new users to the chat.
    Údelete_messageszT
        Whether the administrator can delete messages from other participants.
    Úedit_messagesz:
        Whether the administrator can edit messages.
    Úpost_messageszS
        Whether the administrator can post messages in the broadcast channel.
    Úchange_infozx
        Whether the administrator can change the information about the chat,
        such as title or description.
    Ú	anonymouszT
        Whether the administrator will remain anonymous when sending messages.
    Úmanage_callzB
        Whether the user will be able to manage group calls.
    Nr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úboolr   Úpropertyr   r   r   r    r#   r$   r   r%   r&   r'   r(   r)   r*   r+   r,   r-   r   r   r   r   r      s0    


	



r   N)Ú r   r   r   r   r   r   r   Ú<module>   s    