3
uQh                 @   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 y| j dkr| S W n tk
r2   Y nX tj| sH| gg} n|  s^tj| d  rd| g} d}d}d}d}d}g }x| D ]}g }	x|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j|
}||O }|| O }|
j dkr|	j|
 qW |	r|jtj|	 qW |rN|rNtdn*||krh|rhtdn|rxtj|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-build-2nz6shyl/telethon/telethon/client/buttons.pybuild_reply_markup   sZ    !












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   