2022-09-02 21:30:45 +00:00
|
|
|
import asyncio
|
2022-09-23 06:20:30 +00:00
|
|
|
import sys
|
|
|
|
import uvloop
|
|
|
|
|
2022-09-02 21:30:45 +00:00
|
|
|
from os import getenv
|
|
|
|
|
|
|
|
import util
|
|
|
|
from sources.ch4 import Chan4
|
|
|
|
from sources.dis import DiscordClient
|
2022-09-07 06:20:30 +00:00
|
|
|
from sources.ingest import Ingest
|
2022-09-02 21:30:45 +00:00
|
|
|
|
2022-09-23 06:20:30 +00:00
|
|
|
# Use UVLoop
|
|
|
|
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
|
|
|
|
|
2022-09-02 21:30:45 +00:00
|
|
|
log = util.get_logger("monolith")
|
|
|
|
|
|
|
|
modules_enabled = getenv("MODULES_ENABLED", False)
|
|
|
|
|
|
|
|
token = getenv("DISCORD_TOKEN", None)
|
|
|
|
if not token:
|
|
|
|
raise Exception("No Discord token provided")
|
|
|
|
|
|
|
|
|
2022-09-04 12:47:32 +00:00
|
|
|
async def main(loop):
|
2022-09-21 09:02:05 +00:00
|
|
|
client = DiscordClient()
|
|
|
|
loop.create_task(client.start(token))
|
2022-09-02 21:30:45 +00:00
|
|
|
|
2022-09-21 09:02:05 +00:00
|
|
|
chan = Chan4()
|
|
|
|
loop.create_task(chan.run())
|
2022-09-07 06:20:30 +00:00
|
|
|
|
|
|
|
ingest = Ingest()
|
|
|
|
loop.create_task(ingest.run())
|
2022-09-02 21:30:45 +00:00
|
|
|
|
2022-09-04 12:47:32 +00:00
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
loop.create_task(main(loop))
|
2022-09-23 06:20:30 +00:00
|
|
|
|
2022-09-02 21:30:45 +00:00
|
|
|
try:
|
|
|
|
loop.run_forever()
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
log.info("Process terminating")
|
|
|
|
finally:
|
|
|
|
loop.close()
|