diff --git a/telebot/types.py b/telebot/types.py index 19a6e0f..8688132 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -2,6 +2,7 @@ import logging from typing import Dict, List, Optional, Union +from abc import ABC try: import ujson as json @@ -1279,8 +1280,19 @@ class BotCommand(JsonSerializable, JsonDeserializable): # BotCommandScopes -class BotCommandScope(JsonSerializable): +class BotCommandScope(ABC, JsonSerializable): def __init__(self, type='default', chat_id=None, user_id=None): + """ + Abstract class. + Use BotCommandScopeX classes to set a specific scope type: + BotCommandScopeDefault + BotCommandScopeAllPrivateChats + BotCommandScopeAllGroupChats + BotCommandScopeAllChatAdministrators + BotCommandScopeChat + BotCommandScopeChatAdministrators + BotCommandScopeChatMember + """ self.type: str = type self.chat_id: Optional[Union[int, str]] = chat_id self.user_id: Optional[Union[int, str]] = user_id @@ -1296,21 +1308,34 @@ class BotCommandScope(JsonSerializable): class BotCommandScopeDefault(BotCommandScope): def __init__(self): + """ + Represents the default scope of bot commands. + Default commands are used if no commands with a narrower scope are specified for the user. + """ super(BotCommandScopeDefault, self).__init__(type='default') class BotCommandScopeAllPrivateChats(BotCommandScope): def __init__(self): + """ + Represents the scope of bot commands, covering all private chats. + """ super(BotCommandScopeAllPrivateChats, self).__init__(type='all_private_chats') class BotCommandScopeAllGroupChats(BotCommandScope): def __init__(self): + """ + Represents the scope of bot commands, covering all group and supergroup chats. + """ super(BotCommandScopeAllGroupChats, self).__init__(type='all_group_chats') class BotCommandScopeAllChatAdministrators(BotCommandScope): def __init__(self): + """ + Represents the scope of bot commands, covering all group and supergroup chat administrators. + """ super(BotCommandScopeAllChatAdministrators, self).__init__(type='all_chat_administrators') @@ -1321,11 +1346,20 @@ class BotCommandScopeChat(BotCommandScope): class BotCommandScopeChatAdministrators(BotCommandScope): def __init__(self, chat_id=None): + """ + Represents the scope of bot commands, covering a specific chat. + @param chat_id: Unique identifier for the target chat + """ super(BotCommandScopeChatAdministrators, self).__init__(type='chat_administrators', chat_id=chat_id) class BotCommandScopeChatMember(BotCommandScope): def __init__(self, chat_id=None, user_id=None): + """ + Represents the scope of bot commands, covering all administrators of a specific group or supergroup chat + @param chat_id: Unique identifier for the target chat + @param user_id: Unique identifier of the target user + """ super(BotCommandScopeChatMember, self).__init__(type='chat_administrators', chat_id=chat_id, user_id=user_id)