U
    ddr                     @   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mZmZ erdd
lmZmZmZmZmZmZ G dd deZdS )zGThis module contains an object that represents a Telegram CallbackQuery    )TYPE_CHECKINGClassVarOptionalSequenceTupleUnion)	constants)Location)Message)TelegramObject)User)DEFAULT_NONE)DVInputJSONDictODVInputReplyMarkup)BotGameHighScoreInlineKeyboardMarkup
InputMediaMessageEntity	MessageIdc                       sD  e Zd ZU dZdZd9ddeeeeeeeed fddZ	e
ee ded  d	 fd
dZd:eeeeddeeeeee ee ee ee eed
ddZeeddfeeeeddeee ee ded ee ee ee ee eeeef dddZddedfeeeeddedee ed ee ee ee ee eeeef d
ddZd;eeeedded ee ee ee ee eeeef dddZd<eeeeddddee ee ee ee eeeef dddZd=deeeeddeedeeeeee ee ee ee eeeef d d!d"Zd>eeeedddee ee ee ee eeeef dd#d$Zd?eeeeddeeef eeeee ee ee ee eeeef d%
d&d'Zeeeeddeeef ee ee ee ee eed( d)d*d+Zeeeeddee ee ee ee eed,d-d.Zefeeeeddee ee ee ee ee eed/d0d1Z eeeeddee ee ee ee eed,d2d3Z!dededededf	eeeeddeeef eee ed e"e ee"e e#ee eee ee ee ee ed4d5d6d7Z$e%j&j'Z(e)e e*d8<   Z+S )@CallbackQuerya  
    This object represents an incoming callback query from a callback button in an inline keyboard.

    If the button that originated the query was attached to a message sent by the bot, the field
    :attr:`message` will be present. If the button was attached to a message sent via the bot (in
    inline mode), the field :attr:`inline_message_id` will be present.

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

    Note:
        * In Python :keyword:`from` is a reserved word. Use :paramref:`from_user` instead.
        * Exactly one of the fields :attr:`data` or :attr:`game_short_name` will be present.
        * After the user presses an inline button, Telegram clients will display a progress bar
          until you call :attr:`answer`. It is, therefore, necessary to react
          by calling :attr:`telegram.Bot.answer_callback_query` even if no notification to the user
          is needed (e.g., without specifying any of the optional parameters).
        * If you're using :attr:`telegram.ext.ExtBot.callback_data_cache`, :attr:`data` may be
          an instance
          of :class:`telegram.ext.InvalidCallbackData`. This will be the case, if the data
          associated with the button triggering the :class:`telegram.CallbackQuery` was already
          deleted or if :attr:`data` was manipulated by a malicious client.

          .. versionadded:: 13.6

    Args:
        id (:obj:`str`): Unique identifier for this query.
        from_user (:class:`telegram.User`): Sender.
        chat_instance (:obj:`str`): Global identifier, uniquely corresponding to the chat to which
            the message with the callback button was sent. Useful for high scores in games.
        message (:class:`telegram.Message`, optional): Message with the callback button that
            originated the query. Note that message content and message date will not be available
            if the message is too old.
        data (:obj:`str`, optional): Data associated with the callback button. Be aware that the
            message, which originated the query, can contain no callback buttons with this data.
        inline_message_id (:obj:`str`, optional): Identifier of the message sent via the bot in
            inline mode, that originated the query.
        game_short_name (:obj:`str`, optional): Short name of a Game to be returned, serves as
            the unique identifier for the game.

    Attributes:
        id (:obj:`str`): Unique identifier for this query.
        from_user (:class:`telegram.User`): Sender.
        chat_instance (:obj:`str`): Global identifier, uniquely corresponding to the chat to which
            the message with the callback button was sent. Useful for high scores in games.
        message (:class:`telegram.Message`): Optional. Message with the callback button that
            originated the query. Note that message content and message date will not be available
            if the message is too old.
        data (:obj:`str` | :obj:`object`): Optional. Data associated with the callback button.
            Be aware that the message, which originated the query, can contain no callback buttons
            with this data.

            Tip:
                The value here is the same as the value passed in
                :paramref:`telegram.InlineKeyboardButton.callback_data`.
        inline_message_id (:obj:`str`): Optional. Identifier of the message sent via the bot in
            inline mode, that originated the query.
        game_short_name (:obj:`str`): Optional. Short name of a Game to be returned, serves as
            the unique identifier for the game.


    )game_short_namemessagechat_instanceid	from_userinline_message_iddataN
api_kwargs)r   r   r   r   r   r   r   r!   c          	         sN   t  j|d || _|| _|| _|| _|| _|| _|| _| jf| _	| 
  d S )Nr    )super__init__r   r   r   r   r   r   r   Z	_id_attrsZ_freeze)	selfr   r   r   r   r   r   r   r!   	__class__ ;/tmp/pip-unpacked-wheel-e3anp165/telegram/_callbackquery.pyr#   t   s    
zCallbackQuery.__init__r   )r   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CallbackQuery.de_jsonread_timeoutwrite_timeoutconnect_timeoutpool_timeoutr!   )
text
show_alerturl
cache_timer1   r2   r3   r4   r!   r*   c          
         s*   |   j| j|||||||||	d
I dH S )a1  Shortcut for::

             await bot.answer_callback_query(update.callback_query.id, *args, **kwargs)

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

        Returns:
            :obj:`bool`: On success, :obj:`True` is returned.

        )
Zcallback_query_idr5   r6   r7   r8   r1   r2   r3   r4   r!   N)get_botZanswer_callback_queryr   )
r$   r5   r6   r7   r8   r1   r2   r3   r4   r!   r'   r'   r(   answer   s    zCallbackQuery.answerr   r   )r5   
parse_modedisable_web_page_previewreply_markupentitiesr1   r2   r3   r4   r!   r*   c                   s\   | j r6|  j| j ||||||||	|
|dddI dH S | jj||||||||	|
|d
I dH S )aZ  Shortcut for either::

            await update.callback_query.message.edit_text(*args, **kwargs)

        or::

            await bot.edit_message_text(
                inline_message_id=update.callback_query.inline_message_id, *args, **kwargs,
            )

        For the documentation of the arguments, please see
        :meth:`telegram.Bot.edit_message_text` and :meth:`telegram.Message.edit_text`.

        Returns:
            :class:`telegram.Message`: On success, if edited message is sent by the bot, the
            edited Message is returned, otherwise :obj:`True` is returned.

        N)r   r5   r;   r<   r=   r1   r2   r3   r4   r!   r>   chat_id
message_id)
r5   r;   r<   r=   r1   r2   r3   r4   r!   r>   )r   r9   edit_message_textr   Z	edit_text)r$   r5   r;   r<   r=   r>   r1   r2   r3   r4   r!   r'   r'   r(   rA      s8     zCallbackQuery.edit_message_text)
captionr=   r;   caption_entitiesr1   r2   r3   r4   r!   r*   c          
         sX   | j r4|  j|| j |||||||	|dddI dH S | jj||||||||	|d	I dH S )af  Shortcut for either::

            await update.callback_query.message.edit_caption(*args, **kwargs)

        or::

            await bot.edit_message_caption(
                inline_message_id=update.callback_query.inline_message_id, *args, **kwargs,
            )

        For the documentation of the arguments, please see
        :meth:`telegram.Bot.edit_message_caption` and :meth:`telegram.Message.edit_caption`.

        Returns:
            :class:`telegram.Message`: On success, if edited message is sent by the bot, the
            edited Message is returned, otherwise :obj:`True` is returned.

        N)rB   r   r=   r1   r2   r3   r4   r;   r!   rC   r?   r@   )	rB   r=   r1   r2   r3   r4   r;   r!   rC   )r   r9   edit_message_captionr   Zedit_caption)
r$   rB   r=   r;   rC   r1   r2   r3   r4   r!   r'   r'   r(   rD      s4    z"CallbackQuery.edit_message_caption)r=   r1   r2   r3   r4   r!   r*   c                   sL   | j r.|  j|| j |||||ddd	I dH S | jj||||||dI dH S )a  Shortcut for either::

            await update.callback_query.message.edit_reply_markup(*args, **kwargs)

        or::

            await bot.edit_message_reply_markup(
                inline_message_id=update.callback_query.inline_message_id, *args, **kwargs
            )

        For the documentation of the arguments, please see
        :meth:`telegram.Bot.edit_message_reply_markup` and
        :meth:`telegram.Message.edit_reply_markup`.

        Returns:
            :class:`telegram.Message`: On success, if edited message is sent by the bot, the
            edited Message is returned, otherwise :obj:`True` is returned.

        N)	r=   r   r1   r2   r3   r4   r!   r?   r@   r=   r1   r2   r3   r4   r!   )r   r9   edit_message_reply_markupr   Zedit_reply_markupr$   r=   r1   r2   r3   r4   r!   r'   r'   r(   rF   8  s(    z'CallbackQuery.edit_message_reply_markupr   )mediar=   r1   r2   r3   r4   r!   r*   c                   sP   | j r0|  j| j |||||||ddd
I dH S | jj|||||||dI dH S )ac  Shortcut for either::

            await update.callback_query.message.edit_media(*args, **kwargs)

        or::

            await bot.edit_message_media(
                inline_message_id=update.callback_query.inline_message_id, *args, **kwargs
            )

        For the documentation of the arguments, please see
        :meth:`telegram.Bot.edit_message_media` and :meth:`telegram.Message.edit_media`.

        Returns:
            :class:`telegram.Message`: On success, if edited message is not an inline message, the
            edited Message is returned, otherwise :obj:`True` is returned.

        N)
r   rH   r=   r1   r2   r3   r4   r!   r?   r@   )rH   r=   r1   r2   r3   r4   r!   )r   r9   edit_message_mediar   Z
edit_media)r$   rH   r=   r1   r2   r3   r4   r!   r'   r'   r(   rI   j  s,    z CallbackQuery.edit_message_media)locationr1   r2   r3   r4   r!   )latitude	longituder=   horizontal_accuracyheadingproximity_alert_radiusrJ   r1   r2   r3   r4   r!   r*   c                   sd   | j r:|  j| j ||||||	|
|||||dddI dH S | jj||||||	|
|||||dI dH S )a  Shortcut for either::

            await update.callback_query.message.edit_live_location(*args, **kwargs)

        or::

            await bot.edit_message_live_location(
                inline_message_id=update.callback_query.inline_message_id, *args, **kwargs
            )

        For the documentation of the arguments, please see
        :meth:`telegram.Bot.edit_message_live_location` and
        :meth:`telegram.Message.edit_live_location`.

        Returns:
            :class:`telegram.Message`: On success, if edited message is sent by the bot, the
            edited Message is returned, otherwise :obj:`True` is returned.

        N)r   rK   rL   rJ   r=   r1   r2   r3   r4   r!   rM   rN   rO   r?   r@   )rK   rL   rJ   r=   r1   r2   r3   r4   r!   rM   rN   rO   )r   r9   edit_message_live_locationr   Zedit_live_location)r$   rK   rL   r=   rM   rN   rO   rJ   r1   r2   r3   r4   r!   r'   r'   r(   rP     s@    #z(CallbackQuery.edit_message_live_locationc                   sL   | j r.|  j| j ||||||ddd	I dH S | jj||||||dI dH S )a  Shortcut for either::

            await update.callback_query.message.stop_live_location(*args, **kwargs)

        or::

            await bot.stop_message_live_location(
                inline_message_id=update.callback_query.inline_message_id, *args, **kwargs
            )

        For the documentation of the arguments, please see
        :meth:`telegram.Bot.stop_message_live_location` and
        :meth:`telegram.Message.stop_live_location`.

        Returns:
            :class:`telegram.Message`: On success, if edited message is sent by the bot, the
            edited Message is returned, otherwise :obj:`True` is returned.

        N)	r   r=   r1   r2   r3   r4   r!   r?   r@   rE   )r   r9   stop_message_live_locationr   Zstop_live_locationrG   r'   r'   r(   rQ     s(    z(CallbackQuery.stop_message_live_location)
user_idscoreforcedisable_edit_messager1   r2   r3   r4   r!   r*   c          
         sX   | j r4|  j| j |||||||||	dddI dH S | jj|||||||||	d	I dH S )a\  Shortcut for either::

           await update.callback_query.message.set_game_score(*args, **kwargs)

        or::

            await bot.set_game_score(
                inline_message_id=update.callback_query.inline_message_id, *args, **kwargs
            )

        For the documentation of the arguments, please see
        :meth:`telegram.Bot.set_game_score` and :meth:`telegram.Message.set_game_score`.

        Returns:
            :class:`telegram.Message`: On success, if edited message is sent by the bot, the
            edited Message is returned, otherwise :obj:`True` is returned.

        N)r   rR   rS   rT   rU   r1   r2   r3   r4   r!   r?   r@   )	rR   rS   rT   rU   r1   r2   r3   r4   r!   )r   r9   set_game_scorer   )
r$   rR   rS   rT   rU   r1   r2   r3   r4   r!   r'   r'   r(   rV     s4    zCallbackQuery.set_game_score)r   .)rR   r1   r2   r3   r4   r!   r*   c                   sL   | j r.|  j| j ||||||ddd	I dH S | jj||||||dI dH S )a  Shortcut for either::

            await update.callback_query.message.get_game_high_score(*args, **kwargs)

        or::

            await bot.get_game_high_scores(
                inline_message_id=update.callback_query.inline_message_id, *args, **kwargs
            )

        For the documentation of the arguments, please see
        :meth:`telegram.Bot.get_game_high_scores` and
        :meth:`telegram.Message.get_game_high_scores`.

        Returns:
            Tuple[:class:`telegram.GameHighScore`]

        N)	r   rR   r1   r2   r3   r4   r!   r?   r@   )rR   r1   r2   r3   r4   r!   )r   r9   get_game_high_scoresr   )r$   rR   r1   r2   r3   r4   r!   r'   r'   r(   rW   N  s(    z"CallbackQuery.get_game_high_scores)r1   r2   r3   r4   r!   r*   c                   s   | j j|||||dI dH S )a  Shortcut for::

            await update.callback_query.message.delete(*args, **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Message.delete`.

        Returns:
            :obj:`bool`: On success, :obj:`True` is returned.

        r0   N)r   deleter$   r1   r2   r3   r4   r!   r'   r'   r(   delete_message  s    zCallbackQuery.delete_message)disable_notificationr1   r2   r3   r4   r!   r*   c                   s   | j j||||||dI dH S )a  Shortcut for::

            await update.callback_query.message.pin(*args, **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Message.pin`.

        Returns:
            :obj:`bool`: On success, :obj:`True` is returned.

        )r[   r1   r2   r3   r4   r!   N)r   Zpin)r$   r[   r1   r2   r3   r4   r!   r'   r'   r(   pin_message  s    zCallbackQuery.pin_messagec                   s   | j j|||||dI dH S )a  Shortcut for::

            await update.callback_query.message.unpin(*args, **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Message.unpin`.

        Returns:
            :obj:`bool`: On success, :obj:`True` is returned.

        r0   N)r   ZunpinrY   r'   r'   r(   unpin_message  s    zCallbackQuery.unpin_messager   )r?   rB   r;   rC   r[   reply_to_message_idallow_sending_without_replyr=   protect_contentmessage_thread_idr1   r2   r3   r4   r!   r*   c                   s0   | j j||||||||||||||	|
dI dH S )a  Shortcut for::

            await update.callback_query.message.copy(
                from_chat_id=update.message.chat_id,
                message_id=update.message.message_id,
                *args,
                **kwargs
            )

        For the documentation of the arguments, please see :meth:`telegram.Message.copy`.

        Returns:
            :class:`telegram.MessageId`: On success, returns the MessageId of the sent message.

        )r?   rB   r;   rC   r[   r^   r_   r=   r1   r2   r3   r4   r!   r`   ra   N)r   copy)r$   r?   rB   r;   rC   r[   r^   r_   r=   r`   ra   r1   r2   r3   r4   r!   r'   r'   r(   copy_message  s"    "zCallbackQuery.copy_messageMAX_ANSWER_TEXT_LENGTH)NNNN)NNNN)N)N)NNNNNN)N)NN),__name__
__module____qualname____doc__	__slots__strr   r
   r   r#   classmethodr   r,   r   boolintr   floatr:   r   r   rA   rD   rF   rI   r	   rP   rQ   rV   r   rW   rZ   r\   r]   r   r   rc   r   ZCallbackQueryLimitZ!ANSWER_CALLBACK_QUERY_TEXT_LENGTHrd   r   __annotations____classcell__r'   r'   r%   r(   r   *   s,  
?    
     (
?
< 
5 
6      	
F 
6  

>
4 
6r   N) rh   typingr   r   r   r   r   r   Ztelegramr   Ztelegram._files.locationr	   Ztelegram._messager
   Ztelegram._telegramobjectr   Ztelegram._userr   Ztelegram._utils.defaultvaluer   Ztelegram._utils.typesr   r   r   r   r   r   r   r   r   r   r   r'   r'   r'   r(   <module>   s     
