2018-07-11 22:47:44 +00:00
|
|
|
import asyncio
|
2019-03-07 15:29:46 +00:00
|
|
|
import json
|
|
|
|
import os
|
|
|
|
import sys
|
2018-07-18 13:26:15 +00:00
|
|
|
|
2018-12-10 18:32:31 +00:00
|
|
|
try:
|
|
|
|
# uvloop doesn't work on Windows, therefore an optional dependency
|
|
|
|
import uvloop
|
|
|
|
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
|
|
|
|
except ImportError:
|
|
|
|
pass
|
2018-07-11 22:47:44 +00:00
|
|
|
|
2019-03-07 15:29:46 +00:00
|
|
|
with open(sys.argv[1] if len(sys.argv) > 1 else "pluralkit.conf") as f:
|
|
|
|
config = json.load(f)
|
|
|
|
|
2019-03-08 14:12:14 +00:00
|
|
|
if "database_uri" not in config and "DATABASE_URI" not in os.environ:
|
2019-03-07 15:29:46 +00:00
|
|
|
print("Config file must contain key 'database_uri', or the environment variable DATABASE_URI must be present.")
|
2019-03-08 14:12:14 +00:00
|
|
|
elif "token" not in config and "TOKEN" not in os.environ:
|
2019-03-07 15:29:46 +00:00
|
|
|
print("Config file must contain key 'token', or the environment variable TOKEN must be present.")
|
|
|
|
else:
|
|
|
|
from pluralkit import bot
|
2019-03-08 14:19:08 +00:00
|
|
|
bot.run(os.environ.get("TOKEN", config.get("token")), os.environ.get("DATABASE_URI", config.get("database_uri")), int(config.get("log_channel", 0)))
|