2024-07-28 03:59:19 +01:00
|
|
|
import click
|
|
|
|
import logging
|
|
|
|
from tortoise import run_async
|
|
|
|
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
@click.group()
|
2024-07-31 23:17:09 +01:00
|
|
|
@click.option(
|
|
|
|
"--log-level",
|
|
|
|
default="INFO",
|
|
|
|
type=click.Choice(["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], case_sensitive=False),
|
|
|
|
help="Set the log level."
|
|
|
|
)
|
|
|
|
def cli(log_level: str):
|
|
|
|
logging.basicConfig(level=log_level.upper())
|
2024-07-28 03:59:19 +01:00
|
|
|
|
|
|
|
|
|
|
|
@cli.command()
|
|
|
|
def run():
|
|
|
|
"""Runs the bot"""
|
|
|
|
log.info("Starting bot.")
|
|
|
|
from .main import bot
|
2024-07-28 23:33:15 +01:00
|
|
|
|
2024-07-28 03:59:19 +01:00
|
|
|
run_async(bot.start(access_token=bot.cfg["bot"]["access_token"]))
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
cli()
|