New config.py module to read bot configs from file

This commit is contained in:
2025-05-10 16:49:51 +02:00
parent 4f5146d522
commit 3f7e08239e

View File

@@ -1 +1,21 @@
BOT_TOKEN = "7548174804:AAF3da0PZR47RzOF4llQEJszMD5JjVdS8zI"
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()]