U
    dd#                     @   s   d Z ddlmZmZ ddlmZ ddlmZmZ ddl	m
Z
 ddlmZ ddlmZ ddlmZ dd	lmZ er|dd
lmZ G dd de
ZdS )zIThis module contains an object that represents a Telegram KeyboardButton.    )TYPE_CHECKINGOptional)KeyboardButtonPollType)KeyboardButtonRequestChatKeyboardButtonRequestUser)TelegramObject)JSONDict)warn)
WebAppInfo)PTBDeprecationWarning)Botc                       s   e Zd ZdZdZdddeeeeee	e
ed fddZeed fd	d
Zed fddZeee ded  d fddZ  ZS )KeyboardButtona  
    This object represents one button of the reply keyboard. For simple text buttons, :obj:`str`
    can be used instead of this object to specify text of the button.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`text`, :attr:`request_contact`, :attr:`request_location`,
    :attr:`request_poll`, :attr:`web_app`, :attr:`request_user` and :attr:`request_chat` are equal.

    Note:
        * Optional fields are mutually exclusive.
        * :attr:`request_contact` and :attr:`request_location` options will only work in Telegram
          versions released after 9 April, 2016. Older clients will display unsupported message.
        * :attr:`request_poll` option will only work in Telegram versions released after 23
          January, 2020. Older clients will display unsupported message.
        * :attr:`web_app` option will only work in Telegram versions released after 16 April, 2022.
          Older clients will display unsupported message.
        * :attr:`request_user` and :attr:`request_chat` options will only work in Telegram
          versions released after 3 February, 2023. Older clients will display unsupported
          message.

    .. versionchanged:: 20.0
       :attr:`web_app` is considered as well when comparing objects of this type in terms of
       equality.
    .. deprecated:: 20.1
       :paramref:`request_user` and :paramref:`request_chat` will be considered as well when
       comparing objects of this type in terms of equality in V21.

    Args:
        text (:obj:`str`): Text of the button. If none of the optional fields are used, it will be
            sent to the bot as a message when the button is pressed.
        request_contact (:obj:`bool`, optional): If :obj:`True`, the user's phone number will be
            sent as a contact when the button is pressed. Available in private chats only.
        request_location (:obj:`bool`, optional): If :obj:`True`, the user's current location will
            be sent when the button is pressed. Available in private chats only.
        request_poll (:class:`~telegram.KeyboardButtonPollType`, optional): If specified, the user
            will be asked to create a poll and send it to the bot when the button is pressed.
            Available in private chats only.
        web_app (:class:`~telegram.WebAppInfo`, optional): If specified, the described `Web App
            <https://core.telegram.org/bots/webapps>`_ will be launched when the button is pressed.
            The Web App will be able to send a :attr:`Message.web_app_data` service message.
            Available in private chats only.

            .. versionadded:: 20.0
        request_user (:class:`KeyboardButtonRequestUser`, optional): If specified, pressing the
            button will open a list of suitable users. Tapping on any user will send its
            identifier to the bot in a :attr:`telegram.Message.user_shared` service message.
            Available in private chats only.

            .. versionadded:: 20.1
        request_chat (:class:`KeyboardButtonRequestChat`, optional): If specified, pressing the
            button will open a list of suitable chats. Tapping on a chat will send its
            identifier to the bot in a :attr:`telegram.Message.chat_shared` service message.
            Available in private chats only.

            .. versionadded:: 20.1
    Attributes:
        text (:obj:`str`): Text of the button. If none of the optional fields are used, it will be
            sent to the bot as a message when the button is pressed.
        request_contact (:obj:`bool`): Optional. If :obj:`True`, the user's phone number will be
            sent as a contact when the button is pressed. Available in private chats only.
        request_location (:obj:`bool`): Optional. If :obj:`True`, the user's current location will
            be sent when the button is pressed. Available in private chats only.
        request_poll (:class:`~telegram.KeyboardButtonPollType`): Optional. If specified,
            the user will be asked to create a poll and send it to the bot when the button is
            pressed. Available in private chats only.
        web_app (:class:`~telegram.WebAppInfo`): Optional. If specified, the described `Web App
            <https://core.telegram.org/bots/webapps>`_ will be launched when the button is pressed.
            The Web App will be able to send a :attr:`Message.web_app_data` service message.
            Available in private chats only.

            .. versionadded:: 20.0
        request_user (:class:`KeyboardButtonRequestUser`): Optional. If specified, pressing the
            button will open a list of suitable users. Tapping on any user will send its
            identifier to the bot in a :attr:`telegram.Message.user_shared` service message.
            Available in private chats only.

            .. versionadded:: 20.1
        request_chat (:class:`KeyboardButtonRequestChat`): Optional. If specified, pressing the
            button will open a list of suitable chats. Tapping on a chat will send its
            identifier to the bot in a :attr:`telegram.Message.chat_shared` service message.
            Available in private chats only.

            .. versionadded:: 20.1
    )request_locationrequest_contactrequest_polltextweb_apprequest_userrequest_chatN
api_kwargs)r   r   r   r   r   r   r   r   c          	         s^   t  j|d || _|| _|| _|| _|| _|| _|| _| j| j| j| j| jf| _	| 
  d S )Nr   )super__init__r   r   r   r   r   r   r   Z	_id_attrsZ_freeze)	selfr   r   r   r   r   r   r   r   	__class__ </tmp/pip-unpacked-wheel-e3anp165/telegram/_keyboardbutton.pyr      s    zKeyboardButton.__init__)otherreturnc                    s   t dtdd t |S )NzdIn v21, granular media settings will be considered as well when comparing ChatPermissions instances.   )
stacklevel)r	   r   r   __eq__)r   r   r   r   r   r"      s    zKeyboardButton.__eq__)r   c                    s
   t   S )N)r   __hash__)r   r   r   r   r#      s    zKeyboardButton.__hash__r   )databotr   c                    sz   |  |}|sdS t|d||d< t|d||d< t|d||d< t|d||d< t j||dS )z,See :meth:`telegram.TelegramObject.de_json`.Nr   r   r   r   )r$   r%   )Z_parse_datar   de_jsongetr   r   r
   r   )clsr$   r%   r   r   r   r&      s    
zKeyboardButton.de_json)NNNNNN)__name__
__module____qualname____doc__	__slots__strboolr   r
   r   r   r   r   objectr"   intr#   classmethodr   r&   __classcell__r   r   r   r   r   #   s0   U      
!	r   N)r,   typingr   r   Z telegram._keyboardbuttonpolltyper   Ztelegram._keyboardbuttonrequestr   r   Ztelegram._telegramobjectr   Ztelegram._utils.typesr   Ztelegram._utils.warningsr	   Ztelegram._webappinfor
   Ztelegram.warningsr   Ztelegramr   r   r   r   r   r   <module>   s   