U
    g7?                     @   sz   d Z ddlZddl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 eG d	d
 d
ZdS )z\This module contains the class Defaults, which allows passing default values to Application.    N)AnyDictNoReturnOptionalfinal)LinkPreviewOptions)UTC)ODVInput)warn)PTBDeprecationWarningc                   @   s  e Zd ZdZdZddddedddddf
ee ee ee ee e	j
eee ee ed ee d
ddZed	d
dZeedddZeeeef d	ddZeee d	ddZejeedddZeee d	ddZejeedddZeee d	ddZejeedddZeee d	ddZejeedddZeee d	ddZejeedd dZeee d	d!d"Zejeedd#d"Zeee d	d$d%Zejeedd&d%Zeee d	d'd(Zejeedd)d(Zeee d	d*d+Zejeedd,d+Zee	j
d	d-d.Z
e
jeedd/d.Z
eed	d0d1Z e jeedd2d1Z eee d	d3d4Z!e!jeedd5d4Z!eed d	d6d7Z"eee d	d8d9Z#dS ):DefaultsaT  Convenience Class to gather all parameters with a (user defined) default value

    .. seealso:: :wiki:`Architecture Overview <Architecture>`,
        :wiki:`Adding Defaults to Your Bot <Adding-defaults-to-your-bot>`

    .. versionchanged:: 20.0
        Removed the argument and attribute ``timeout``. Specify default timeout behavior for the
        networking backend directly via :class:`telegram.ext.ApplicationBuilder` instead.

    Parameters:
        parse_mode (:obj:`str`, optional): |parse_mode|
        disable_notification (:obj:`bool`, optional): |disable_notification|
        disable_web_page_preview (:obj:`bool`, optional): Disables link previews for links in this
            message. Mutually exclusive with :paramref:`link_preview_options`.

            .. deprecated:: 20.8
                Use :paramref:`link_preview_options` instead. This parameter will be removed in
                future versions.

        allow_sending_without_reply (:obj:`bool`, optional): |allow_sending_without_reply|.
            Will be used for :attr:`telegram.ReplyParameters.allow_sending_without_reply`.
        quote (:obj:`bool`, optional): |reply_quote|

            .. deprecated:: 20.8
                Use :paramref:`do_quote` instead. This parameter will be removed in future
                versions.
        tzinfo (:class:`datetime.tzinfo`, optional): A timezone to be used for all date(time)
            inputs appearing throughout PTB, i.e. if a timezone naive date(time) object is passed
            somewhere, it will be assumed to be in :paramref:`tzinfo`. If the
            :class:`telegram.ext.JobQueue` is used, this must be a timezone provided
            by the ``pytz`` module. Defaults to ``pytz.utc``, if available, and
            :attr:`datetime.timezone.utc` otherwise.
        block (:obj:`bool`, optional): Default setting for the :paramref:`BaseHandler.block`
            parameter
            of handlers and error handlers registered through :meth:`Application.add_handler` and
            :meth:`Application.add_error_handler`. Defaults to :obj:`True`.
        protect_content (:obj:`bool`, optional): |protect_content|

            .. versionadded:: 20.0
        link_preview_options (:class:`telegram.LinkPreviewOptions`, optional):
            Link preview generation options for all outgoing messages. Mutually exclusive with
            :paramref:`disable_web_page_preview`.
            This object is used for the corresponding parameter of
            :meth:`telegram.Bot.send_message`, :meth:`telegram.Bot.edit_message_text`,
            and :class:`telegram.InputTextMessageContent` if not specified. If a value is specified
            for the corresponding parameter, only those parameters of
            :class:`telegram.LinkPreviewOptions` will be overridden that are not
            explicitly set.

            Example:

                .. code-block:: python

                    from telegram import LinkPreviewOptions
                    from telegram.ext import Defaults, ExtBot

                    defaults = Defaults(
                        link_preview_options=LinkPreviewOptions(show_above_text=True)
                    )
                    chat_id = 123

                    async def main():
                        async with ExtBot("Token", defaults=defaults) as bot:
                            # The link preview will be shown above the text.
                            await bot.send_message(chat_id, "https://python-telegram-bot.org")

                            # The link preview will be shown below the text.
                            await bot.send_message(
                                chat_id,
                                "https://python-telegram-bot.org",
                                link_preview_options=LinkPreviewOptions(show_above_text=False)
                            )

                            # The link preview will be shown above the text, but the preview will
                            # show Telegram.
                            await bot.send_message(
                                chat_id,
                                "https://python-telegram-bot.org",
                                link_preview_options=LinkPreviewOptions(url="https://telegram.org")
                            )

            .. versionadded:: 20.8
        do_quote(:obj:`bool`, optional): |reply_quote|

            .. versionadded:: 20.8
    )	_allow_sending_without_reply_api_defaults_block_disable_notification	_do_quote_link_preview_options_parse_mode_protect_content_tzinfoNTr   )

parse_modedisable_notificationdisable_web_page_previewquotetzinfoblockallow_sending_without_replyprotect_contentlink_preview_optionsdo_quotec                 C   s   || _ || _|| _|| _|| _|| _|d k	r<|	d k	r<td|d k	rT|
d k	rTtd|d k	r|ttdddd t	|d| _
n|	| _
|d k	rttdddd || _n|
| _i | _d	D ] }t| |}|d k	r|| j|< qd S )
NzM`disable_web_page_preview` and `link_preview_options` are mutually exclusive.z-`quote` and `do_quote` are mutually exclusivez20.8z_`Defaults.disable_web_page_preview` is deprecated. Use `Defaults.link_preview_options` instead.   )
stacklevel)is_disabledz@`Defaults.quote` is deprecated. Use `Defaults.do_quote` instead.)r   r   r   explanation_parse_moder   r   r   question_parse_mode)r   r   r   r   r   r   
ValueErrorr
   r   r   r   r   r   getattr)selfr   r   r   r   r   r   r   r   r   r   kwargvalue r*   :/tmp/pip-unpacked-wheel-swnnwir2/telegram/ext/_defaults.py__init__   sN    
 

zDefaults.__init__)returnc              	   C   s(   t | j| j| j| j| j| j| j| jfS )zBuilds a hash value for this object such that the hash of two objects is equal if and
        only if the objects are equal in terms of :meth:`__eq__`.

        Returns:
            :obj:`int` The hash value of the object.
        )	hashr   r   r   r   r   r   r   r   r'   r*   r*   r+   __hash__   s    zDefaults.__hash__)otherr-   c                    s(   t  tr$t fddjD S dS )a"  Defines equality condition for the :class:`Defaults` object.
        Two objects of this class are considered to be equal if all their parameters
        are identical.

        Returns:
            :obj:`True` if both objects have all parameters identical. :obj:`False` otherwise.
        c                 3   s"   | ]}t |t  |kV  qd S N)r&   ).0attrr1   r'   r*   r+   	<genexpr>   s     z"Defaults.__eq__.<locals>.<genexpr>F)
isinstancer   all	__slots__)r'   r1   r*   r5   r+   __eq__   s    
zDefaults.__eq__c                 C   s   | j S r2   )r   r/   r*   r*   r+   api_defaults   s    zDefaults.api_defaultsc                 C   s   | j S )z:obj:`str`: Optional. Send Markdown or HTML, if you want Telegram apps to show
        bold, italic, fixed-width text or URLs in your bot's message.
        r   r/   r*   r*   r+   r      s    zDefaults.parse_mode)_r-   c                 C   s   t dd S )NzBYou can not assign a new value to parse_mode after initialization.AttributeErrorr'   r=   r*   r*   r+   r      s    c                 C   s   | j S )z:obj:`str`: Optional. Alias for :attr:`parse_mode`, used for
        the corresponding parameter of :meth:`telegram.Bot.send_poll`.
        r<   r/   r*   r*   r+   r#      s    zDefaults.explanation_parse_modec                 C   s   t dd S )NzNYou can not assign a new value to explanation_parse_mode after initialization.r>   r@   r*   r*   r+   r#      s    c                 C   s   | j S )z:obj:`str`: Optional. Alias for :attr:`parse_mode`, used for
        the corresponding parameter of :meth:`telegram.ReplyParameters`.
        r<   r/   r*   r*   r+   quote_parse_mode  s    zDefaults.quote_parse_modec                 C   s   t dd S )NzHYou can not assign a new value to quote_parse_mode after initialization.r>   r@   r*   r*   r+   rA   	  s    c                 C   s   | j S )z:obj:`str`: Optional. Alias for :attr:`parse_mode`, used for
        the corresponding parameter of :class:`telegram.InputPollOption`.

        .. versionadded:: 21.2
        r<   r/   r*   r*   r+   text_parse_mode  s    zDefaults.text_parse_modec                 C   s   t dd S )NzGYou can not assign a new value to text_parse_mode after initialization.r>   r@   r*   r*   r+   rB     s    c                 C   s   | j S )z:obj:`str`: Optional. Alias for :attr:`parse_mode`, used for
        the corresponding parameter of :meth:`telegram.Bot.send_poll`.

        .. versionadded:: 21.2
        r<   r/   r*   r*   r+   r$     s    zDefaults.question_parse_modec                 C   s   t dd S )NzKYou can not assign a new value to question_parse_mode after initialization.r>   r@   r*   r*   r+   r$   '  s    c                 C   s   | j S )zt:obj:`bool`: Optional. Sends the message silently. Users will
        receive a notification with no sound.
        )r   r/   r*   r*   r+   r   -  s    zDefaults.disable_notificationc                 C   s   t dd S )NzLYou can not assign a new value to disable_notification after initialization.r>   r@   r*   r*   r+   r   4  s    c                 C   s   | j r| j jS dS )z:obj:`bool`: Optional. Disables link previews for links in all outgoing
        messages.

        .. deprecated:: 20.8
            Use :attr:`link_preview_options` instead. This attribute will be removed in future
            versions.
        N)r   r"   r/   r*   r*   r+   r   :  s    	z!Defaults.disable_web_page_previewc                 C   s   t dd S )NzPYou can not assign a new value to disable_web_page_preview after initialization.r>   r@   r*   r*   r+   r   E  s    c                 C   s   | j S )z:obj:`bool`: Optional. Pass :obj:`True`, if the message
        should be sent even if the specified replied-to message is not found.
        )r   r/   r*   r*   r+   r   K  s    z$Defaults.allow_sending_without_replyc                 C   s   t dd S )NzSYou can not assign a new value to allow_sending_without_reply after initialization.r>   r@   r*   r*   r+   r   R  s    c                 C   s   | j dk	r| j S dS )z:obj:`bool`: Optional. |reply_quote|

        .. deprecated:: 20.8
            Use :attr:`do_quote` instead. This attribute will be removed in future
            versions.
        Nr   r/   r*   r*   r+   r   X  s    zDefaults.quotec                 C   s   t dd S )Nz=You can not assign a new value to quote after initialization.r>   r@   r*   r*   r+   r   b  s    c                 C   s   | j S )zj:obj:`tzinfo`: A timezone to be used for all date(time) objects appearing
        throughout PTB.
        )r   r/   r*   r*   r+   r   f  s    zDefaults.tzinfoc                 C   s   t dd S )Nz>You can not assign a new value to tzinfo after initialization.r>   r@   r*   r*   r+   r   m  s    c                 C   s   | j S )z:obj:`bool`: Optional. Default setting for the :paramref:`BaseHandler.block` parameter
        of handlers and error handlers registered through :meth:`Application.add_handler` and
        :meth:`Application.add_error_handler`.
        )r   r/   r*   r*   r+   r   q  s    zDefaults.blockc                 C   s   t dd S )Nz=You can not assign a new value to block after initialization.r>   r@   r*   r*   r+   r   y  s    c                 C   s   | j S )z:obj:`bool`: Optional. Protects the contents of the sent message from forwarding and
        saving.

        .. versionadded:: 20.0
        )r   r/   r*   r*   r+   r   }  s    zDefaults.protect_contentc                 C   s   t dd S )NzEYou can't assign a new value to protect_content after initialization.r>   r@   r*   r*   r+   r     s    c                 C   s   | j S )z:class:`telegram.LinkPreviewOptions`: Optional. Link preview generation options for all
        outgoing messages.

        .. versionadded:: 20.8
        )r   r/   r*   r*   r+   r     s    zDefaults.link_preview_optionsc                 C   s   | j S )zM:obj:`bool`: Optional. |reply_quote|

        .. versionadded:: 20.8
        rC   r/   r*   r*   r+   r     s    zDefaults.do_quote)$__name__
__module____qualname____doc__r9   r   r   strbooldatetimer   r,   intr0   objectr:   propertyr   r   r;   r   setterr   r#   rA   rB   r$   r   r	   r   r   r   r   r   r   r   r*   r*   r*   r+   r      s   WC
	r   )rG   rJ   typingr   r   r   r   r   Ztelegramr   Ztelegram._utils.datetimer   Ztelegram._utils.typesr	   Ztelegram._utils.warningsr
   Ztelegram.warningsr   r   r*   r*   r*   r+   <module>   s   