o
    f>h                     @   s   d Z ddlmZ ddlmZmZmZmZ ddlm	Z	 ddl
mZ ddl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mZmZmZ erbddlmZmZ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    )Sequence)TYPE_CHECKINGFinalOptionalUnion)	constants)Location)MaybeInaccessibleMessageMessage)TelegramObject)User)de_json_optional)DEFAULT_NONE)JSONDictODVInputReplyMarkup
TimePeriod)BotGameHighScoreInlineKeyboardMarkup
InputMediaLinkPreviewOptionsMessageEntity	MessageIdReplyParametersc                *       sB  e Zd ZU dZdZ				dcdddedededee d	ee d
ee dee dee	 f fddZ
eddd	e	ded dd f fddZ				dceeeedddee dee dee dee dee dee dee dee dee	 defddZded edefd!d"Zeddefdeeeedd#ded$ee d%ed& d'eed(  d)ed* d+ee dee dee dee dee dee	 deeef fd,d-Zddeddfeeeeddd.ee d%ed& d$ee d/eed(  d0ee dee dee dee dee dee	 deeef fd1d2Z	ddeeeeddd%ed& dee dee dee dee dee	 deeef fd3d4Z	ddeeeeddd5d6d%ed& dee dee dee dee dee	 deeef fd7d8Z							dfdeeeedd9d:ee d;ee d%ed& d<ee d=ee d>ee d?ee d@ee dee dee dee dee dee	 deeef fdAdBZ	ddeeeeddd%ed& dee dee dee dee dee	 deeef fdCdDZ		dgeeeedddEedFedGee dHee dee dee dee dee dee	 deeef fdIdJZeeeedddEedee dee dee dee dee	 de dK fdLdMZ!eeeedddee dee dee dee dee	 defdNdOZ"efeeeedddPee dee dee dee dee dee	 defdQdRZ#eeeedddee dee dee dee dee	 defdSdTZ$dedededddddfedeeeeddUdVeeef d.ee d$ee d/eed(  dPee d%ee% dWee dXee dYedZ d0ee d[ee d\ee d]ee d^ee dee dee dee dee dee	 dd_f(d`daZ&e'j(j)Z*e+e e,db<   Z-S )h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.MaybeInaccessibleMessage`, optional): Message sent by the bot
            with the callback button that originated the query.

            .. versionchanged:: 20.8
               Accept objects of type :class:`telegram.MaybeInaccessibleMessage` since Bot API 7.0.
        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.MaybeInaccessibleMessage`): Optional. Message sent by the bot
            with the callback button that originated the query.

            .. versionchanged:: 20.8
               Objects may be of type :class:`telegram.MaybeInaccessibleMessage` since Bot API
               7.0.
        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.


    )chat_instancedata	from_usergame_short_nameidinline_message_idmessageN
api_kwargsr    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   	_id_attrs_freeze)	selfr    r   r   r"   r   r!   r   r$   	__class__ J/var/www/html/venv/lib/python3.10/site-packages/telegram/_callbackquery.pyr&   }   s   
zCallbackQuery.__init__botr   returnc                    sH   |  |}t|ddt||d< t|dt||d< t j||dS )z,See :meth:`telegram.TelegramObject.de_json`.fromNr   r"   )r   r.   )_parse_datar   popr   getr
   r%   de_json)clsr   r.   r*   r,   r-   r4      s   
zCallbackQuery.de_jsonread_timeoutwrite_timeoutconnect_timeoutpool_timeoutr$   text
show_alerturl
cache_timer7   r8   r9   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.

        )
callback_query_idr;   r<   r=   r>   r7   r8   r9   r:   r$   N)get_botanswer_callback_queryr    )
r)   r;   r<   r=   r>   r7   r8   r9   r:   r$   r,   r,   r-   answer   s   zCallbackQuery.answereditactionc                 C   s"   t | jtstd| d| jS )zHelper method to get the message for the shortcut methods. Must be called only
        if :attr:`inline_message_id` is *not* set.
        zCannot z an inaccessible message)
isinstancer"   r
   	TypeError)r)   rD   r,   r,   r-   _get_message   s   zCallbackQuery._get_message)disable_web_page_previewr7   r8   r9   r:   r$   
parse_modereply_markupr   entitiesr   link_preview_optionsr   rH   c                   sf   | j r|  j| j ||||||||	|
||ddddI dH S |  j||||||||	|
||dI dH S )a  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`.

        .. versionchanged:: 20.8
           Raises :exc:`TypeError` if :attr:`message` is not accessible.

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

        Raises:
            :exc:`TypeError` if :attr:`message` is not accessible.

        N)r!   r;   rI   rH   rL   rJ   r7   r8   r9   r:   r$   rK   chat_id
message_idbusiness_connection_id)r;   rI   rH   rL   rJ   r7   r8   r9   r:   r$   rK   )r!   r@   edit_message_textrG   	edit_text)r)   r;   rI   rJ   rK   rL   rH   r7   r8   r9   r:   r$   r,   r,   r-   rP      s@   'zCallbackQuery.edit_message_textcaptioncaption_entitiesshow_caption_above_mediac                   sb   | j r|  j|| j |||||	||
|dd|ddI dH S |  j||||||	||
||d
I dH S )a%  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`.

        .. versionchanged:: 20.8
           Raises :exc:`TypeError` if :attr:`message` is not accessible.

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

        Raises:
            :exc:`TypeError` if :attr:`message` is not accessible.

        N)rR   r!   rJ   r7   r8   r9   r:   rI   r$   rS   rM   rN   rT   rO   )
rR   rJ   r7   r8   r9   r:   rI   r$   rS   rT   )r!   r@   edit_message_captionrG   edit_caption)r)   rR   rJ   rI   rS   rT   r7   r8   r9   r:   r$   r,   r,   r-   rU     s<   &z"CallbackQuery.edit_message_captionc                   sR   | j r|  j|| j |||||dddd
I dH S |  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`.

        .. versionchanged:: 20.8
           Raises :exc:`TypeError` if :attr:`message` is not accessible.

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

        Raises:
            :exc:`TypeError` if :attr:`message` is not accessible.

        N)
rJ   r!   r7   r8   r9   r:   r$   rM   rN   rO   rJ   r7   r8   r9   r:   r$   )r!   r@   edit_message_reply_markuprG   edit_reply_markupr)   rJ   r7   r8   r9   r:   r$   r,   r,   r-   rX   \  s,   #z'CallbackQuery.edit_message_reply_markupmediar   c                   sV   | j r|  j| j |||||||ddddI dH S |  j|||||||dI dH S )a"  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`.

        .. versionchanged:: 20.8
           Raises :exc:`TypeError` if :attr:`message` is not accessible.

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

        Raises:
            :exc:`TypeError` if :attr:`message` is not accessible.

        N)r!   r[   rJ   r7   r8   r9   r:   r$   rM   rN   rO   )r[   rJ   r7   r8   r9   r:   r$   )r!   r@   edit_message_mediarG   
edit_media)r)   r[   rJ   r7   r8   r9   r:   r$   r,   r,   r-   r\     s0   #z CallbackQuery.edit_message_media)locationr7   r8   r9   r:   r$   latitude	longitudehorizontal_accuracyheadingproximity_alert_radiuslive_periodr^   c                   s   | j rC|  jdi d| j d|d|d|d|d|	d|
d|d	|d
|d|d|d|d|ddddddI dH S |  j|||||	|
|||||||dI dH S )aD  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`.

        .. versionchanged:: 20.8
           Raises :exc:`TypeError` if :attr:`message` is not accessible.

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

        Raises:
            :exc:`TypeError` if :attr:`message` is not accessible.

        r!   r_   r`   r^   rJ   r7   r8   r9   r:   r$   ra   rb   rc   rd   rM   NrN   rO   )r_   r`   r^   rJ   r7   r8   r9   r:   r$   ra   rb   rc   rd   r,   )r!   r@   edit_message_live_locationrG   edit_live_location)r)   r_   r`   rJ   ra   rb   rc   rd   r^   r7   r8   r9   r:   r$   r,   r,   r-   re     sh   *	

z(CallbackQuery.edit_message_live_locationc                   sR   | j r|  j| j ||||||dddd
I dH S |  j||||||dI dH S )aD  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`.

        .. versionchanged:: 20.8
           Raises :exc:`TypeError` if :attr:`message` is not accessible.

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

        Raises:
            :exc:`TypeError` if :attr:`message` is not accessible.

        N)
r!   rJ   r7   r8   r9   r:   r$   rM   rN   rO   rW   )r!   r@   stop_message_live_locationrG   stop_live_locationrZ   r,   r,   r-   rg   !  s,   #z(CallbackQuery.stop_message_live_locationuser_idscoreforcedisable_edit_messagec          
         s\   | j r|  j| j |||||||||	dddI dH S |  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`.

        .. versionchanged:: 20.8
           Raises :exc:`TypeError` if :attr:`message` is not accessible.

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

        Raises:
            :exc:`TypeError` if :attr:`message` is not accessible.

        N)r!   ri   rj   rk   rl   r7   r8   r9   r:   r$   rM   rN   )	ri   rj   rk   rl   r7   r8   r9   r:   r$   )r!   r@   set_game_scorerG   )
r)   ri   rj   rk   rl   r7   r8   r9   r:   r$   r,   r,   r-   rm   [  s6   %zCallbackQuery.set_game_score)r   .c                   sP   | j r|  j| j ||||||ddd	I dH S |  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`.

        .. versionchanged:: 20.8
           Raises :exc:`TypeError` if :attr:`message` is not accessible.

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

        Raises:
            :exc:`TypeError` if :attr:`message` is not accessible.

        N)	r!   ri   r7   r8   r9   r:   r$   rM   rN   )ri   r7   r8   r9   r:   r$   )r!   r@   get_game_high_scoresrG   )r)   ri   r7   r8   r9   r:   r$   r,   r,   r-   rn     s*   "z"CallbackQuery.get_game_high_scoresc                   $   | j dd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`.

        .. versionchanged:: 20.8
           Raises :exc:`TypeError` if :attr:`message` is not accessible.

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

        Raises:
            :exc:`TypeError` if :attr:`message` is not accessible.

        deleterD   r6   N)rG   rp   r)   r7   r8   r9   r:   r$   r,   r,   r-   delete_message  s   zCallbackQuery.delete_messagedisable_notificationc                   s&   | j dd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`.

        .. versionchanged:: 20.8
           Raises :exc:`TypeError` if :attr:`message` is not accessible.

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

        Raises:
            :exc:`TypeError` if :attr:`message` is not accessible.
        pinrq   )rt   r7   r8   r9   r:   r$   N)rG   ru   )r)   rt   r7   r8   r9   r:   r$   r,   r,   r-   pin_message  s   zCallbackQuery.pin_messagec                   ro   )a  Shortcut for::

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

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

        .. versionchanged:: 20.8
           Raises :exc:`TypeError` if :attr:`message` is not accessible.

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

        Raises:
            :exc:`TypeError` if :attr:`message` is not accessible.
        unpinrq   r6   N)rG   rw   rr   r,   r,   r-   unpin_message  s   zCallbackQuery.unpin_message)allow_sending_without_replyreply_to_message_idr7   r8   r9   r:   r$   rM   protect_contentmessage_thread_idreply_parametersr   allow_paid_broadcastvideo_start_timestampry   rz   r   c                   s   | j ddjdi d|d|d|d|d|d|d	|d
|d|d|d|d|d|d|d|d|d|	d|
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`.

        .. versionchanged:: 20.8
           Raises :exc:`TypeError` if :attr:`message` is not accessible.

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

        Raises:
            :exc:`TypeError` if :attr:`message` is not accessible.
        copyrq   rM   rR   rI   r   rS   rt   rz   ry   rJ   r7   r8   r9   r:   r$   r{   r|   r}   rT   r~   Nr,   )rG   r   )r)   rM   rR   rI   rS   rt   rJ   r{   r|   r}   rT   r~   r   ry   rz   r7   r8   r9   r:   r$   r,   r,   r-   copy_message5  sP   +	

zCallbackQuery.copy_messageMAX_ANSWER_TEXT_LENGTH)NNNN)N)rC   )NNNNNNN)NN).__name__
__module____qualname____doc__	__slots__strr   r   r	   r   r&   classmethodr4   r   boolr   r   floatrB   r
   rG   r   r   rP   rU   rX   r\   intr   re   rg   rm   tuplern   rs   rv   rx   r   r   r   CallbackQueryLimit!ANSWER_CALLBACK_QUERY_TEXT_LENGTHr   r   __annotations____classcell__r,   r,   r*   r-   r   .   s6  
 D

"	

%
	


J
	


G
	
=	


>



Q
	
>	


D	
:
#	
%
#

	

Br   N)%r   collections.abcr   typingr   r   r   r   telegramr   telegram._files.locationr   telegram._messager	   r
   telegram._telegramobjectr   telegram._userr   telegram._utils.argumentparsingr   telegram._utils.defaultvaluer   telegram._utils.typesr   r   r   r   r   r   r   r   r   r   r   r   r   r,   r,   r,   r-   <module>   s   (