U
    h                     @   s:   d dl Z ddlmZmZ ddlmZmZ G dd dZdS )    N   )utilshints)typescustomc                   @   s$   e Zd ZeddeddddZdS )	ButtonMethodsFz!typing.Optional[hints.MarkupLike]z&typing.Optional[types.TypeReplyMarkup])buttonsinline_onlyreturnc                 C   s  | dkrdS z| j dkr| W S W n tk
r4   Y nX t| sJ| gg} n| r\t| d sb| g} d}d}d}d}d}g }| D ]}g }	|D ]}
t|
tjr|
jdk	r|
j}|
jdk	r|
j}|
j	dk	r|
j	}|
j
}
nt|
tjr|
j
}
tj|
}||O }|| O }|
j dkr|	|
 q|	r~|t|	 q~|rD|rDtdn*||kr^|r^tdn|rnt|S tj||||dS )	a  
        Builds a :tl:`ReplyInlineMarkup` or :tl:`ReplyKeyboardMarkup` for
        the given buttons.

        Does nothing if either no buttons are provided or the provided
        argument is already a reply markup.

        You should consider using this method if you are going to reuse
        the markup very often. Otherwise, it is not necessary.

        This method is **not** asynchronous (don't use ``await`` on it).

        Arguments
            buttons (`hints.MarkupLike`):
                The button, list of buttons, array of buttons or markup
                to convert into a markup.

            inline_only (`bool`, optional):
                Whether the buttons **must** be inline buttons only or not.

        Example
            .. code-block:: python

                from telethon import Button

                markup = client.build_reply_markup(Button.inline('hi'))
                # later
                await client.send_message(chat, 'click me', buttons=markup)
        Nl   E r   Fitz&You cannot use non-inline buttons herez)You cannot mix inline with normal buttons)resize
single_use	selective)ZSUBCLASS_OF_IDAttributeErrorr   Zis_list_like
isinstancer   ZButtonr   r   r   buttonZMessageButtonZ
_is_inlineappendr   ZKeyboardButtonRow
ValueErrorZReplyInlineMarkupZReplyKeyboardMarkup)r   r	   Z	is_inline	is_normalr   r   r   Zrowsrowcurrentr   inline r   ;/tmp/pip-unpacked-wheel-c81u5j2r/telethon/client/buttons.pybuild_reply_markup   sb    !











   z ButtonMethods.build_reply_markupN)F)__name__
__module____qualname__staticmethodboolr   r   r   r   r   r      s     r   )typing r   r   tlr   r   r   r   r   r   r   <module>   s   