mirror of
https://github.com/Noettore/lagomareGateKeeperBot.git
synced 2025-10-14 19:16:40 +02:00
New config.py module to read bot configs from file
This commit is contained in:
22
config.py
22
config.py
@@ -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()]
|
Reference in New Issue
Block a user