U
    2tcZ                     @   s   d Z ddlmZmZmZmZmZmZm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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AnyListOptionalUnionTupleClassVar)MessageTelegramObjectUserLocationReplyMarkup	constants)DEFAULT_NONE)JSONDictODVInputDVInput)BotGameHighScoreInlineKeyboardMarkup	MessageId
InputMediaMessageEntityc                   @   s  e Zd ZU dZdZd8eeeeeeeded	ddZ	e
ee ded  dd	d
Zddddedfeeeeee eedddZeededdfeee ee dee eeed ed f eeef dddZddeeddfedee ee eeed ed f eeef dddZdedfed ee eeeef dddZddedfddee eeeef dddZddddeddddf	eeedee eeeeeeef d
d d!Zdedfdee eeeef dd"d#Zddedfeeef eeeee eeeef d$d%d&Zedfeeef ee eed' d(d)d*Zedfee eed+d,d-Z eedfee ee eed.d/d0Z!edfee eed+d1d2Z"dededededdf
eeef eee eed ed f e#e ee#e e$ee eed3d4d5d6Z%e&j'Z(e)e e*d7< dS )9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 ``from`` is a reserved word, use ``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:`Bot.arbitrary_callback_data`, :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 a bad
            client can send arbitrary data in this field.
        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
        bot (:class:`telegram.Bot`, optional): The Bot to use for instance methods.

    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.
        message (:class:`telegram.Message`): Optional. Message with the callback button that
            originated the query.
        data (:obj:`str` | :obj:`object`): Optional. Data associated with the callback button.
        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.
        bot (:class:`telegram.Bot`, optional): The Bot to use for instance methods.

    )	botgame_short_namemessagechat_instanceid	from_userinline_message_iddata	_id_attrsNr   )	r   r   r   r   r!   r    r   r   _kwargsc	           
      K   s>   || _ || _|| _|| _|| _|| _|| _|| _| j f| _d S )N)	r   r   r   r   r!   r    r   r   r"   )
selfr   r   r   r   r!   r    r   r   r#    r%   :/tmp/pip-unpacked-wheel-2u9rcp5s/telegram/callbackquery.py__init__k   s    zCallbackQuery.__init__)r!   r   returnc                 C   sP   |  |}|sdS t|d||d< t|d||d< | f d|i|S )z,See :meth:`telegram.TelegramObject.de_json`.Nfromr   r   r   )Z_parse_datar   de_jsongetr	   )clsr!   r   r%   r%   r&   r*      s    
zCallbackQuery.de_jsonF)text
show_alerturl
cache_timetimeout
api_kwargsr(   c              	   C   s   | j j| j||||||dS )a*  Shortcut for::

            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_idr-   r.   r/   r0   r1   r2   )r   Zanswer_callback_queryr   )r$   r-   r.   r/   r0   r1   r2   r%   r%   r&   answer   s    zCallbackQuery.answerr   r   )r   .)r-   
parse_modedisable_web_page_previewreply_markupr1   r2   entitiesr(   c                 C   sB   | j r(| jj| j |||||||ddd
S | jj|||||||dS )a[  Shortcut for either::

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

        or::

            bot.edit_message_text(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    r-   r4   r5   r6   r1   r2   r7   chat_id
message_id)r-   r4   r5   r6   r1   r2   r7   )r    r   edit_message_textr   Z	edit_text)r$   r-   r4   r5   r6   r1   r2   r7   r%   r%   r&   r:      s,    zCallbackQuery.edit_message_text)captionr6   r1   r4   r2   caption_entitiesr(   c                 C   s>   | j r&| jj|| j |||||ddd	S | jj||||||dS )a  Shortcut for either::

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

        or::

            bot.edit_message_caption(caption=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)	r;   r    r6   r1   r4   r2   r<   r8   r9   )r;   r6   r1   r4   r2   r<   )r    r   edit_message_captionr   Zedit_caption)r$   r;   r6   r1   r4   r2   r<   r%   r%   r&   r=      s(    z"CallbackQuery.edit_message_caption)r6   r1   r2   r(   c                 C   s2   | j r | jj|| j ||dddS | jj|||dS )a  Shortcut for either::

            update.callback_query.message.edit_reply_markup(
                reply_markup=reply_markup,
                *args,
                **kwargs
            )

        or::

            bot.edit_message_reply_markup
                inline_message_id=update.callback_query.inline_message_id,
                reply_markup=reply_markup,
                *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)r6   r    r1   r2   r8   r9   r6   r1   r2   )r    r   edit_message_reply_markupr   Zedit_reply_markupr$   r6   r1   r2   r%   r%   r&   r?     s     z'CallbackQuery.edit_message_reply_markupr   )mediar6   r1   r2   r(   c              	   C   s6   | j r"| jj| j ||||dddS | jj||||dS )aV  Shortcut for either::

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

        or::

            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 sent by the bot, the
            edited Message is returned, otherwise :obj:`True` is returned.

        N)r    rA   r6   r1   r2   r8   r9   )rA   r6   r1   r2   )r    r   edit_message_mediar   Z
edit_media)r$   rA   r6   r1   r2   r%   r%   r&   rB   A  s     	z CallbackQuery.edit_message_media)
latitude	longitudelocationr6   r1   r2   horizontal_accuracyheadingproximity_alert_radiusr(   c
           
      C   sJ   | j r,| jj| j |||||||||	dddS | jj|||||||||	d	S )a  Shortcut for either::

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

        or::

            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    rC   rD   rE   r6   r1   r2   rF   rG   rH   r8   r9   )	rC   rD   rE   r6   r1   r2   rF   rG   rH   )r    r   edit_message_live_locationr   Zedit_live_location)
r$   rC   rD   rE   r6   r1   r2   rF   rG   rH   r%   r%   r&   rI   j  s4     z(CallbackQuery.edit_message_live_locationc                 C   s2   | j r | jj| j |||dddS | jj|||dS )a  Shortcut for either::

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

        or::

            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    r6   r1   r2   r8   r9   r>   )r    r   stop_message_live_locationr   Zstop_live_locationr@   r%   r%   r&   rJ     s    z(CallbackQuery.stop_message_live_location)user_idscoreforcedisable_edit_messager1   r2   r(   c                 C   s>   | j r&| jj| j ||||||ddd	S | jj||||||dS )aQ  Shortcut for either::

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

        or::

            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    rK   rL   rM   rN   r1   r2   r8   r9   )rK   rL   rM   rN   r1   r2   )r    r   set_game_scorer   )r$   rK   rL   rM   rN   r1   r2   r%   r%   r&   rO     s(    zCallbackQuery.set_game_scorer   )rK   r1   r2   r(   c                 C   s2   | j r | jj| j |||dddS | jj|||dS )a  Shortcut for either::

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

        or::

            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_score`.

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

        N)r    rK   r1   r2   r8   r9   )rK   r1   r2   )r    r   get_game_high_scoresr   )r$   rK   r1   r2   r%   r%   r&   rP     s    z"CallbackQuery.get_game_high_scores)r1   r2   r(   c                 C   s   | j j||dS )a  Shortcut for::

            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.

        r1   r2   )r   deleter$   r1   r2   r%   r%   r&   delete_message"  s    zCallbackQuery.delete_message)disable_notificationr1   r2   r(   c                 C   s   | j j|||dS )a  Shortcut for::

             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.

        )rU   r1   r2   )r   Zpin)r$   rU   r1   r2   r%   r%   r&   pin_message7  s
    zCallbackQuery.pin_messagec                 C   s   | j j||dS )a  Shortcut for::

             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.

        rQ   )r   ZunpinrS   r%   r%   r&   unpin_messageN  s    zCallbackQuery.unpin_messager   )r8   r;   r4   r<   rU   reply_to_message_idallow_sending_without_replyr6   r1   r2   protect_contentr(   c                 C   s"   | j j|||||||||	|
|dS )a  Shortcut for::

            update.callback_query.message.copy(
                chat_id,
                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.

        )r8   r;   r4   r<   rU   rX   rY   r6   r1   r2   rZ   )r   copy)r$   r8   r;   r4   r<   rU   rX   rY   r6   r1   r2   rZ   r%   r%   r&   copy_messagec  s    zCallbackQuery.copy_messageMAX_ANSWER_TEXT_LENGTH)NNNNN)+__name__
__module____qualname____doc__	__slots__strr   r	   r   r'   classmethodr   r   r*   r   boolintr   floatr3   r   r   r   r:   r=   r?   rB   r   rI   rJ   rO   rP   rT   rV   rW   r   r   r\   r   Z%MAX_ANSWER_CALLBACK_QUERY_TEXT_LENGTHr]   r   __annotations__r%   r%   r%   r&   r   &   st  
8     !
4
2
1
+
=
-

2
'
,r   N)ra   typingr   r   r   r   r   r   r   Ztelegramr	   r
   r   r   r   r   Ztelegram.utils.helpersr   Ztelegram.utils.typesr   r   r   r   r   r   r   r   r   r   r%   r%   r%   r&   <module>   s   $  
