U
    2Òtcï0  ã                   @   sL   d Z ddlmZmZmZmZ ddlmZmZ ddl	m
Z
 G dd„ deƒZdS )zNThis module contains an object that represents a Telegram ReplyKeyboardMarkup.é    )ÚAnyÚListÚUnionÚSequence)ÚKeyboardButtonÚReplyMarkup)ÚJSONDictc                
       sâ   e Zd ZdZdZdeeeeef   e	e	e	ee
dœdd„Zedœ‡ fd	d
„Zedeeef e	e	e	eed dœdd„ƒZedeeeef  e	e	e	eed dœdd„ƒZedeeeef  e	e	e	eed dœdd„ƒZedœdd„Z‡  ZS )ÚReplyKeyboardMarkupam
  This object represents a custom keyboard with reply options.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their the size of :attr:`keyboard` and all the buttons are equal.

    Example:
        A user requests to change the bot's language, bot replies to the request with a keyboard
        to select the new language. Other users in the group don't see the keyboard.

    Args:
        keyboard (List[List[:obj:`str` | :class:`telegram.KeyboardButton`]]): Array of button rows,
                each represented by an Array of :class:`telegram.KeyboardButton` objects.
        resize_keyboard (:obj:`bool`, optional): Requests clients to resize the keyboard vertically
            for optimal fit (e.g., make the keyboard smaller if there are just two rows of
            buttons). Defaults to :obj:`False`, in which case the custom keyboard is always of the
            same height as the app's standard keyboard.
        one_time_keyboard (:obj:`bool`, optional): Requests clients to hide the keyboard as soon as
            it's been used. The keyboard will still be available, but clients will automatically
            display the usual letter-keyboard in the chat - the user can press a special button in
            the input field to see the custom keyboard again. Defaults to :obj:`False`.
        selective (:obj:`bool`, optional): Use this parameter if you want to show the keyboard to
            specific users only. Targets:

            1) Users that are @mentioned in the :attr:`~telegram.Message.text` of the
               :class:`telegram.Message` object.
            2) If the bot's message is a reply (has ``reply_to_message_id``), sender of the
               original message.

            Defaults to :obj:`False`.

        input_field_placeholder (:obj:`str`, optional): The placeholder to be shown in the input
            field when the keyboard is active; 1-64 characters.

            .. versionadded:: 13.7

        **kwargs (:obj:`dict`): Arbitrary keyword arguments.

    Attributes:
        keyboard (List[List[:class:`telegram.KeyboardButton` | :obj:`str`]]): Array of button rows.
        resize_keyboard (:obj:`bool`): Optional. Requests clients to resize the keyboard.
        one_time_keyboard (:obj:`bool`): Optional. Requests clients to hide the keyboard as soon as
            it's been used.
        selective (:obj:`bool`): Optional. Show the keyboard to specific users only.
        input_field_placeholder (:obj:`str`): Optional. The placeholder shown in the input
            field when the reply is active.

            .. versionadded:: 13.7

    )Ú	selectiveÚkeyboardÚresize_keyboardÚone_time_keyboardÚinput_field_placeholderÚ	_id_attrsFN)r   r   r   r
   r   Ú_kwargsc           
      K   s€   g | _ |D ]B}g }|D ](}	t|	tƒr0| |	¡ q| t|	ƒ¡ q| j  |¡ q
t|ƒ| _t|ƒ| _t|ƒ| _|| _| j f| _	d S ©N)
r   Ú
isinstancer   ÚappendÚboolr   r   r
   r   r   )
Úselfr   r   r   r
   r   r   ÚrowÚ
button_rowÚbutton© r   ú@/tmp/pip-unpacked-wheel-2u9rcp5s/telegram/replykeyboardmarkup.pyÚ__init__W   s    




zReplyKeyboardMarkup.__init__)Úreturnc                    s:   t ƒ  ¡ }g |d< | jD ]}|d  dd„ |D ƒ¡ q|S )z,See :meth:`telegram.TelegramObject.to_dict`.r   c                 S   s   g | ]}|  ¡ ‘qS r   )Úto_dict©Ú.0r   r   r   r   Ú
<listcomp>y   s     z/ReplyKeyboardMarkup.to_dict.<locals>.<listcomp>)Úsuperr   r   r   )r   Údatar   ©Ú	__class__r   r   r   s   s
    

zReplyKeyboardMarkup.to_dict)r   r   r   r
   r   Úkwargsr   c                 K   s   | |ggf||||dœ|—ŽS )a®  Shortcut for::

            ReplyKeyboardMarkup([[button]], **kwargs)

        Return a ReplyKeyboardMarkup from a single KeyboardButton.

        Args:
            button (:class:`telegram.KeyboardButton` | :obj:`str`): The button to use in
                the markup.
            resize_keyboard (:obj:`bool`, optional): Requests clients to resize the keyboard
                vertically for optimal fit (e.g., make the keyboard smaller if there are just two
                rows of buttons). Defaults to :obj:`False`, in which case the custom keyboard is
                always of the same height as the app's standard keyboard.
            one_time_keyboard (:obj:`bool`, optional): Requests clients to hide the keyboard as
                soon as it's been used. The keyboard will still be available, but clients will
                automatically display the usual letter-keyboard in the chat - the user can press
                a special button in the input field to see the custom keyboard again.
                Defaults to :obj:`False`.
            selective (:obj:`bool`, optional): Use this parameter if you want to show the keyboard
                to specific users only. Targets:

                1) Users that are @mentioned in the text of the Message object.
                2) If the bot's message is a reply (has ``reply_to_message_id``), sender of the
                   original message.

                Defaults to :obj:`False`.

            input_field_placeholder (:obj:`str`): Optional. The placeholder shown in the input
                field when the reply is active.

                .. versionadded:: 13.7
            **kwargs (:obj:`dict`): Arbitrary keyword arguments.
        ©r   r   r
   r   r   )Úclsr   r   r   r
   r   r%   r   r   r   Úfrom_button|   s    +ÿûúzReplyKeyboardMarkup.from_button)r   r   r   r
   r   r%   r   c                 K   s   | |gf||||dœ|—ŽS )aÃ  Shortcut for::

            ReplyKeyboardMarkup([button_row], **kwargs)

        Return a ReplyKeyboardMarkup from a single row of KeyboardButtons.

        Args:
            button_row (List[:class:`telegram.KeyboardButton` | :obj:`str`]): The button to use in
                the markup.
            resize_keyboard (:obj:`bool`, optional): Requests clients to resize the keyboard
                vertically for optimal fit (e.g., make the keyboard smaller if there are just two
                rows of buttons). Defaults to :obj:`False`, in which case the custom keyboard is
                always of the same height as the app's standard keyboard.
            one_time_keyboard (:obj:`bool`, optional): Requests clients to hide the keyboard as
                soon as it's been used. The keyboard will still be available, but clients will
                automatically display the usual letter-keyboard in the chat - the user can press
                a special button in the input field to see the custom keyboard again.
                Defaults to :obj:`False`.
            selective (:obj:`bool`, optional): Use this parameter if you want to show the keyboard
                to specific users only. Targets:

                1) Users that are @mentioned in the text of the Message object.
                2) If the bot's message is a reply (has ``reply_to_message_id``), sender of the
                   original message.

                Defaults to :obj:`False`.

            input_field_placeholder (:obj:`str`): Optional. The placeholder shown in the input
                field when the reply is active.

                .. versionadded:: 13.7
            **kwargs (:obj:`dict`): Arbitrary keyword arguments.

        r&   r   )r'   r   r   r   r
   r   r%   r   r   r   Úfrom_row°   s    ,ÿûúzReplyKeyboardMarkup.from_row)Úbutton_columnr   r   r
   r   r%   r   c                 K   s(   dd„ |D ƒ}| |f||||dœ|—ŽS )aã  Shortcut for::

            ReplyKeyboardMarkup([[button] for button in button_column], **kwargs)

        Return a ReplyKeyboardMarkup from a single column of KeyboardButtons.

        Args:
            button_column (List[:class:`telegram.KeyboardButton` | :obj:`str`]): The button to use
                in the markup.
            resize_keyboard (:obj:`bool`, optional): Requests clients to resize the keyboard
                vertically for optimal fit (e.g., make the keyboard smaller if there are just two
                rows of buttons). Defaults to :obj:`False`, in which case the custom keyboard is
                always of the same height as the app's standard keyboard.
            one_time_keyboard (:obj:`bool`, optional): Requests clients to hide the keyboard as
                soon as it's been used. The keyboard will still be available, but clients will
                automatically display the usual letter-keyboard in the chat - the user can press
                a special button in the input field to see the custom keyboard again.
                Defaults to :obj:`False`.
            selective (:obj:`bool`, optional): Use this parameter if you want to show the keyboard
                to specific users only. Targets:

                1) Users that are @mentioned in the text of the Message object.
                2) If the bot's message is a reply (has ``reply_to_message_id``), sender of the
                   original message.

                Defaults to :obj:`False`.

            input_field_placeholder (:obj:`str`): Optional. The placeholder shown in the input
                field when the reply is active.

                .. versionadded:: 13.7
            **kwargs (:obj:`dict`): Arbitrary keyword arguments.

        c                 S   s   g | ]
}|g‘qS r   r   r   r   r   r   r      s     z3ReplyKeyboardMarkup.from_column.<locals>.<listcomp>r&   r   )r'   r*   r   r   r
   r   r%   Zbutton_gridr   r   r   Úfrom_columnå   s    ,ÿûúzReplyKeyboardMarkup.from_columnc                 C   s&   t tdd„ | jD ƒƒ| j| j| jfƒS )Nc                 s   s    | ]}t d d„ |D ƒƒV  qdS )c                 s   s   | ]
}|V  qd S r   r   r   r   r   r   Ú	<genexpr>  s     z9ReplyKeyboardMarkup.__hash__.<locals>.<genexpr>.<genexpr>N)Útuple)r   r   r   r   r   r,     s     z/ReplyKeyboardMarkup.__hash__.<locals>.<genexpr>)Úhashr-   r   r   r   r
   )r   r   r   r   Ú__hash__  s    üÿzReplyKeyboardMarkup.__hash__)FFFN)FFFN)FFFN)FFFN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r   Ústrr   r   r   r   r   r   ÚclassmethodÚobjectr(   r   r)   r+   Úintr/   Ú__classcell__r   r   r#   r   r	      st   2    úù	    ú
ø3    úø4    úø5r	   N)r3   Útypingr   r   r   r   Ztelegramr   r   Ztelegram.utils.typesr   r	   r   r   r   r   Ú<module>   s   