Example #1
0
PREFIX = os.getenv("COMMAND_PREFIX")
TIME_DOWN_BEFORE_NOTIFY = int(os.getenv("TIME_DOWN_BEFORE_NOTIFY"))
COLOUR = int(os.getenv("COLOUR"), 16)
PORT = int(os.getenv("RELAY_PORT"))

# Init relay http server
r = Relay(PORT)

# Load data from json
JSON = json.load(
    open(
        os.path.join(os.path.dirname(os.path.realpath(__file__)), "data.json"),
        "r"))

for channelID, connectionObj in JSON.items():
    if JSON[channelID]["relay"] == 1: r.addConStr(connectionObj["server"])
    JSON[channelID]["server"] = SourceServer(connectionObj["server"])
    JSON[channelID]["time_since_down"] = -1

# Load custom message formats from json
messageFormats = json.load(
    open(
        os.path.join(os.path.dirname(os.path.realpath(__file__)),
                     "messageFormats.json"), "r"))

if "joinMsgs" not in messageFormats.keys() or len(
        messageFormats["joinMsgs"]) == 0:
    messageFormats["joinMsgs"] = ["`{player}` just joined the server!"]
if "leaveMsgs" not in messageFormats.keys() or len(
        messageFormats["leaveMsgs"]) == 0:
    messageFormats["leaveMsgs"] = ["`{player}` just left the server"]