rpgbot/config.py

30 lines
747 B
Python
Raw Permalink Normal View History

2019-02-19 14:44:27 +01:00
import os
admins = None
bot_token = None
db_file = None
log_file = None
2019-02-19 14:44:27 +01:00
try:
# Import config from custom_config if present
import custom_config
admins = custom_config.admins
bot_token = custom_config.bot_token
db_file = custom_config.db_file
log_file = custom_config.log_file
except:
# Import config from env vars
admins = os.environ.get('RPGBOT_ADMINS', '')
if admins is None:
raise Exception('No Admins Provided')
2019-02-19 14:44:27 +01:00
admins = admins.split(',')
2019-02-19 19:44:41 +01:00
bot_token = os.environ.get('RPGBOT_TOKEN')
if bot_token is None:
raise Exception('No Token Provided')
db_file = os.environ.get('RPGBOT_DB_FILE', '/data/games.db' )
log_file = os.environ.get('RPGBOT_LOG', '/data/service.log' )