o
    Xzjƒ  ã                   @   sj   d dl mZmZ ddl mZ ddlmZ zddlZW n	 ey#   Y nw ddl	Z	ddl
Z
G dd„ dƒZdS )	é   )ÚtypesÚ	functionsé   )Úpassword)ÚBotResponseTimeoutErroré    Nc                   @   sf   e Zd ZdZdd„ Zedd„ ƒZedd„ ƒZedd	„ ƒZed
d„ ƒZ	edd„ ƒZ
ddddœdd„ZdS )ÚMessageButtona+  
    .. note::

        `Message.buttons <telethon.tl.custom.message.Message.buttons>`
        are instances of this type. If you want to **define** a reply
        markup for e.g. sending messages, refer to `Button
        <telethon.tl.custom.button.Button>` instead.

    Custom class that encapsulates a message button providing
    an abstraction to easily access some commonly needed features
    (such as clicking the button itself).

    Attributes:

        button (:tl:`KeyboardButton`):
            The original :tl:`KeyboardButton` object.
    c                 C   s"   || _ || _|| _|| _|| _d S )N)ÚbuttonÚ_botÚ_chatÚ_msg_idÚ_client)ÚselfÚclientÚoriginalÚchatÚbotÚmsg_id© r   ú[/var/www/kodo/tsheker/venv/lib/python3.10/site-packages/telethon/tl/custom/messagebutton.pyÚ__init__   s
   
zMessageButton.__init__c                 C   s   | j S )zz
        Returns the `telethon.client.telegramclient.TelegramClient`
        instance that created this instance.
        )r   ©r   r   r   r   r   %   s   zMessageButton.clientc                 C   s   | j jS )zThe text string of the button.)r	   Útextr   r   r   r   r   -   s   zMessageButton.textc                 C   ó   t | jtjƒr| jjS dS )z:The `bytes` data for :tl:`KeyboardButtonCallback` objects.N)Ú
isinstancer	   r   ÚKeyboardButtonCallbackÚdatar   r   r   r   r   2   ó   ÿzMessageButton.datac                 C   r   )z=The query `str` for :tl:`KeyboardButtonSwitchInline` objects.N)r   r	   r   ÚKeyboardButtonSwitchInlineÚqueryr   r   r   r   Úinline_query8   r   zMessageButton.inline_queryc                 C   r   )z2The url `str` for :tl:`KeyboardButtonUrl` objects.N)r   r	   r   ÚKeyboardButtonUrlÚurlr   r   r   r   r"   >   r   zMessageButton.urlN)r   Úopen_urlc          
      Ã   s<  �t | jtjƒr| jj| j| jjdd�I dH S t | jtjƒrU|dur3|  t	j
 ¡ ¡I dH }t ||¡}t	jj| j| j| jj|d�}z	|  |¡I dH W S  tyT   Y dS w t | jtjƒro|  t	jj| j| j| jjd�¡I dH S t | jtjƒrˆ|r„dtjv r„t | jj¡S | jjS t | jtjƒr®t	jj| j| jdd�}z	|  |¡I dH W S  ty­   Y dS w t | jtjƒrí|s»tdƒ‚|dksÄt |t ƒrâ| j !¡ I dH }tj"|dkrÕ|j#n||j$pÚd	|j%pÞd	d	d
�}| j &| j|¡I dH S t | jtj'ƒ�r|sûtdƒ‚t |t(t)fƒ�r|\}}	t *tj+|	|d�¡}| j &| j|¡I dH S dS )aó  
        Emulates the behaviour of clicking this button.

        If it's a normal :tl:`KeyboardButton` with text, a message will be
        sent, and the sent `Message <telethon.tl.custom.message.Message>` returned.

        If it's an inline :tl:`KeyboardButtonCallback` with text and data,
        it will be "clicked" and the :tl:`BotCallbackAnswer` returned.

        If it's an inline :tl:`KeyboardButtonSwitchInline` button, the
        :tl:`StartBotRequest` will be invoked and the resulting updates
        returned.

        If it's a :tl:`KeyboardButtonUrl`, the ``URL`` of the button will
        be returned. If you pass ``open_url=True`` the URL of the button will
        be passed to ``webbrowser.open`` and return `True` on success.

        If it's a :tl:`KeyboardButtonRequestPhone`, you must indicate that you
        want to ``share_phone=True`` in order to share it. Sharing it is not a
        default because it is a privacy concern and could happen accidentally.

        You may also use ``share_phone=phone`` to share a specific number, in
        which case either `str` or :tl:`InputMediaContact` should be used.

        If it's a :tl:`KeyboardButtonRequestGeoLocation`, you must pass a
        tuple in ``share_geo=(longitude, latitude)``. Note that Telegram seems
        to have some heuristics to determine impossible locations, so changing
        this value a lot quickly may not work as expected. You may also pass a
        :tl:`InputGeoPoint` if you find the order confusing.
        N)Ú
parse_mode)Úpeerr   r   r   )r   r%   Ústart_paramÚ
webbrowserT)r%   r   Úgamez5cannot click on phone buttons unless share_phone=TrueÚ )Úphone_numberÚ
first_nameÚ	last_nameÚvcardzBcannot click on geo buttons unless share_geo=(longitude, latitude))ÚlatÚlong),r   r	   r   ÚKeyboardButtonr   Úsend_messager   r   r   r   ÚaccountÚGetPasswordRequestÚpwd_modÚcompute_checkÚmessagesÚGetBotCallbackAnswerRequestr   r   r   r   ÚStartBotRequestr
   r   r!   ÚsysÚmodulesr'   Úopenr"   ÚKeyboardButtonGameÚKeyboardButtonRequestPhoneÚ
ValueErrorÚstrÚget_meÚInputMediaContactÚphoner+   r,   Ú	send_fileÚ KeyboardButtonRequestGeoLocationÚtupleÚlistÚInputMediaGeoPointÚInputGeoPoint)
r   Úshare_phoneÚ	share_geor   r#   ÚpwdÚreqÚmer/   r.   r   r   r   ÚclickD   sp   €ÿþÿ
ÿ

ÿÿüøzMessageButton.click)NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr   r   r   r    r"   rN   r   r   r   r   r      s    




r   )r)   r   r   r   r4   Úerrorsr   r'   ÚModuleNotFoundErrorr9   Úosr   r   r   r   r   Ú<module>   s    ÿ