U
    g$                     @   s   d Z ddlmZmZmZmZmZmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ ddlmZ ddlmZ dd	lmZmZ erdd
lmZmZ G dd deZdS )zFThis module contains an object that represents a Telegram InlineQuery.    )TYPE_CHECKINGCallableFinalOptionalSequenceUnion)	constants)Location)InlineQueryResultsButton)TelegramObject)User)DEFAULT_NONE)JSONDictODVInput)BotInlineQueryResultc                       sX  e Zd ZU dZdZdddeeeeee ee ee	 d fddZ
edee	 ed ed  d	 fd
dZdddeeeeddeed eegeed  f f ee ee ee ee ee eee ee ee ee ee	 edddZejjZee ed< ejjZee ed< ejjZee ed< ejjZee ed< ejj Z ee ed<   Z!S )InlineQueryab  
    This object represents an incoming inline query. When the user sends an empty query, your bot
    could return some default or trending results.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`id` is equal.

    .. figure:: https://core.telegram.org/file/464001466/10e4a/r4FKyQ7gw5g.134366/f2        606a53d683374703
        :align: center

        Inline queries on Telegram

    .. seealso::
        The :class:`telegram.InlineQueryResult` classes represent the media the user can choose
        from (see above figure).

    Note:
        In Python :keyword:`from` is a reserved word. Use :paramref:`from_user` instead.

    .. versionchanged:: 20.0
        The following are now keyword-only arguments in Bot methods:
        ``{read, write, connect, pool}_timeout``, :paramref:`answer.api_kwargs`,
        ``auto_pagination``. Use a named argument for those,
        and notice that some positional arguments changed position as a result.

    Args:
        id (:obj:`str`): Unique identifier for this query.
        from_user (:class:`telegram.User`): Sender.
        query (:obj:`str`): Text of the query (up to
            :tg-const:`telegram.InlineQuery.MAX_QUERY_LENGTH` characters).
        offset (:obj:`str`): Offset of the results to be returned, can be controlled by the bot.
        chat_type (:obj:`str`, optional): Type of the chat, from which the inline query was sent.
            Can be either :tg-const:`telegram.Chat.SENDER` for a private chat with the inline query
            sender, :tg-const:`telegram.Chat.PRIVATE`, :tg-const:`telegram.Chat.GROUP`,
            :tg-const:`telegram.Chat.SUPERGROUP` or :tg-const:`telegram.Chat.CHANNEL`. The chat
            type should be always known for requests sent from official clients and most
            third-party clients, unless the request was sent from a secret chat.

            .. versionadded:: 13.5
        location (:class:`telegram.Location`, optional): Sender location, only for bots that
            request user location.

    Attributes:
        id (:obj:`str`): Unique identifier for this query.
        from_user (:class:`telegram.User`): Sender.
        query (:obj:`str`): Text of the query (up to
            :tg-const:`telegram.InlineQuery.MAX_QUERY_LENGTH` characters).
        offset (:obj:`str`): Offset of the results to be returned, can be controlled by the bot.
        chat_type (:obj:`str`): Optional. Type of the chat, from which the inline query was sent.
            Can be either :tg-const:`telegram.Chat.SENDER` for a private chat with the inline query
            sender, :tg-const:`telegram.Chat.PRIVATE`, :tg-const:`telegram.Chat.GROUP`,
            :tg-const:`telegram.Chat.SUPERGROUP` or :tg-const:`telegram.Chat.CHANNEL`. The chat
            type should be always known for requests sent from official clients and most
            third-party clients, unless the request was sent from a secret chat.

            .. versionadded:: 13.5
        location (:class:`telegram.Location`): Optional. Sender location, only for bots that
            request user location.

    )	chat_type	from_useridlocationoffsetqueryN
api_kwargs)r   r   r   r   r   r   r   c                   sH   t  j|d || _|| _|| _|| _|| _|| _| jf| _| 	  d S )Nr   )
super__init__r   r   r   r   r   r   Z	_id_attrsZ_freeze)selfr   r   r   r   r   r   r   	__class__ @/tmp/pip-unpacked-wheel-swnnwir2/telegram/_inline/inlinequery.pyr   e   s    
zInlineQuery.__init__r   )databotreturnc                    sP   |  |}|sdS t|dd||d< t|d||d< t j||dS )z,See :meth:`telegram.TelegramObject.de_json`.Nfromr   r   )r"   r#   )Z_parse_datar   de_jsonpopr	   getr   )clsr"   r#   r   r    r!   r&      s    
zInlineQuery.de_jsonF)current_offsetauto_paginationread_timeoutwrite_timeoutconnect_timeoutpool_timeoutr   r   )results
cache_timeis_personalnext_offsetbuttonr*   r+   r,   r-   r.   r/   r   r$   c                   sH   |r|rt d|  j| j|r&| jn||||||||	|
||dI dH S )a  Shortcut for::

            await bot.answer_inline_query(
                update.inline_query.id,
                *args,
                current_offset=self.offset if auto_pagination else None,
                **kwargs
            )

        For the documentation of the arguments, please see
        :meth:`telegram.Bot.answer_inline_query`.

        .. versionchanged:: 20.0
            Raises :class:`ValueError` instead of :class:`TypeError`.

        Keyword Args:
            auto_pagination (:obj:`bool`, optional): If set to :obj:`True`, :attr:`offset` will be
                passed as
                :paramref:`current_offset <telegram.Bot.answer_inline_query.current_offset>` to
                :meth:`telegram.Bot.answer_inline_query`.
                Defaults to :obj:`False`.

        Raises:
            ValueError: If both :paramref:`~telegram.Bot.answer_inline_query.current_offset` and
                :paramref:`auto_pagination` are supplied.
        z:current_offset and auto_pagination are mutually exclusive!)Zinline_query_idr*   r0   r1   r2   r3   r4   r,   r-   r.   r/   r   N)
ValueErrorZget_botZanswer_inline_queryr   r   )r   r0   r1   r2   r3   r4   r*   r+   r,   r-   r.   r/   r   r    r    r!   answer   s     ,zInlineQuery.answerMAX_RESULTSMIN_SWITCH_PM_TEXT_LENGTHMAX_SWITCH_PM_TEXT_LENGTHMAX_OFFSET_LENGTHMAX_QUERY_LENGTH)NN)N)NNNN)"__name__
__module____qualname____doc__	__slots__strr   r   r	   r   r   classmethodr&   r   r   r   r   intboolr
   r   floatr6   r   ZInlineQueryLimitZRESULTSr7   r   __annotations__r8   r9   r:   r;   __classcell__r    r    r   r!   r   $   sr   
>  	      
=r   N)r?   typingr   r   r   r   r   r   Ztelegramr   Ztelegram._files.locationr	   Z)telegram._inline.inlinequeryresultsbuttonr
   Ztelegram._telegramobjectr   Ztelegram._userr   Ztelegram._utils.defaultvaluer   Ztelegram._utils.typesr   r   r   r   r   r    r    r    r!   <module>   s    