U
    ;g                     @   sN   d dl m Z  d dlmZ d dlZd dlmZmZ d dlmZ G dd dZdS )    )datetime)UnionN)rawutils)typesc                   @   sB   e Zd Ze fdeeef eeef eede	f dddZ
dS )BanChatMemberzpyrogram.Clientztypes.Message)selfchat_iduser_id
until_datereturnc                    s   |  |I dH }|  |I dH }t|tjjrp| tjjj||tjj	t
|ddddddddd	dI dH }n"| tjjjt||dI dH }|jD ]P}t|tjjtjjfrtj| |jdd |jD dd |jD I dH   S qdS )	a  Ban a user from a group, a supergroup or a channel.
        In the case of supergroups and channels, the user will not be able to return to the group on their own using
        invite links, etc., unless unbanned first. You must be an administrator in the chat for this to work and must
        have the appropriate admin rights.

        Note:
            In regular groups (non-supergroups), this method will only work if the "All Members Are Admins" setting is
            off in the target group. Otherwise members may only be removed by the group's creator or by the member
            that added them.

        .. include:: /_includes/usable-by/users-bots.rst

        Parameters:
            chat_id (``int`` | ``str``):
                Unique identifier (int) or username (str) of the target chat.

            user_id (``int`` | ``str``):
                Unique identifier (int) or username (str) of the target user.
                For a contact that exists in your Telegram address book you can use his phone number (str).

            until_date (:py:obj:`~datetime.datetime`, *optional*):
                Date when the user will be unbanned.
                If user is banned for more than 366 days or less than 30 seconds from the current time they are
                considered to be banned forever. Defaults to epoch (ban forever).

        Returns:
            :obj:`~pyrogram.types.Message` | ``bool``: On success, a service message will be returned (when applicable),
            otherwise, in case a message object couldn't be returned, True is returned.

        Example:
            .. code-block:: python

                from datetime import datetime, timedelta

                # Ban chat member forever
                await app.ban_chat_member(chat_id, user_id)

                # Ban chat member and automatically unban after 24h
                await app.ban_chat_member(chat_id, user_id, datetime.now() + timedelta(days=1))
        NT)	r   Zview_messagesZsend_messagesZ
send_mediaZsend_stickersZ	send_gifsZ
send_gamesZsend_inlineZembed_links)ZchannelZparticipantZbanned_rights)r	   r
   c                 S   s   i | ]}|j |qS  id.0ir   r   f/opt/bot/vods_filmes/script/venv/lib/python3.8/site-packages/pyrogram/methods/chats/ban_chat_member.py
<dictcomp>k   s      z1BanChatMember.ban_chat_member.<locals>.<dictcomp>c                 S   s   i | ]}|j |qS r   r   r   r   r   r   r   l   s      )Zresolve_peer
isinstancer   r   ZInputPeerChannelZinvokeZ	functionsZchannelsZ
EditBannedZChatBannedRightsr   Zdatetime_to_timestampmessagesZDeleteChatUserabsZupdatesZUpdateNewMessageZUpdateNewChannelMessageMessage_parsemessageZusersZchats)r   r	   r
   r   Z	chat_peerZ	user_peerrr   r   r   r   ban_chat_member   sF    .

 zBanChatMember.ban_chat_memberN)__name__
__module____qualname__r   Zzero_datetimer   intstrr   boolr   r   r   r   r   r      s   


r   )r   typingr   Zpyrogramr   r   r   r   r   r   r   r   <module>   s
   