From 524a3c2a29735ceb71f8777dad6cb996b484bac1 Mon Sep 17 00:00:00 2001 From: profitroll Date: Wed, 21 Jun 2023 13:45:01 +0200 Subject: [PATCH] Added dynamic scope chat_id for owner --- classes/pyroclient.py | 4 ++++ config_example.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/classes/pyroclient.py b/classes/pyroclient.py index 636658b..6605c0e 100644 --- a/classes/pyroclient.py +++ b/classes/pyroclient.py @@ -139,6 +139,10 @@ class PyroClient(Client): # Make flat key a dict again 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 try: scope_obj = globals()[scope_dict["name"]]( diff --git a/config_example.json b/config_example.json index ad73d95..ca1a356 100644 --- a/config_example.json +++ b/config_example.json @@ -20,7 +20,7 @@ "scopes": [ { "name": "BotCommandScopeChat", - "chat_id": 0 + "chat_id": "owner" } ] }