U
    hd?                     @   s*   d dl mZ d dlmZ G dd dZdS )   )types)get_input_peerc                   @   s  e Zd ZdZ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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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,d- Zed.d/ Zed0d1 Zed2d3 Zed4d5 Zed6d7 Zed8d9 Z ed:d; Z!ed<d= Z"ed>d? Z#ed@dA Z$edBdC Z%edDdE Z&edFdG Z'edHdI Z(edJdK Z)dLdM Z*dNdO Z+dPS )QAdminLogEventa  
    Represents a more friendly interface for admin log events.

    Members:
        original (:tl:`ChannelAdminLogEvent`):
            The original :tl:`ChannelAdminLogEvent`.

        entities (`dict`):
            A dictionary mapping user IDs to :tl:`User`.

            When `old` and `new` are :tl:`ChannelParticipant`, you can
            use this dictionary to map the ``user_id``, ``kicked_by``,
            ``inviter_id`` and ``promoted_by`` IDs to their :tl:`User`.

        user (:tl:`User`):
            The user that caused this action (``entities[original.user_id]``).

        input_user (:tl:`InputPeerUser`):
            Input variant of `user`.
    c                 C   s(   || _ || _||j | _t| j| _d S N)originalentitiesuser_iduserr   Z
input_user)selfr   r    r   D/tmp/pip-unpacked-wheel-c81u5j2r/telethon/tl/custom/adminlogevent.py__init__   s    zAdminLogEvent.__init__c                 C   s   | j jS )z'
        The ID of this event.
        )r   idr
   r   r   r   r       s    zAdminLogEvent.idc                 C   s   | j jS )z4
        The date when this event occurred.
        )r   dater   r   r   r   r   '   s    zAdminLogEvent.datec                 C   s   | j jS )z?
        The ID of the user that triggered this event.
        )r   r   r   r   r   r   r   .   s    zAdminLogEvent.user_idc                 C   s   | j jS )z@
        The original :tl:`ChannelAdminLogEventAction`.
        )r   actionr   r   r   r   r   5   s    zAdminLogEvent.actionc                 C   s  | j j}t|tjtjtjtjtjfr,|j	S t|tj
r>|jS t|tjrP|jS t|tjrb|jS t|tjtjfrz|jS t|tjtjtjfr|j S t|tjr|jS t|tjr|jS t|tjr|jS t|tjtjtjfr|j S t|tj! r|j"S dS )z/
        The old value from the event.
        N)#r   r   
isinstancer   %ChannelAdminLogEventActionChangeAbout%ChannelAdminLogEventActionChangeTitle(ChannelAdminLogEventActionChangeUsername(ChannelAdminLogEventActionChangeLocation*ChannelAdminLogEventActionChangeHistoryTTLZ
prev_value%ChannelAdminLogEventActionChangePhotoZ
prev_photo*ChannelAdminLogEventActionChangeStickerSetZprev_stickerset%ChannelAdminLogEventActionEditMessageZprev_message0ChannelAdminLogEventActionParticipantToggleAdmin.ChannelAdminLogEventActionParticipantToggleBanZprev_participant'ChannelAdminLogEventActionToggleInvites0ChannelAdminLogEventActionTogglePreHistoryHidden*ChannelAdminLogEventActionToggleSignatures	new_value'ChannelAdminLogEventActionDeleteMessagemessage-ChannelAdminLogEventActionDefaultBannedRightsZprev_banned_rights*ChannelAdminLogEventActionDiscardGroupCallcall.ChannelAdminLogEventActionExportedInviteDelete.ChannelAdminLogEventActionExportedInviteRevoke1ChannelAdminLogEventActionParticipantJoinByInviteZinvite,ChannelAdminLogEventActionExportedInviteEditZprev_inviter
   Zorir   r   r   old<   sP    zAdminLogEvent.oldc              
   C   s  | j j}t|tjtjtjtjtjtj	tj
tjfr8|jS t|tjrJ|jS t|tjr\|jS t|tjrn|jS t|tjtjfr|jS t|tjtjfr|jS t|tjr|jS t|tjr|jS t|tjr|jS t|tjtj f r|jS t|tj!r|j"S t|tj#r|j$S dS )z5
        The new value present in the event.
        N)%r   r   r   r   r   r   r   r   r   r   r   r   r    r   Z	new_photor   Znew_stickersetr   Znew_messager   r   Znew_participant+ChannelAdminLogEventActionParticipantInvite+ChannelAdminLogEventActionParticipantVolumeZparticipantr#   Znew_banned_rights"ChannelAdminLogEventActionStopPollr"   (ChannelAdminLogEventActionStartGroupCallr%   )ChannelAdminLogEventActionParticipantMute+ChannelAdminLogEventActionParticipantUnmute0ChannelAdminLogEventActionToggleGroupCallSettingZ
join_mutedr)   Z
new_inviter*   r   r   r   newj   sV    
zAdminLogEvent.newc                 C   s   t | jjtjS )z
        Whether the channel's about was changed or not.

        If `True`, `old` and `new` will be present as `str`.
        )r   r   r   r   r   r   r   r   r   changed_about   s    zAdminLogEvent.changed_aboutc                 C   s   t | jjtjS )z
        Whether the channel's title was changed or not.

        If `True`, `old` and `new` will be present as `str`.
        )r   r   r   r   r   r   r   r   r   changed_title   s    zAdminLogEvent.changed_titlec                 C   s   t | jjtjS )z
        Whether the channel's username was changed or not.

        If `True`, `old` and `new` will be present as `str`.
        )r   r   r   r   r   r   r   r   r   changed_username   s    zAdminLogEvent.changed_usernamec                 C   s   t | jjtjS )z
        Whether the channel's photo was changed or not.

        If `True`, `old` and `new` will be present as :tl:`Photo`.
        )r   r   r   r   r   r   r   r   r   changed_photo   s    zAdminLogEvent.changed_photoc                 C   s   t | jjtjS )z
        Whether the channel's sticker set was changed or not.

        If `True`, `old` and `new` will be present as :tl:`InputStickerSet`.
        )r   r   r   r   r   r   r   r   r   changed_sticker_set   s    z!AdminLogEvent.changed_sticker_setc                 C   s   t | jjtjS )z
        Whether a message in this channel was edited or not.

        If `True`, `old` and `new` will be present as
        `Message <telethon.tl.custom.message.Message>`.
        )r   r   r   r   r   r   r   r   r   changed_message   s    zAdminLogEvent.changed_messagec                 C   s   t | jjtjS )z
        Whether a message in this channel was deleted or not.

        If `True`, `old` will be present as
        `Message <telethon.tl.custom.message.Message>`.
        )r   r   r   r   r!   r   r   r   r   deleted_message   s    zAdminLogEvent.deleted_messagec                 C   s   t | jjtjS )z
        Whether the permissions for an admin in this channel
        changed or not.

        If `True`, `old` and `new` will be present as
        :tl:`ChannelParticipant`.
        )r   r   r   r   r   r   r   r   r   changed_admin   s    	zAdminLogEvent.changed_adminc                 C   s   t | jjtjS )z
        Whether a message in this channel was edited or not.

        If `True`, `old` and `new` will be present as
        :tl:`ChannelParticipant`.
        )r   r   r   r   r   r   r   r   r   changed_restrictions   s    z"AdminLogEvent.changed_restrictionsc                 C   s   t | jjtjS )z
        Whether the invites in the channel were toggled or not.

        If `True`, `old` and `new` will be present as `bool`.
        )r   r   r   r   r   r   r   r   r   changed_invites   s    zAdminLogEvent.changed_invitesc                 C   s   t | jjtjS )z
        Whether the location setting of the channel has changed or not.

        If `True`, `old` and `new` will be present as :tl:`ChannelLocation`.
        )r   r   r   r   r   r   r   r   r   changed_location  s    zAdminLogEvent.changed_locationc                 C   s   t | jjtjS )z]
        Whether `user` joined through the channel's
        public username or not.
        )r   r   r   r   Z)ChannelAdminLogEventActionParticipantJoinr   r   r   r   joined  s    zAdminLogEvent.joinedc                 C   s   t | jjtjS )z
        Whether a new user joined through an invite
        link to the channel or not.

        If `True`, `new` will be present as
        :tl:`ChannelParticipant`.
        )r   r   r   r   r,   r   r   r   r   joined_invite  s    	zAdminLogEvent.joined_invitec                 C   s   t | jjtjS )z9
        Whether `user` left the channel or not.
        )r   r   r   r   Z*ChannelAdminLogEventActionParticipantLeaver   r   r   r   left%  s    zAdminLogEvent.leftc                 C   s   t | jjtjS )z
        Whether hiding the previous message history for new members
        in the channel was toggled or not.

        If `True`, `old` and `new` will be present as `bool`.
        )r   r   r   r   r   r   r   r   r   changed_hide_history-  s    z"AdminLogEvent.changed_hide_historyc                 C   s   t | jjtjS )z
        Whether the message signatures in the channel were toggled
        or not.

        If `True`, `old` and `new` will be present as `bool`.
        )r   r   r   r   r   r   r   r   r   changed_signatures8  s    z AdminLogEvent.changed_signaturesc                 C   s   t | jjtjS )z
        Whether a new message in this channel was pinned or not.

        If `True`, `new` will be present as
        `Message <telethon.tl.custom.message.Message>`.
        )r   r   r   r   Z&ChannelAdminLogEventActionUpdatePinnedr   r   r   r   changed_pinC  s    zAdminLogEvent.changed_pinc                 C   s   t | jjtjS )z
        Whether the default banned rights were changed or not.

        If `True`, `old` and `new` will
        be present as :tl:`ChatBannedRights`.
        )r   r   r   r   r#   r   r   r   r   changed_default_banned_rightsN  s    z+AdminLogEvent.changed_default_banned_rightsc                 C   s   t | jjtjS )z
        Whether a poll was stopped or not.

        If `True`, `new` will be present as
        `Message <telethon.tl.custom.message.Message>`.
        )r   r   r   r   r.   r   r   r   r   stopped_pollY  s    zAdminLogEvent.stopped_pollc                 C   s   t | jjtjS )z}
        Whether a group call was started or not.

        If `True`, `new` will be present as :tl:`InputGroupCall`.
        )r   r   r   r   r/   r   r   r   r   started_group_calld  s    z AdminLogEvent.started_group_callc                 C   s   t | jjtjS )z}
        Whether a group call was started or not.

        If `True`, `old` will be present as :tl:`InputGroupCall`.
        )r   r   r   r   r$   r   r   r   r   discarded_group_calln  s    z"AdminLogEvent.discarded_group_callc                 C   s   t | jjtjS )z
        Whether a participant was muted in the ongoing group call or not.

        If `True`, `new` will be present as :tl:`GroupCallParticipant`.
        )r   r   r   r   r0   r   r   r   r   
user_mutedx  s    zAdminLogEvent.user_mutedc                 C   s   t | jjtjS )z
        Whether a participant was unmuted from the ongoing group call or not.

        If `True`, `new` will be present as :tl:`GroupCallParticipant`.
        )r   r   r   r   r1   r   r   r   r   user_unmutted  s    zAdminLogEvent.user_unmuttedc                 C   s   t | jjtjS )z
        Whether the group call settings were changed or not.

        If `True`, `new` will be `True` if new users are muted on join.
        )r   r   r   r   r2   r   r   r   r   changed_call_settings  s    z#AdminLogEvent.changed_call_settingsc                 C   s   t | jjtjS )a;  
        Whether the Time To Live of the message history has changed.

        Messages sent after this change will have a ``ttl_period`` in seconds
        indicating how long they should live for before being auto-deleted.

        If `True`, `old` will be the old TTL, and `new` the new TTL, in seconds.
        )r   r   r   r   r   r   r   r   r   changed_history_ttl  s    
z!AdminLogEvent.changed_history_ttlc                 C   s   t | jjtjS )z
        Whether the exported chat invite has been deleted.

        If `True`, `old` will be the deleted :tl:`ExportedChatInvite`.
        )r   r   r   r   r&   r   r   r   r   deleted_exported_invite  s    z%AdminLogEvent.deleted_exported_invitec                 C   s   t | jjtjS )z
        Whether the exported chat invite has been edited.

        If `True`, `old` and `new` will be the old and new
        :tl:`ExportedChatInvite`, respectively.
        )r   r   r   r   r)   r   r   r   r   edited_exported_invite  s    z$AdminLogEvent.edited_exported_invitec                 C   s   t | jjtjS )z
        Whether the exported chat invite has been revoked.

        If `True`, `old` will be the revoked :tl:`ExportedChatInvite`.
        )r   r   r   r   r'   r   r   r   r   revoked_exported_invite  s    z%AdminLogEvent.revoked_exported_invitec                 C   s   t | jjtjS )z
        Whether a new participant has joined with the use of an invite link.

        If `True`, `old` will be pre-existing (old) :tl:`ExportedChatInvite`
        used to join.
        )r   r   r   r   r(   r   r   r   r   joined_by_invite  s    zAdminLogEvent.joined_by_invitec                 C   s   t | jjtjS )z
        Whether a participant's volume in a call has been changed.

        If `True`, `new` will be the updated :tl:`GroupCallParticipant`.
        )r   r   r   r   r-   r   r   r   r   changed_user_volume  s    z!AdminLogEvent.changed_user_volumec                 C   s
   t | jS r   )strr   r   r   r   r   __str__  s    zAdminLogEvent.__str__c                 C   s
   | j  S r   )r   	stringifyr   r   r   r   rT     s    zAdminLogEvent.stringifyN),__name__
__module____qualname____doc__r   propertyr   r   r   r   r+   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rS   rT   r   r   r   r   r      s   




-
0
	
	
	
	
	






	
	













	
	
	
	
	

	


	


	r   N)tlr   utilsr   r   r   r   r   r   <module>   s   