Move configuration to seperate file

feature/embed-uploads
Tristan Gosselin-Hane 7 years ago
parent e9e3b3239c
commit bae4f0e42a
  1. 15
      config.py
  2. 6
      webhook-bridge.py

@ -0,0 +1,15 @@
import json
class Configuration(object):
def __init__(self, path):
try:
with open(path, 'r') as f:
self._config = json.load(f)
if self._config:
self.webhook_url = self._config["MAIN"]["WEBHOOK_URL"]
else:
print("error reading config")
exit(1)
except IOError:
print("error reading config")
exit(1)

@ -8,6 +8,7 @@ import re
import requests
import json
from optparse import OptionParser
from config import Configuration
from minecraft import authentication
from minecraft.exceptions import YggdrasilError
@ -67,10 +68,9 @@ def get_options():
def main():
options = get_options()
with open('config.json', 'r') as f:
_config = json.load(f)
config = Configuration("config.json")
WEBHOOK_URL = _config["MAIN"]["WEBHOOK_URL"]
WEBHOOK_URL = config.webhook_url
if options.offline:
print("Connecting in offline mode...")

Loading…
Cancel
Save