monolith/monolith.py

44 lines
923 B
Python
Raw Normal View History

import asyncio
from os import getenv
import util
from sources.ch4 import Chan4
from sources.dis import DiscordClient
# For development
if not getenv("DISCORD_TOKEN", None):
2022-09-05 06:20:30 +00:00
print("Could not get Discord token, attempting load from .env")
from dotenv import load_dotenv
2022-09-04 20:40:04 +00:00
load_dotenv()
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):
log.info("Starting Discord handler.")
2022-09-04 12:47:32 +00:00
client = DiscordClient()
loop.create_task(client.start(token))
2022-09-04 20:40:04 +00:00
# client.run(token)
2022-09-04 18:44:25 +00:00
log.info("Starting 4chan handler.")
chan = Chan4()
await chan.run()
2022-09-04 12:47:32 +00:00
loop = asyncio.get_event_loop()
loop.create_task(main(loop))
2022-09-04 20:40:04 +00:00
# reactor.run()
try:
loop.run_forever()
except KeyboardInterrupt:
log.info("Process terminating")
finally:
loop.close()