o
    Xzj   ã                   @   s.   d dl mZmZ ddl mZ G dd„ dƒZdS )é   )ÚtypesÚ	functionsé   )Úutilsc                   @   s¸   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZd$ddœdd„Zedd„ ƒZe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!„Zd"d#„ ZdS )&ÚInlineResulta'  
    Custom class that encapsulates a bot inline result providing
    an abstraction to easily access some commonly needed features
    (such as clicking a result to select it).

    Attributes:

        result (:tl:`BotInlineResult`):
            The original :tl:`BotInlineResult` object.
    ÚarticleÚphotoÚgifÚvideoÚ	mpeg4_gifÚaudioÚdocumentÚlocationÚvenueÚcontactÚgameN)Úentityc                C   s   || _ || _|| _|| _d S ©N)Ú_clientÚresultÚ	_query_idÚ_entity)ÚselfÚclientÚoriginalÚquery_idr   © r   úZ/var/www/kodo/tsheker/venv/lib/python3.10/site-packages/telethon/tl/custom/inlineresult.pyÚ__init__    s   
zInlineResult.__init__c                 C   ó   | j jS )a™  
        The always-present type of this result. It will be one of:
        ``'article'``, ``'photo'``, ``'gif'``, ``'mpeg4_gif'``, ``'video'``,
        ``'audio'``, ``'voice'``, ``'document'``, ``'location'``, ``'venue'``,
        ``'contact'``, ``'game'``.

        You can access all of these constants through `InlineResult`,
        such as `InlineResult.ARTICLE`, `InlineResult.VIDEO_GIF`, etc.
        )r   Útype©r   r   r   r   r    &   s   zInlineResult.typec                 C   r   )zz
        The always-present :tl:`BotInlineMessage` that
        will be sent if `click` is called on this result.
        )r   Úsend_messager!   r   r   r   Úmessage3   s   zInlineResult.messagec                 C   r   )zE
        The title for this inline result. It may be `None`.
        )r   Útitler!   r   r   r   r$   ;   ó   zInlineResult.titlec                 C   r   )zK
        The description for this inline result. It may be `None`.
        )r   Údescriptionr!   r   r   r   r&   B   r%   zInlineResult.descriptionc                 C   s   t | jtjƒr| jjS dS )zÃ
        The URL present in this inline results. If you want to "click"
        this URL to open it in your browser, you should use Python's
        `webbrowser.open(url)` for such task.
        N)Ú
isinstancer   r   ÚBotInlineResultÚurlr!   r   r   r   r)   I   s   ÿzInlineResult.urlc                 C   ó0   t | jtjƒr| jjS t | jtjƒr| jjS dS )z�
        Returns either the :tl:`WebDocument` thumbnail for
        normal results or the :tl:`Photo` for media results.
        N)r'   r   r   r(   ÚthumbÚBotInlineMediaResultr   r!   r   r   r   r   S   ó
   ÿzInlineResult.photoc                 C   r*   )z‚
        Returns either the :tl:`WebDocument` content for
        normal results or the :tl:`Document` for media results.
        N)r'   r   r   r(   Úcontentr,   r   r!   r   r   r   r   ^   r-   zInlineResult.documentFc           
      Ã   s´   �|r| j  |¡I dH }n| jr| j}ntdƒ‚|r'| j  ||¡I dH \}}n|du r-dnt |¡}tjj	|| j
| jj|||||du rEdnt |¡d�}	| j  |	|   |	¡I dH |¡S )aŒ  
        Clicks this result and sends the associated `message`.

        Args:
            entity (`entity`):
                The entity to which the message of this result should be sent.

            reply_to (`int` | `Message <telethon.tl.custom.message.Message>`, optional):
                If present, the sent message will reply to this ID or message.

            comment_to (`int` | `Message <telethon.tl.custom.message.Message>`, optional):
                Similar to ``reply_to``, but replies in the linked group of a
                broadcast channel instead (effectively leaving a "comment to"
                the specified message).

            silent (`bool`, optional):
                Whether the message should notify people with sound or not.
                Defaults to `False` (send with a notification sound unless
                the person has the chat muted). Set it to `True` to alter
                this behaviour.

            clear_draft (`bool`, optional):
                Whether the draft should be removed after sending the
                message from this result or not. Defaults to `False`.

            hide_via (`bool`, optional):
                Whether the "via @bot" should be hidden or not.
                Only works with certain bots (like @bing or @gif).

            background (`bool`, optional):
                Whether the message should be send in background.

        Nz>You must provide the entity where the result should be sent to)Úpeerr   ÚidÚsilentÚ
backgroundÚclear_draftÚhide_viaÚreply_to)r   Úget_input_entityr   Ú
ValueErrorÚ_get_comment_datar   Úget_message_idr   ÚmessagesÚSendInlineBotResultRequestr   r   r0   r   ÚInputReplyToMessageÚ_get_response_message)
r   r   r5   Ú
comment_tor1   r3   r4   r2   Úreply_idÚreqr   r   r   Úclicki   s,   €$ø
ÿzInlineResult.clickc                 Ï   s:   �| j s| jr| jj| j p| jg|¢R i |¤ŽI dH S dS )a  
        Downloads the media in this result (if there is a document, the
        document will be downloaded; otherwise, the photo will if present).

        This is a wrapper around `client.download_media
        <telethon.client.downloads.DownloadMethods.download_media>`.
        N)r   r   r   Údownload_media)r   ÚargsÚkwargsr   r   r   rB   ¦   s   €
ÿÿÿÿzInlineResult.download_mediar   )NNNFFFN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚARTICLEÚPHOTOÚGIFÚVIDEOÚ	VIDEO_GIFÚAUDIOÚDOCUMENTÚLOCATIONÚVENUEÚCONTACTÚGAMEr   Úpropertyr    r#   r$   r&   r)   r   r   rA   rB   r   r   r   r   r      sB    




	




þ=r   N)Ú r   r   r   r   r   r   r   r   Ú<module>   s    