From 88f2c4d0872f9c1a4cc86e61f921bd327105aa8b Mon Sep 17 00:00:00 2001 From: Raatty <39517058+Raatty@users.noreply.github.com> Date: Wed, 23 May 2018 20:32:20 +1200 Subject: [PATCH] Development (#16) * heroku yml * owner list from env * bot key from enviroment var * app json * heroku button * again * Update README.md * fixing syntax hopefully * error fixing * enviroments added * opsy forgot a } * trying again * Update app.json * Update app.json * Update app.json * Update app.json * Update app.json * Update __main__.py * Update app.json * Update __main__.py * removed prints --- README.md | 2 +- app.json | 15 +++++++++++++++ heroku.yml | 3 +++ src/__main__.py | 4 ++++ src/config/config.py | 6 +++++- 5 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 app.json create mode 100644 heroku.yml diff --git a/README.md b/README.md index eea3036..0e1e939 100644 --- a/README.md +++ b/README.md @@ -60,4 +60,4 @@ If you are stuck in any way shape or form you can always contact anyone who work - http://discord.gg/GWdhBSp - http://chillout.ueuo.com - http://trello.com/b/x02goBbW/sebis-bot-tutorial-roadmap - +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/Raatty/Sebi-Machine/tree/development) diff --git a/app.json b/app.json new file mode 100644 index 0000000..d5d8b35 --- /dev/null +++ b/app.json @@ -0,0 +1,15 @@ +{ + "name":"sebi-machine", + "stack":"container", + "env": { + + "ownerlist": { + "description": "comma seperated list of owner ids", + "required": true + }, + "botkey": { + "description": "bot token", + "required": true + } + } +} diff --git a/heroku.yml b/heroku.yml new file mode 100644 index 0000000..2d41892 --- /dev/null +++ b/heroku.yml @@ -0,0 +1,3 @@ +build: + docker: + worker: dockerfile diff --git a/src/__main__.py b/src/__main__.py index 8b4ecd8..e6b15ea 100644 --- a/src/__main__.py +++ b/src/__main__.py @@ -10,6 +10,7 @@ import json import logging import random import traceback +import os import discord from discord.ext import commands @@ -98,4 +99,7 @@ client = SebiMachine() # I am 99% certain this is valid! with open(in_here('config', 'PrivateConfig.json')) as fp: PrivateConfig = json.load(fp) +if PrivateConfig["bot-key"] == '': + PrivateConfig["bot-key"] = os.getenv('botkey') + client.run(PrivateConfig["bot-key"]) diff --git a/src/config/config.py b/src/config/config.py index b6f5acf..fe00265 100644 --- a/src/config/config.py +++ b/src/config/config.py @@ -3,6 +3,7 @@ import json import discord +import os class LoadConfig: """ @@ -14,7 +15,10 @@ class LoadConfig: self.config = json.load(fp) # Initialize config - self.ownerlist = self.config["ownerlist"] + if self.config["ownerlist"] != []: + self.ownerlist = self.config["ownerlist"] + else: + self.ownerlist = [int(i) for i in os.getenv('ownerlist').split(',')] self.defaultprefix = self.config["prefix"] self.version = self.config["version"] self.display_name = self.config["display_name"]