From 3f7e08239ecd180394530f52cb854365c19d178c Mon Sep 17 00:00:00 2001 From: Ettore Dreucci Date: Sat, 10 May 2025 16:49:51 +0200 Subject: [PATCH] New config.py module to read bot configs from file --- config.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index 9efe429..425d111 100644 --- a/config.py +++ b/config.py @@ -1 +1,21 @@ -BOT_TOKEN = "7548174804:AAF3da0PZR47RzOF4llQEJszMD5JjVdS8zI" \ No newline at end of file +import json +from telegram import BotCommand + +ACCESS_FILE = "./data/config.json" + +def load_config(): + try: + with open(ACCESS_FILE, "r") as f: + return json.load(f) + except FileNotFoundError: + return {} + +def get_bot_token(bot_name): + config = load_config().get(str(bot_name), {}) + return config.get("token", "") + +def get_commands(bot_name): + config = load_config().get(str(bot_name), {}) + commands = config.get("commands", {}) + bot_commands = [] + return [BotCommand(command, description) for command, description in commands.items()] \ No newline at end of file