o
    ZzjÔ(  ã                   @   sØ   d 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 er*d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ÚFinal)Ú	constants)ÚTelegramObject)Úenum)Ú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œde	ded
B f‡ fdd„Zeddedddd f‡ 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_kwargsr
   r   c                   s6   t ƒ j|d� t tj||¡| _| jf| _|  ¡  d S )Nr   )	ÚsuperÚ__init__r   Ú
get_memberr   ÚBotCommandScopeTyper
   Ú	_id_attrsÚ_freeze)Úselfr
   r   ©Ú	__class__© úT/var/www/kodo/tsheker/venv/lib/python3.10/site-packages/telegram/_botcommandscope.pyr   P   s   
zBotCommandScope.__init__ÚdataÚbotz
Bot | NoneÚreturnc                    sv   |   |¡}| jt| jt| jt| jt| j	t
| jt| jti}| tu r3| d¡|v r3|| d¡ j||d�S tƒ j||d�S )a6  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`, optional): The bot associated with this object. Defaults to
                :obj:`None`, in which case shortcut methods will not be available.

                .. versionchanged:: 21.4
                   :paramref:`bot` is now optional and defaults to :obj:`None`

        Returns:
            The Telegram object.

        r
   )r   r    )Ú_parse_datar   ÚBotCommandScopeDefaultr   ÚBotCommandScopeAllPrivateChatsr   ÚBotCommandScopeAllGroupChatsr   Ú$BotCommandScopeAllChatAdministratorsr   ÚBotCommandScopeChatr   Ú!BotCommandScopeChatAdministratorsr   ÚBotCommandScopeChatMemberr	   ÚgetÚpopÚde_jsonr   )Úclsr   r    Ú_class_mappingr   r   r   r,   W   s   
ù
zBotCommandScope.de_json)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r   r   r   ÚstrÚ__annotations__r   r   r   r   r   r   r   r   Úclassmethodr,   Ú__classcell__r   r   r   r   r	   !   s(   
  &r	   c                       ó4   e Zd ZdZdZddœdedB f‡ 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   r   c                   ó   t ƒ jtj|d� |  ¡  d S ©N©r
   r   )r   r   r	   r   r   ©r   r   r   r   r   r   †   ó   zBotCommandScopeDefault.__init__©r/   r0   r1   r2   r3   r   r   r7   r   r   r   r   r#   y   s    
$r#   c                       r8   )r$   zÑRepresents 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   r   c                   r9   r:   )r   r   r	   r   r   r<   r   r   r   r   –   r=   z'BotCommandScopeAllPrivateChats.__init__r>   r   r   r   r   r$   ‹   s    $r$   c                       r8   )r%   zÛRepresents 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   r   c                   r9   r:   )r   r   r	   r   r   r<   r   r   r   r   ¥   r=   z%BotCommandScopeAllGroupChats.__init__r>   r   r   r   r   r%   ›   ó    $r%   c                       r8   )r&   zñRepresents 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   r   c                   r9   r:   )r   r   r	   r   r   r<   r   r   r   r   ´   r=   z-BotCommandScopeAllChatAdministrators.__init__r>   r   r   r   r   r&   ª   r?   r&   c                       ó<   e Zd ZdZdZddœdeeB dedB f‡ 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   rB   r   c                   óp   t ƒ jtj|d� |  ¡ �! t|tƒr| d¡r|nt|ƒ| _	| j
| j	f| _W d   ƒ d S 1 s1w   Y  d S ©Nr;   ú@)r   r   r	   r   Ú	_unfrozenÚ
isinstancer4   Ú
startswithÚintrB   r
   r   ©r   rB   r   r   r   r   r   Ë   ó   
ÿ"üzBotCommandScopeChat.__init__©
r/   r0   r1   r2   r3   r4   rI   r   r   r7   r   r   r   r   r'   ¹   ó    ,r'   c                       r@   )	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|
    rA   Nr   rB   r   c                   rC   rD   )r   r   r	   r   rF   rG   r4   rH   rI   rB   r
   r   rJ   r   r   r   r   æ   rK   z*BotCommandScopeChatAdministrators.__init__rL   r   r   r   r   r(   Ô   rM   r(   c                       s@   e Zd ZdZdZddœdeeB dededB f‡ 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.
    )rB   Úuser_idNr   rB   rN   r   c                   sz   t ƒ jtj|d� |  ¡ �& t|tƒr| d¡r|nt|ƒ| _	|| _
| j| j	| j
f| _W d   ƒ d S 1 s6w   Y  d S rD   )r   r   r	   r   rF   rG   r4   rH   rI   rB   rN   r
   r   )r   rB   rN   r   r   r   r   r     s   
ÿ"ûz"BotCommandScopeChatMember.__init__rL   r   r   r   r   r)   ï   s    0r)   N)r2   Útypingr   r   Útelegramr   Útelegram._telegramobjectr   Útelegram._utilsr   Útelegram._utils.typesr   r   r	   r#   r$   r%   r&   r'   r(   r)   r   r   r   r   Ú<module>   s    X