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dddZdS )ButtonMethodsz!typing.Optional[hints.MarkupLike]z&typing.Optional[types.TypeReplyMarkup])buttons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}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
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|rn|rntdn|r~t|S tj||||||dS )aq  
        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.

        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 mix inline with normal buttons)rowsresize
single_use	selective
persistentplaceholder)ZSUBCLASS_OF_IDAttributeErrorr   Zis_list_like
isinstancer   ZButtonr   r   r   r   r   buttonZMessageButtonZ
_is_inlineappendr   ZKeyboardButtonRow
ValueErrorZReplyInlineMarkupZReplyKeyboardMarkup)r   Z	is_inline	is_normalr   r   r   r   r   r
   rowcurrentr   inline r   ;/tmp/pip-unpacked-wheel-t5wbaijj/telethon/client/buttons.pybuild_reply_markup   sn    












z ButtonMethods.build_reply_markupN)__name__
__module____qualname__staticmethodr   r   r   r   r   r      s   r   )typing r   r   tlr   r   r   r   r   r   r   <module>   s   