U
    dd'                     @   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 erXddlmZ G dd deZG d	d
 d
eZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZdS )zFThis module contains objects representing Telegram bot command scopes.    )TYPE_CHECKINGClassVarDictOptionalTypeUnion)	constants)TelegramObject)JSONDict)Botc                       s   e Zd ZU dZdZejjZee	 e
d< ejjZee	 e
d< ejjZee	 e
d< ejjZee	 e
d< ejjZee	 e
d< ejjZee	 e
d< ejjZee	 e
d	< d
de	ed fddZeee ded  d fddZ  ZS )BotCommandScopea/  Base class for objects that represent the scope to which bot commands are applied.
    Currently, the following 7 scopes are supported:

    * :class:`telegram.BotCommandScopeDefault`
    * :class:`telegram.BotCommandScopeAllPrivateChats`
    * :class:`telegram.BotCommandScopeAllGroupChats`
    * :class:`telegram.BotCommandScopeAllChatAdministrators`
    * :class:`telegram.BotCommandScopeChat`
    * :class:`telegram.BotCommandScopeChatAdministrators`
    * :class:`telegram.BotCommandScopeChatMember`

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`type` is equal. For subclasses with additional attributes,
    the notion of equality is overridden.

    Note:
        Please see the `official docs`_ on how Telegram determines which commands to display.

    .. _`official docs`: https://core.telegram.org/bots/api#determining-list-of-commands

    .. versionadded:: 13.7

    Args:
        type (:obj:`str`): Scope type.

    Attributes:
        type (:obj:`str`): Scope type.
    )typeDEFAULTALL_PRIVATE_CHATSALL_GROUP_CHATSALL_CHAT_ADMINISTRATORSCHATCHAT_ADMINISTRATORSCHAT_MEMBERN
api_kwargsr   r   c                   s*   t  j|d || _| jf| _|   d S )Nr   )super__init__r   	_id_attrs_freeze)selfr   r   	__class__ =/tmp/pip-unpacked-wheel-e3anp165/telegram/_botcommandscope.pyr   N   s    
zBotCommandScope.__init__r   )databotreturnc                    s~   |  |}|sdS | jt| jt| jt| jt| j	t
| jt| jti}| tkrn|d|krn||d j||dS t j||dS )aT  Converts JSON data to the appropriate :class:`BotCommandScope` object, i.e. takes
        care of selecting the correct subclass.

        Args:
            data (Dict[:obj:`str`, ...]): The JSON data.
            bot (:class:`telegram.Bot`): The bot associated with this object.

        Returns:
            The Telegram object.

        Nr   )r!   r"   )Z_parse_datar   BotCommandScopeDefaultr   BotCommandScopeAllPrivateChatsr   BotCommandScopeAllGroupChatsr   $BotCommandScopeAllChatAdministratorsr   BotCommandScopeChatr   !BotCommandScopeChatAdministratorsr   BotCommandScopeChatMemberr   getpopde_jsonr   )clsr!   r"   Z_class_mappingr   r   r    r-   U   s*    
       
zBotCommandScope.de_json)__name__
__module____qualname____doc__	__slots__r   ZBotCommandScopeTyper   r   str__annotations__r   r   r   r   r   r   r
   r   classmethodr   r-   __classcell__r   r   r   r    r      s   
r   c                       s0   e Zd ZdZdZdded fddZ  ZS )r$   ao  Represents the default scope of bot commands. Default commands are used if no commands with
    a `narrower scope`_ are specified for the user.

    .. _`narrower scope`: https://core.telegram.org/bots/api#determining-list-of-commands

    .. versionadded:: 13.7
    Attributes:
        type (:obj:`str`): Scope type :tg-const:`telegram.BotCommandScope.DEFAULT`.
    r   Nr   c                   s   t  jtj|d |   d S Nr   )r   r   r   r   r   r   r   r   r   r    r      s    zBotCommandScopeDefault.__init__r/   r0   r1   r2   r3   r
   r   r7   r   r   r   r    r$   v   s   
r$   c                       s0   e Zd ZdZdZdded fddZ  ZS )r%   zRepresents the scope of bot commands, covering all private chats.

    .. versionadded:: 13.7

    Attributes:
        type (:obj:`str`): Scope type :tg-const:`telegram.BotCommandScope.ALL_PRIVATE_CHATS`.
    r   Nr   c                   s   t  jtj|d |   d S r8   )r   r   r   r   r   r9   r   r   r    r      s    z'BotCommandScopeAllPrivateChats.__init__r:   r   r   r   r    r%      s   r%   c                       s0   e Zd ZdZdZdded fddZ  ZS )r&   zRepresents the scope of bot commands, covering all group and supergroup chats.

    .. versionadded:: 13.7
    Attributes:
        type (:obj:`str`): Scope type :tg-const:`telegram.BotCommandScope.ALL_GROUP_CHATS`.
    r   Nr   c                   s   t  jtj|d |   d S r8   )r   r   r   r   r   r9   r   r   r    r      s    z%BotCommandScopeAllGroupChats.__init__r:   r   r   r   r    r&      s   r&   c                       s0   e Zd ZdZdZdded fddZ  ZS )r'   zRepresents the scope of bot commands, covering all group and supergroup chat administrators.

    .. versionadded:: 13.7
    Attributes:
        type (:obj:`str`): Scope type :tg-const:`telegram.BotCommandScope.ALL_CHAT_ADMINISTRATORS`.
    r   Nr   c                   s   t  jtj|d |   d S r8   )r   r   r   r   r   r9   r   r   r    r      s    z-BotCommandScopeAllChatAdministrators.__init__r:   r   r   r   r    r'      s   r'   c                       s:   e Zd ZdZdZddeeef ed fddZ	  Z
S )r(   a  Represents the scope of bot commands, covering a specific chat.

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

    .. versionadded:: 13.7

    Args:
        chat_id (:obj:`str` | :obj:`int`): |chat_id_group|

    Attributes:
        type (:obj:`str`): Scope type :tg-const:`telegram.BotCommandScope.CHAT`.
        chat_id (:obj:`str` | :obj:`int`): |chat_id_group|
    chat_idNr   r<   r   c             	      sZ   t  jtj|d |  6 t|tr4|dr4|nt|| _	| j
| j	f| _W 5 Q R X d S Nr   @)r   r   r   r   	_unfrozen
isinstancer4   
startswithintr<   r   r   r   r<   r   r   r   r    r      s
    
zBotCommandScopeChat.__init__r/   r0   r1   r2   r3   r   r4   rC   r
   r   r7   r   r   r   r    r(      s   r(   c                       s:   e Zd ZdZdZddeeef ed fddZ	  Z
S )r)   a(  Represents the scope of bot commands, covering all administrators of a specific group or
    supergroup chat.

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

    .. versionadded:: 13.7

    Args:
        chat_id (:obj:`str` | :obj:`int`): |chat_id_group|
    Attributes:
        type (:obj:`str`): Scope type :tg-const:`telegram.BotCommandScope.CHAT_ADMINISTRATORS`.
        chat_id (:obj:`str` | :obj:`int`): |chat_id_group|
    r;   Nr   r=   c             	      sZ   t  jtj|d |  6 t|tr4|dr4|nt|| _	| j
| j	f| _W 5 Q R X d S r>   )r   r   r   r   r@   rA   r4   rB   rC   r<   r   r   rD   r   r   r    r      s
    
z*BotCommandScopeChatAdministrators.__init__rE   r   r   r   r    r)      s   r)   c                       s<   e Zd ZdZdZddeeef eed fddZ	  Z
S )r*   a  Represents the scope of bot commands, covering a specific member of a group or supergroup
    chat.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`type`, :attr:`chat_id` and :attr:`user_id` are equal.

    .. versionadded:: 13.7

    Args:
        chat_id (:obj:`str` | :obj:`int`): |chat_id_group|
        user_id (:obj:`int`): Unique identifier of the target user.

    Attributes:
        type (:obj:`str`): Scope type :tg-const:`telegram.BotCommandScope.CHAT_MEMBER`.
        chat_id (:obj:`str` | :obj:`int`): |chat_id_group|
        user_id (:obj:`int`): Unique identifier of the target user.
    )r<   user_idNr   )r<   rF   r   c             	      sd   t  jtj|d |  @ t|tr4|dr4|nt|| _	|| _
| j| j	| j
f| _W 5 Q R X d S r>   )r   r   r   r   r@   rA   r4   rB   rC   r<   rF   r   r   )r   r<   rF   r   r   r   r    r     s    
z"BotCommandScopeChatMember.__init__rE   r   r   r   r    r*      s   r*   N)r2   typingr   r   r   r   r   r   Ztelegramr   Ztelegram._telegramobjectr	   Ztelegram._utils.typesr
   r   r   r$   r%   r&   r'   r(   r)   r*   r   r   r   r    <module>   s    W