U
    h
                     @   s(   d dl Z ddlmZ G dd deZdS )    N   )InlineResultc                       sF   e Zd ZdZdd fdd
Zdd Zdd	 Zd
d Zdd Z  Z	S )InlineResultsaj  
    Custom class that encapsulates :tl:`BotResults` providing
    an abstraction to easily access some commonly needed features
    (such as clicking one of the results to select it)

    Note that this is a list of `InlineResult
    <telethon.tl.custom.inlineresult.InlineResult>`
    so you can iterate over it or use indices to
    access its elements. In addition, it has some
    attributes.

    Attributes:
        result (:tl:`BotResults`):
            The original :tl:`BotResults` object.

        query_id (`int`):
            The random ID that identifies this query.

        cache_time (`int`):
            For how long the results should be considered
            valid. You can call `results_valid` at any
            moment to determine if the results are still
            valid or not.

        users (:tl:`User`):
            The users present in this inline query.

        gallery (`bool`):
            Whether these results should be presented
            in a grid (as a gallery of images) or not.

        next_offset (`str`, optional):
            The string to be used as an offset to get
            the next chunk of results, if any.

        switch_pm (:tl:`InlineBotSwitchPM`, optional):
            If presents, the results should show a button to
            switch to a private conversation with the bot using
            the text in this object.
    Nentityc                   sn   t   fddjD  | _j| _j| _t | j | _j| _t	j
| _
j| _j| _d S )Nc                 3   s    | ]}t  |jd V  qdS )r   N)r   query_id.0xclientr   original D/tmp/pip-unpacked-wheel-c81u5j2r/telethon/tl/custom/inlineresults.py	<genexpr>0   s   z)InlineResults.__init__.<locals>.<genexpr>)super__init__resultsresultr   
cache_timetime_valid_untilusersboolgallerynext_offset	switch_pm)selfr   r   r   	__class__r   r   r   /   s    zInlineResults.__init__c                 C   s   t   | jk S )z}
        Returns `True` if the cache time has not expired
        yet and the results can still be considered valid.
        )r   r   r   r   r   r   results_valid<   s    zInlineResults.results_validc              	      s6   d d fdd| D | j| j| j| j| j| jS )NzT[{}, query_id={}, cache_time={}, users={}, gallery={}, next_offset={}, switch_pm={}]z, c                 3   s   | ]} |V  qd S Nr   r   item_functionr   r   r   F   s     z(InlineResults._to_str.<locals>.<genexpr>)formatjoinr   r   r   r   r   r   )r   r$   r   r#   r   _to_strC   s    zInlineResults._to_strc                 C   s
   |  tS r"   )r'   strr    r   r   r   __str__O   s    zInlineResults.__str__c                 C   s
   |  tS r"   )r'   reprr    r   r   r   __repr__R   s    zInlineResults.__repr__)
__name__
__module____qualname____doc__r   r!   r'   r)   r+   __classcell__r   r   r   r   r      s   (r   )r   Zinlineresultr   listr   r   r   r   r   <module>   s   