2022-06-10 01:48:02 +02:00
|
|
|
import logging
|
|
|
|
from logging.handlers import RotatingFileHandler
|
|
|
|
|
|
|
|
import asyncio
|
|
|
|
|
|
|
|
import settings
|
2022-06-11 01:26:19 +02:00
|
|
|
from database.migrations import ensure_latest_migration
|
2022-06-10 01:48:02 +02:00
|
|
|
from didier import Didier
|
|
|
|
|
|
|
|
|
|
|
|
async def run_bot():
|
|
|
|
"""Run Didier"""
|
|
|
|
didier = Didier()
|
|
|
|
await didier.start(settings.DISCORD_TOKEN)
|
|
|
|
|
|
|
|
|
|
|
|
def setup_logging():
|
|
|
|
"""Configure custom loggers"""
|
|
|
|
max_log_size = 32 * 1024 * 1024
|
|
|
|
|
|
|
|
didier_log = logging.getLogger("didier")
|
|
|
|
|
|
|
|
handler = RotatingFileHandler(settings.LOGFILE, mode="a", maxBytes=max_log_size, backupCount=5)
|
|
|
|
handler.setFormatter(logging.Formatter("[%(asctime)s] [%(levelname)s]: %(message)s"))
|
|
|
|
|
|
|
|
didier_log.addHandler(handler)
|
2022-06-15 01:56:18 +02:00
|
|
|
didier_log.setLevel(logging.INFO)
|
2022-06-10 01:48:02 +02:00
|
|
|
|
|
|
|
logging.getLogger("discord").setLevel(logging.ERROR)
|
|
|
|
|
|
|
|
|
2022-06-11 01:26:19 +02:00
|
|
|
async def main():
|
|
|
|
"""Do some setup & checks, and then run the bot"""
|
2022-06-10 01:48:02 +02:00
|
|
|
setup_logging()
|
2022-06-11 01:26:19 +02:00
|
|
|
await ensure_latest_migration()
|
|
|
|
await run_bot()
|
|
|
|
|
2022-06-10 01:48:02 +02:00
|
|
|
|
2022-06-11 01:26:19 +02:00
|
|
|
if __name__ == "__main__":
|
|
|
|
asyncio.run(main())
|