From 5e691b8dcfbbe6ff19fa010a6245623199ad5160 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Mon, 23 Dec 2019 20:51:40 -0900 Subject: [PATCH] Update env to remove secrets and add secrets to redis --- .env | 10 ++++++++++ .gitignore | 1 - geeksbot/__main__.py | 2 +- geeksbot/imports/geeksbot.py | 6 ++++-- 4 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..f739c40 --- /dev/null +++ b/.env @@ -0,0 +1,10 @@ +REDIS_DB=0 +REDIS_HOST=ip-10-0-0-4.ec2.internal +REDIS_PORT=6379 +REDIS_PASSWORD=EUZ9QWkaFhMM + +USE_DOCKER=yes + +DISCORD_DEFAULT_PREFIX=g$ + +PYTHONPATH=/code:$PYTHONPATH diff --git a/.gitignore b/.gitignore index cf7868a..0d092a2 100644 --- a/.gitignore +++ b/.gitignore @@ -331,6 +331,5 @@ geeksbot_v2/media/ .ipython/ -.env .envs/* !.envs/.local/ diff --git a/geeksbot/__main__.py b/geeksbot/__main__.py index 9a490ba..e892e70 100644 --- a/geeksbot/__main__.py +++ b/geeksbot/__main__.py @@ -85,4 +85,4 @@ async def on_ready(): with open(f'{bot.config_dir}restart', 'w') as f: f.write('0') -bot.run(os.environ['TOKEN']) +bot.run(bot.token) diff --git a/geeksbot/imports/geeksbot.py b/geeksbot/imports/geeksbot.py index 57190e3..6126dd5 100644 --- a/geeksbot/imports/geeksbot.py +++ b/geeksbot/imports/geeksbot.py @@ -24,8 +24,10 @@ class Geeksbot(commands.Bot): self.config_dir = 'geeksbot/config' self.config_file = 'bot_config.json' self.extension_dir = 'exts' - self.cache = redis.Redis(host=os.environ['REDIS_HOST'], port=os.environ['REDIS_PORT'], db=1, charset="utf-8", decode_responses=True) - self.api_token = os.environ['API_TOKEN'] + self.cache = redis.Redis(host=os.environ['REDIS_HOST'], port=os.environ['REDIS_PORT'], db=os.environ['REDIS_DB'], charset="utf-8", decode_responses=True) + settings_cache = redis.Redis(host=os.environ['REDIS_HOST'], port=os.environ['REDIS_PORT'], db=1, charset="utf-8", decode_responses=True) + self.token = settings_cache.get('DISCORD_TOKEN') + self.api_token = settings_cache.get('API_TOKEN') self.aio_session = aiohttp.ClientSession(loop=self.loop) self.auth_header = {'Authorization': f'Token {self.api_token}'} self.api_base = 'https://geeksbot.app/api'