U
    2tc&                     @   s   d Z ddlmZmZmZmZmZmZ ddlm	Z	m
Z
 ddlmZ erPd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.    )AnyUnionOptionalTYPE_CHECKINGDictType)TelegramObject	constants)JSONDict)Botc                   @   sl   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edddZeee ded  ddd	Zd
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	_id_attrs)r   _kwargsc                 K   s   || _ | j f| _d S )Nr   )selfr   r    r   </tmp/pip-unpacked-wheel-2u9rcp5s/telegram/botcommandscope.py__init__M   s    zBotCommandScope.__init__r   )databotreturnc                 C   sp   |  |}|sdS | jt| jt| jt| jt| j	t
| jt| jti}| tkrf||d | f |d|iS | f |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   )Z_parse_dataDEFAULTBotCommandScopeDefaultALL_PRIVATE_CHATSBotCommandScopeAllPrivateChatsALL_GROUP_CHATSBotCommandScopeAllGroupChatsALL_CHAT_ADMINISTRATORS$BotCommandScopeAllChatAdministratorsCHATBotCommandScopeChatCHAT_ADMINISTRATORS!BotCommandScopeChatAdministratorsCHAT_MEMBERBotCommandScopeChatMemberr   get)clsr   r   Z_class_mappingr   r   r   de_jsonQ   s*    
       
zBotCommandScope.de_jsonN)__name__
__module____qualname____doc__	__slots__r	   ZBOT_COMMAND_SCOPE_DEFAULTr   Z#BOT_COMMAND_SCOPE_ALL_PRIVATE_CHATSr   Z!BOT_COMMAND_SCOPE_ALL_GROUP_CHATSr   Z)BOT_COMMAND_SCOPE_ALL_CHAT_ADMINISTRATORSr   ZBOT_COMMAND_SCOPE_CHATr    Z%BOT_COMMAND_SCOPE_CHAT_ADMINISTRATORSr"   ZBOT_COMMAND_SCOPE_CHAT_MEMBERr$   strr   r   classmethodr   r
   r(   r   r   r   r   r      s   r   c                       s*   e Zd ZdZdZed fddZ  ZS )r   al  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 :attr:`telegram.BotCommandScope.DEFAULT`.
    r   r   c                    s   t  jtjd d S Nr   )superr   r   r   r   r   	__class__r   r   r      s    zBotCommandScopeDefault.__init__r)   r*   r+   r,   r-   r   r   __classcell__r   r   r5   r   r   r   s   r   c                       s*   e Zd ZdZdZ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 :attr:`telegram.BotCommandScope.ALL_PRIVATE_CHATS`.
    r   r0   c                    s   t  jtjd d S r1   )r3   r   r   r   r4   r5   r   r   r      s    z'BotCommandScopeAllPrivateChats.__init__r7   r   r   r5   r   r      s   r   c                       s*   e Zd ZdZdZ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 :attr:`telegram.BotCommandScope.ALL_GROUP_CHATS`.
    r   r0   c                    s   t  jtjd d S r1   )r3   r   r   r   r4   r5   r   r   r      s    z%BotCommandScopeAllGroupChats.__init__r7   r   r   r5   r   r      s   r   c                       s*   e Zd ZdZdZ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 :attr:`telegram.BotCommandScope.ALL_CHAT_ADMINISTRATORS`.
    r   r0   c                    s   t  jtjd d S r1   )r3   r   r   r   r4   r5   r   r   r      s    z-BotCommandScopeAllChatAdministrators.__init__r7   r   r   r5   r   r      s   r   c                       s4   e Zd ZdZdZ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`): Unique identifier for the target chat or username of the
            target supergroup (in the format ``@supergroupusername``)

    Attributes:
        type (:obj:`str`): Scope type :attr:`telegram.BotCommandScope.CHAT`.
        chat_id (:obj:`str` | :obj:`int`): Unique identifier for the target chat or username of the
            target supergroup (in the format ``@supergroupusername``)
    chat_idr:   r   c                    sD   t  jtjd t|tr(|dr(|nt|| _| j	| jf| _
d S Nr2   @)r3   r   r   r    
isinstancer.   
startswithintr:   r   r   r   r:   r   r5   r   r   r      s    zBotCommandScopeChat.__init__r)   r*   r+   r,   r-   r   r.   r@   r   r   r8   r   r   r5   r   r!      s   r!   c                       s4   e Zd ZdZdZ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`): Unique identifier for the target chat or username of the
            target supergroup (in the format ``@supergroupusername``)

    Attributes:
        type (:obj:`str`): Scope type :attr:`telegram.BotCommandScope.CHAT_ADMINISTRATORS`.
        chat_id (:obj:`str` | :obj:`int`): Unique identifier for the target chat or username of the
            target supergroup (in the format ``@supergroupusername``)
    r9   r;   c                    sD   t  jtjd t|tr(|dr(|nt|| _| j	| jf| _
d S r<   )r3   r   r   r"   r>   r.   r?   r@   r:   r   r   rA   r5   r   r   r      s    z*BotCommandScopeChatAdministrators.__init__rB   r   r   r5   r   r#      s   r#   c                       s6   e Zd ZdZdZ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`): Unique identifier for the target chat or username of the
            target supergroup (in the format ``@supergroupusername``)
        user_id (:obj:`int`): Unique identifier of the target user.

    Attributes:
        type (:obj:`str`): Scope type :attr:`telegram.BotCommandScope.CHAT_MEMBER`.
        chat_id (:obj:`str` | :obj:`int`): Unique identifier for the target chat or username of the
            target supergroup (in the format ``@supergroupusername``)
        user_id (:obj:`int`): Unique identifier of the target user.
    )r:   user_id)r:   rC   r   c                    sR   t  jtjd t|tr(|dr(|nt|| _t|| _	| j
| j| j	f| _d S r<   )r3   r   r   r$   r>   r.   r?   r@   r:   rC   r   r   )r   r:   rC   r   r5   r   r   r     s
    
z"BotCommandScopeChatMember.__init__rB   r   r   r5   r   r%      s   r%   N)r,   typingr   r   r   r   r   r   Ztelegramr   r	   Ztelegram.utils.typesr
   r   r   r   r   r   r   r!   r#   r%   r   r   r   r   <module>   s    T