1717# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818
1919from pyrogram import raw
20+
2021from ..object import Object
2122
2223
@@ -26,7 +27,7 @@ class BotCommand(Object):
2627 Parameters:
2728 command (``str``):
2829 The bot command, for example: "/start".
29-
30+
3031 description (``str``):
3132 Description of the bot command.
3233 """
@@ -40,5 +41,74 @@ def __init__(self, command: str, description: str):
4041 def write (self ):
4142 return raw .types .BotCommand (
4243 command = self .command ,
43- description = self .description
44+ description = self .description ,
4445 )
46+
47+
48+ class BotCommandScope (Object ):
49+ """
50+ Represents a scope where the bot commands, specified
51+ using bots.setBotCommands will be valid.
52+
53+ Parameters:
54+ scope (``str``):
55+
56+ - DEFAULT: The commands will be valid in all chats (default value)
57+
58+ - PRIVATE: The specified bot commands will only be valid in all private
59+ chats with users.
60+
61+ - GROUP: The specified bot commands will be valid in all groups and supergroups
62+
63+ - GROUP_ADMINS: The specified bot commands will be valid only for chat
64+ administrators, in all groups and supergroups.
65+
66+ - PEER: The specified bot commands will be valid only in a specific dialog
67+
68+ - PEER_ADMINS: The specified bot commands will be valid for all admins of the
69+ specified group or supergroup.
70+
71+ - PEER_USER: The specified bot commands will be valid only for a specific user
72+ in the specified chat
73+ """
74+
75+ DEFAULT = "default"
76+ PRIVATE = "users"
77+ GROUP = "chats"
78+ GROUP_ADMINS = "chat_admins"
79+ PEER = "peer"
80+ PEER_ADMINS = "peer_admins"
81+ PEER_USER = "peer_user"
82+
83+ raw_scopes = {
84+ DEFAULT : raw .types .BotCommandScopeDefault ,
85+ PRIVATE : raw .types .BotCommandScopeUsers ,
86+ GROUP : raw .types .BotCommandScopeChats ,
87+ GROUP_ADMINS : raw .types .BotCommandScopeChatAdmins ,
88+ PEER : lambda peer : raw .types .BotCommandScopePeer (peer ),
89+ PEER_ADMINS : lambda peer : raw .types .BotCommandScopePeerAdmins (peer ),
90+ PEER_USER : lambda peer , user_id : raw .types .BotCommandScopePeerUser (
91+ peer , user_id
92+ ),
93+ }
94+
95+ def __init__ (
96+ self ,
97+ scope : str ,
98+ peer : raw .types .InputPeerUser = None ,
99+ user_id : raw .types .InputUser = None ,
100+ ):
101+ super ().__init__ ()
102+ self .scope = scope
103+ self .peer = peer
104+ self .user_id = user_id
105+
106+ def write (self ):
107+
108+ if self .scope in ["peer" , "peer_admins" ]:
109+ return self .raw_scopes [self .scope ](self .peer )
110+
111+ elif self .scope == "peer_user" :
112+ return self .raw_scopes [self .scopes ](self .peer , self .user_id )
113+
114+ return self .raw_scopes [self .scope ]()
0 commit comments