mirror of
https://github.com/Xevion/contest-assistant.git
synced 2025-12-05 23:14:35 -06:00
Also: - Removed emotes from some of the error messages. - Changed how emotes were placed into the leaderboard slightly - Moved around TODO strings into proper files and added more. - Corrected main.py cog loading references. - Improved ContestBot.reject with message references and used built-in delete_after keyword argument. - Minor docstring/light formatting
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
import logging
|
|
|
|
from sqlalchemy import create_engine
|
|
from sqlalchemy.engine import Engine
|
|
|
|
from bot import constants
|
|
from bot.bot import ContestBot
|
|
from bot.models import Base
|
|
|
|
|
|
def load_db(url=constants.DATABASE_URI) -> Engine:
|
|
engine = create_engine(url)
|
|
Base.metadata.create_all(engine)
|
|
return engine
|
|
|
|
|
|
if __name__ == "__main__":
|
|
logger = logging.getLogger(__file__)
|
|
logger.setLevel(constants.LOGGING_LEVEL)
|
|
|
|
# noinspection PyArgumentList
|
|
logging.basicConfig(format='[%(asctime)s] [%(levelname)s] [%(funcName)s] %(message)s',
|
|
handlers=[
|
|
logging.FileHandler(f"bot.log", encoding='utf-8'),
|
|
logging.StreamHandler()
|
|
])
|
|
|
|
initial_extensions = ['bot.cogs.contest_commands',
|
|
'bot.cogs.contest_events']
|
|
|
|
engine = load_db()
|
|
bot = ContestBot(engine, description='A assistant for the Photography Lounge\'s monday contests')
|
|
|
|
for extension in initial_extensions:
|
|
bot.load_extension(extension)
|
|
|
|
logger.info('Starting bot...')
|
|
with open('token.dat', 'r') as file:
|
|
bot.run(file.read(), bot=True, reconnect=True)
|