U
    2tcB                     @   s   d Z ddlmZmZmZ ddlmZmZmZm	Z	m
Z
mZmZmZmZmZmZ ddlmZ ddlmZ er|ddlmZmZmZ G dd deZd	S )
zAThis module contains an object that represents a Telegram Update.    )TYPE_CHECKINGAnyOptional)CallbackQueryChosenInlineResultInlineQueryMessagePollPreCheckoutQueryShippingQueryTelegramObjectChatMemberUpdated	constantsChatJoinRequest)
PollAnswer)JSONDict)BotChatUserc                   @   s   e Zd ZdZdZejZejZ	ej
ZejZejZejZejZejZejZejZejZejZejZej Z!ej"Z#de$e%e%e%e%e&e'e(e)e*e+e,e-e-e.e/dddZ0e1e2d dd	d
Z3e1e2d dddZ4e1e2e% dddZ5e6e2e7 de2d  dddZ8dS )Updatea  This object represents an incoming update.

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

    Note:
        At most one of the optional parameters can be present in any given update.

    Args:
        update_id (:obj:`int`): The update's unique identifier. Update identifiers start from a
            certain positive number and increase sequentially. This ID becomes especially handy if
            you're using Webhooks, since it allows you to ignore repeated updates or to restore the
            correct update sequence, should they get out of order. If there are no new updates for
            at least a week, then identifier of the next update will be chosen randomly instead of
            sequentially.
        message (:class:`telegram.Message`, optional): New incoming message of any kind - text,
            photo, sticker, etc.
        edited_message (:class:`telegram.Message`, optional): New version of a message that is
            known to the bot and was edited.
        channel_post (:class:`telegram.Message`, optional): New incoming channel post of any kind
            - text, photo, sticker, etc.
        edited_channel_post (:class:`telegram.Message`, optional): New version of a channel post
            that is known to the bot and was edited.
        inline_query (:class:`telegram.InlineQuery`, optional): New incoming inline query.
        chosen_inline_result (:class:`telegram.ChosenInlineResult`, optional): The result of an
            inline query that was chosen by a user and sent to their chat partner.
        callback_query (:class:`telegram.CallbackQuery`, optional): New incoming callback query.
        shipping_query (:class:`telegram.ShippingQuery`, optional): New incoming shipping query.
            Only for invoices with flexible price.
        pre_checkout_query (:class:`telegram.PreCheckoutQuery`, optional): New incoming
            pre-checkout query. Contains full information about checkout.
        poll (:class:`telegram.Poll`, optional): New poll state. Bots receive only updates about
            stopped polls and polls, which are sent by the bot.
        poll_answer (:class:`telegram.PollAnswer`, optional): A user changed their answer
            in a non-anonymous poll. Bots receive new votes only in polls that were sent
            by the bot itself.
        my_chat_member (:class:`telegram.ChatMemberUpdated`, optional): The bot's chat member
            status was updated in a chat. For private chats, this update is received only when the
            bot is blocked or unblocked by the user.

            .. versionadded:: 13.4
        chat_member (:class:`telegram.ChatMemberUpdated`, optional): A chat member's status was
            updated in a chat. The bot must be an administrator in the chat and must explicitly
            specify ``'chat_member'`` in the list of ``'allowed_updates'`` to receive these
            updates (see :meth:`telegram.Bot.get_updates`, :meth:`telegram.Bot.set_webhook`,
            :meth:`telegram.ext.Updater.start_polling` and
            :meth:`telegram.ext.Updater.start_webhook`).

            .. versionadded:: 13.4
        chat_join_request (:class:`telegram.ChatJoinRequest`, optional): A request to join the
            chat has been sent. The bot must have the
            :attr:`telegram.ChatPermissions.can_invite_users` administrator right in the chat to
            receive these updates.

            .. versionadded:: 13.8
        **kwargs (:obj:`dict`): Arbitrary keyword arguments.

    Attributes:
        update_id (:obj:`int`): The update's unique identifier.
        message (:class:`telegram.Message`): Optional. New incoming message.
        edited_message (:class:`telegram.Message`): Optional. New version of a message.
        channel_post (:class:`telegram.Message`): Optional. New incoming channel post.
        edited_channel_post (:class:`telegram.Message`): Optional. New version of a channel post.
        inline_query (:class:`telegram.InlineQuery`): Optional. New incoming inline query.
        chosen_inline_result (:class:`telegram.ChosenInlineResult`): Optional. The result of an
            inline query that was chosen by a user.
        callback_query (:class:`telegram.CallbackQuery`): Optional. New incoming callback query.
        shipping_query (:class:`telegram.ShippingQuery`): Optional. New incoming shipping query.
        pre_checkout_query (:class:`telegram.PreCheckoutQuery`): Optional. New incoming
            pre-checkout query.
        poll (:class:`telegram.Poll`): Optional. New poll state. Bots receive only updates
            about stopped polls and polls, which are sent by the bot.
        poll_answer (:class:`telegram.PollAnswer`): Optional. A user changed their answer
            in a non-anonymous poll. Bots receive new votes only in polls that were sent
            by the bot itself.
        my_chat_member (:class:`telegram.ChatMemberUpdated`): Optional. The bot's chat member
            status was updated in a chat. For private chats, this update is received only when the
            bot is blocked or unblocked by the user.

            .. versionadded:: 13.4
        chat_member (:class:`telegram.ChatMemberUpdated`): Optional. A chat member's status was
            updated in a chat. The bot must be an administrator in the chat and must explicitly
            specify ``'chat_member'`` in the list of ``'allowed_updates'`` to receive these
            updates (see :meth:`telegram.Bot.get_updates`, :meth:`telegram.Bot.set_webhook`,
            :meth:`telegram.ext.Updater.start_polling` and
            :meth:`telegram.ext.Updater.start_webhook`).

            .. versionadded:: 13.4
        chat_join_request (:class:`telegram.ChatJoinRequest`): Optional. A request to join the
            chat has been sent. The bot must have the ``'can_invite_users'`` administrator
            right in the chat to receive these updates.

            .. versionadded:: 13.8

    )callback_querychosen_inline_resultpre_checkout_queryinline_query	update_idmessageshipping_querypollpoll_answerchannel_postedited_channel_postedited_message_effective_user_effective_chat_effective_messagemy_chat_memberchat_memberchat_join_request	_id_attrsN)r   r   r!   r   r    r   r   r   r   r   r   r   r%   r&   r'   _kwargsc                 K   s~   t || _|| _|| _|| _|| _|| _|	| _|
| _|| _	|| _
|| _|| _|| _|| _|| _d | _d | _d | _| jf| _d S )N)intr   r   r!   r   r   r   r   r   r   r    r   r   r%   r&   r'   r"   r#   r$   r(   )selfr   r   r!   r   r    r   r   r   r   r   r   r   r%   r&   r'   r)    r,   3/tmp/pip-unpacked-wheel-2u9rcp5s/telegram/update.py__init__   s&    
zUpdate.__init__r   )returnc                 C   s   | j r| j S d}| jr | jj}n| jr0| jj}n| jr@| jj}n~| jrP| jj}nn| jr`| jj}n^| jrp| jj}nN| jr| jj}n>| j	r| j	j
}n.| jr| jj}n| jr| jj}n| jr| jj}|| _ |S )z
        :class:`telegram.User`: The user that sent this update, no matter what kind of update this
            is. Will be :obj:`None` for :attr:`channel_post` and :attr:`poll`.

        N)r"   r   Z	from_userr!   r   r   r   r   r   r   userr%   r&   r'   )r+   r0   r,   r,   r-   effective_user
  s6    









zUpdate.effective_userr   c                 C   s   | j r| j S d}| jr | jj}nx| jr0| jj}nh| jrJ| jjrJ| jjj}nN| jrZ| jj}n>| jrj| jj}n.| jrz| jj}n| jr| jj}n| j	r| j	j}|| _ |S )a{  
        :class:`telegram.Chat`: The chat that this update was sent in, no matter what kind of
            update this is. Will be :obj:`None` for :attr:`inline_query`,
            :attr:`chosen_inline_result`, :attr:`callback_query` from inline messages,
            :attr:`shipping_query`, :attr:`pre_checkout_query`, :attr:`poll` and
            :attr:`poll_answer`.

        N)
r#   r   chatr!   r   r   r    r%   r&   r'   )r+   r2   r,   r,   r-   effective_chat:  s*    






zUpdate.effective_chatc                 C   s`   | j r| j S d}| jr| j}n8| jr,| j}n*| jr<| jj}n| jrJ| j}n| jrV| j}|| _ |S )aT  
        :class:`telegram.Message`: The message included in this update, no matter what kind of
            update this is. Will be :obj:`None` for :attr:`inline_query`,
            :attr:`chosen_inline_result`, :attr:`callback_query` from inline messages,
            :attr:`shipping_query`, :attr:`pre_checkout_query`, :attr:`poll`,
            :attr:`poll_answer`, :attr:`my_chat_member`, :attr:`chat_member` as well as
            :attr:`chat_join_request` in case the bot is missing the
            :attr:`telegram.ChatPermissions.can_invite_users` administrator right in the chat.

        N)r$   r   r!   r   r   r    )r+   r   r,   r,   r-   effective_messaged  s    
zUpdate.effective_messager   )databotr/   c                 C   sP  |  |}|sdS t|d||d< t|d||d< t|d||d< t|d||d< t|d||d< t|d||d< t|d||d< t|d	||d	< t|d
||d
< t	|d||d< t
|d||d< t|d||d< t|d||d< t|d||d< | f |S )z,See :meth:`telegram.TelegramObject.de_json`.Nr   r!   r   r   r   r   r   r   r    r   r   r%   r&   r'   )Z_parse_datar   de_jsongetr   r   r   r   r
   r	   r   r   r   )clsr5   r6   r,   r,   r-   r7     s*    
 zUpdate.de_json)NNNNNNNNNNNNNN)9__name__
__module____qualname____doc__	__slots__r   ZUPDATE_MESSAGEZMESSAGEZUPDATE_EDITED_MESSAGEZEDITED_MESSAGEZUPDATE_CHANNEL_POSTZCHANNEL_POSTZUPDATE_EDITED_CHANNEL_POSTZEDITED_CHANNEL_POSTZUPDATE_INLINE_QUERYZINLINE_QUERYZUPDATE_CHOSEN_INLINE_RESULTZCHOSEN_INLINE_RESULTZUPDATE_CALLBACK_QUERYZCALLBACK_QUERYZUPDATE_SHIPPING_QUERYZSHIPPING_QUERYZUPDATE_PRE_CHECKOUT_QUERYZPRE_CHECKOUT_QUERYZUPDATE_POLLZPOLLZUPDATE_POLL_ANSWERZPOLL_ANSWERZUPDATE_MY_CHAT_MEMBERZMY_CHAT_MEMBERZUPDATE_CHAT_MEMBERZCHAT_MEMBERZUPDATE_CHAT_JOIN_REQUESTZCHAT_JOIN_REQUESTZUPDATE_ALL_TYPESZ	ALL_TYPESr*   r   r   r   r   r   r
   r	   r   r   r   r   r.   propertyr   r1   r3   r4   classmethodr   r7   r,   r,   r,   r-   r   +   sr   `              +/)"r   N)r=   typingr   r   r   Ztelegramr   r   r   r   r	   r
   r   r   r   r   r   Ztelegram.pollr   Ztelegram.utils.typesr   r   r   r   r   r,   r,   r,   r-   <module>   s   4