Added dynamic scope chat_id for owner

This commit is contained in:
Profitroll 2023-06-21 13:45:01 +02:00
parent 0cfe55d3c9
commit 524a3c2a29
Signed by: profitroll
GPG Key ID: FA35CAB49DACD3B2
2 changed files with 5 additions and 1 deletions

View File

@ -139,6 +139,10 @@ class PyroClient(Client):
# Make flat key a dict again # Make flat key a dict again
scope_dict = loads(scope) scope_dict = loads(scope)
# Replace "owner" in the bot scope with owner's id
if "chat_id" in scope_dict and scope_dict["chat_id"] == "owner":
scope_dict["chat_id"] = self.owner
# Create object with the same name and args from the dict # Create object with the same name and args from the dict
try: try:
scope_obj = globals()[scope_dict["name"]]( scope_obj = globals()[scope_dict["name"]](

View File

@ -20,7 +20,7 @@
"scopes": [ "scopes": [
{ {
"name": "BotCommandScopeChat", "name": "BotCommandScopeChat",
"chat_id": 0 "chat_id": "owner"
} }
] ]
} }