U
    h#                     @   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 M/tmp/pip-unpacked-wheel-c81u5j2r/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ed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f eddZef eddZef eddZef eddZef eddZef eddZef eddZef edd Zef 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   ZChannelParticipantAdminZ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   ZChannelParticipantCreatorZ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   ZChannelParticipantZChatParticipantZChannelParticipantSelfr   r   r   r   has_default_permissions?   s
    z.ParticipantPermissions.has_default_permissionsc                 C   s   t | jtjS )z9
        Whether the user is banned in the chat.
        )r   r   r   ZChannelParticipantBannedr   r   r   r   	is_bannedK   s    z ParticipantPermissions.is_bannedc                 C   s   t | jtjS )z1
        Whether the user left the chat.
        )r   r   r   ZChannelParticipantLeftr   r   r   r   has_leftR   s    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.
    N)__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      s.   

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