Skip to content

Commit

Permalink
Make bot.py better with env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
alex4108 committed Sep 23, 2020
1 parent f156137 commit caab287
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,16 @@
log.basicConfig(level=log.INFO)
import sqlite3

if "APPROOVA_DOTENV_PATH" in os.environ:
DOTENV_PATH=os.getenv('APPROOVA_DOTENV_PATH')
else:
DOTENV_PATH="/content/.env"

if "APPROOVA_DB_PATH" in os.environ:
DB_PATH=os.getenv("APPROOVA_DB_PATH")
else:
DB_PATH="/content/sqlite.db"

if "APPROOVA_DISCORD_TOKEN" in os.environ:
TOKEN = os.getenv('APPROOVA_DISCORD_TOKEN')
else:
DOTENV_PATH=os.getenv("APPROOVA_DOTENV_PATH", "/content/.env")
DB_PATH=os.getenv("APPROOVA_DB_PATH", "/content/sqlite.db")
TOKEN = os.getenv("APPROOVA_DISCORD_TOKEN")
if TOKEN is None:
load_dotenv(DOTENV_PATH)
TOKEN = os.getenv("DISCORD_TOKEN")

if TOKEN is None:
log.critical("No bot token provided, exiting!")
os.exit(1)

global db
global db_cursor
global discord
Expand Down

0 comments on commit caab287

Please sign in to comment.