-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
executable file
·41 lines (32 loc) · 1.24 KB
/
run.py
File metadata and controls
executable file
·41 lines (32 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from src.clients.discord_client import DiscordClient
import os
import sys
import json
from src.clients.discord_clientV2 import DiscordClientV2
is_prod = os.environ.get('IS_HEROKU', None)
if not is_prod:
# Import settings from .env file while development
if os.path.exists(".env"):
print("Importing environment from .env file")
for line in open(".env"):
var = line.strip().split("=")
os.environ[var[0]] = var[1]
else:
print("ERROR: .env file does not exist failing the script.")
sys.exit("FAILED TO RUN SCRIPT MISSING .env")
token = os.getenv("DISCORD_TOKEN")
# Setup to run the app in debug mode
if __name__ == "__main__" and not is_prod:
if os.path.exists('channels.json'):
f = open('channels.json')
threads = json.load(f)
bot = DiscordClientV2(threads=threads["channels"])
bot.run(token)
else:
print("ERROR: channels.json file does not exist failing the script.")
sys.exit("FAILED TO RUN SCRIPT MISSING channels.json")
# Setup to run the app in production mode
if __name__ == "__main__" and is_prod:
threads = json.loads(os.getenv("CHANNELS_JSON"))
bot = DiscordClientV2(threads=threads["channels"])
bot.run(token)