2018-07-12 00:47:44 +02:00
|
|
|
import asyncio
|
2019-03-07 16:29:46 +01:00
|
|
|
import json
|
|
|
|
|
import os
|
|
|
|
|
import sys
|
2018-07-18 15:26:15 +02:00
|
|
|
|
2018-12-10 19:32:31 +01: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-12 00:47:44 +02:00
|
|
|
|
2019-03-07 16:29:46 +01:00
|
|
|
with open(sys.argv[1] if len(sys.argv) > 1 else "pluralkit.conf") as f:
|
|
|
|
|
config = json.load(f)
|
|
|
|
|
|
2019-03-08 15:12:14 +01:00
|
|
|
if "database_uri" not in config and "DATABASE_URI" not in os.environ:
|
2019-03-07 16:29:46 +01:00
|
|
|
print("Config file must contain key 'database_uri', or the environment variable DATABASE_URI must be present.")
|
2019-03-08 15:12:14 +01:00
|
|
|
elif "token" not in config and "TOKEN" not in os.environ:
|
2019-03-07 16:29:46 +01:00
|
|
|
print("Config file must contain key 'token', or the environment variable TOKEN must be present.")
|
|
|
|
|
else:
|
|
|
|
|
from pluralkit import bot
|
2019-03-08 15:19:08 +01: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)))
|