U
    2tc                     @   s   d Z ddlZddlmZmZmZ ddlmZmZm	Z	m
Z
 ddlmZmZmZ ddlmZmZ erlddlmZ G dd	 d	eZdS )
zJThis module contains an object that represents a Telegram ChatJoinRequest.    N)TYPE_CHECKINGAnyOptional)TelegramObjectUserChatChatInviteLink)from_timestampto_timestampDEFAULT_NONE)JSONDictODVInput)Botc                	       s   e Zd ZdZdZdeeejee	de
dddZeee ded  dd	d
Zed fddZedfee eedddZedfee eedddZ  ZS )ChatJoinRequestu  This object represents a join request sent to a chat.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`chat`, :attr:`from_user` and :attr:`date` are equal.

    Note:
        Since Bot API 5.5, bots are allowed to contact users who sent a join request to a chat
        where the bot is an administrator with the
        :attr:`~telegram.ChatMemberAdministrator.can_invite_users` administrator right – even if
        the user never interacted with the bot before.

    .. versionadded:: 13.8

    Args:
        chat (:class:`telegram.Chat`): Chat to which the request was sent.
        from_user (:class:`telegram.User`): User that sent the join request.
        date (:class:`datetime.datetime`): Date the request was sent.
        bio (:obj:`str`, optional): Bio of the user.
        invite_link (:class:`telegram.ChatInviteLink`, optional): Chat invite link that was used
            by the user to send the join request.
        bot (:class:`telegram.Bot`, optional): The Bot to use for instance methods.

    Attributes:
        chat (:class:`telegram.Chat`): Chat to which the request was sent.
        from_user (:class:`telegram.User`): User that sent the join request.
        date (:class:`datetime.datetime`): Date the request was sent.
        bio (:obj:`str`): Optional. Bio of the user.
        invite_link (:class:`telegram.ChatInviteLink`): Optional. Chat invite link that was used
            by the user to send the join request.

    chat	from_userdatebioinvite_linkbotZ	_id_attrsNr   )r   r   r   r   r   r   _kwargsc                 K   s:   || _ || _|| _|| _|| _|| _| j | j| jf| _d S )Nr   )selfr   r   r   r   r   r   r    r   </tmp/pip-unpacked-wheel-2u9rcp5s/telegram/chatjoinrequest.py__init__J   s    zChatJoinRequest.__init__)datar   returnc                 C   sz   |  |}|sdS t|d||d< t|d||d< t|dd|d< t|d||d< | f d|i|S )z,See :meth:`telegram.TelegramObject.de_json`.Nr   fromr   r   r   r   )Z_parse_datar   de_jsongetr   r	   r   )clsr   r   r   r   r   r   `   s    
zChatJoinRequest.de_json)r   c                    s   t   }t| j|d< |S )z,See :meth:`telegram.TelegramObject.to_dict`.r   )superto_dictr
   r   )r   r   	__class__r   r   r#   o   s    
zChatJoinRequest.to_dict)timeout
api_kwargsr   c                 C   s   | j j| jj| jj||dS )ah  Shortcut for::

            bot.approve_chat_join_request(chat_id=update.effective_chat.id,
            user_id=update.effective_user.id, *args, **kwargs)

        For the documentation of the arguments, please see
        :meth:`telegram.Bot.approve_chat_join_request`.

        Returns:
            :obj:`bool`: On success, :obj:`True` is returned.

        Zchat_idZuser_idr&   r'   )r   Zapprove_chat_join_requestr   idr   r   r&   r'   r   r   r   approvew   s       zChatJoinRequest.approvec                 C   s   | j j| jj| jj||dS )ah  Shortcut for::

            bot.decline_chat_join_request(chat_id=update.effective_chat.id,
            user_id=update.effective_user.id, *args, **kwargs)

        For the documentation of the arguments, please see
        :meth:`telegram.Bot.decline_chat_join_request`.

        Returns:
            :obj:`bool`: On success, :obj:`True` is returned.

        r(   )r   Zdecline_chat_join_requestr   r)   r   r*   r   r   r   decline   s       zChatJoinRequest.decline)NNN)__name__
__module____qualname____doc__	__slots__r   r   datetimestrr   r   r   classmethodr   r   r   r#   r   r   floatboolr+   r,   __classcell__r   r   r$   r   r      s>       
r   )r0   r2   typingr   r   r   Ztelegramr   r   r   r   Ztelegram.utils.helpersr	   r
   r   Ztelegram.utils.typesr   r   r   r   r   r   r   r   <module>   s   