mirror of
https://github.com/Xevion/contest-assistant.git
synced 2025-12-06 01:14:37 -06:00
running bot with database, switch to helper function for testing
This commit is contained in:
@@ -5,6 +5,7 @@ import os
|
||||
BASE_DIR = os.path.dirname(os.path.abspath(os.path.join(__file__, '..')))
|
||||
TOKEN = os.path.join(BASE_DIR, 'token.dat')
|
||||
DATABASE = os.path.join(BASE_DIR, 'database.db')
|
||||
DATABASE_URI = f'sqlite:///{DATABASE}'
|
||||
|
||||
# Other constants
|
||||
LOGGING_LEVEL = logging.DEBUG
|
||||
|
||||
13
main.py
13
main.py
@@ -1,11 +1,19 @@
|
||||
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)
|
||||
@@ -17,10 +25,9 @@ if __name__ == "__main__":
|
||||
logging.StreamHandler()
|
||||
])
|
||||
|
||||
initial_extensions = ['contest.cogs.contest']
|
||||
initial_extensions = ['bot.cogs.contest']
|
||||
|
||||
engine = create_engine(constants.DATABASE)
|
||||
Base.metadata.create_all(engine)
|
||||
engine = load_db()
|
||||
bot = ContestBot(engine, description='A assistant for the Photography Lounge\'s monday contests')
|
||||
|
||||
for extension in initial_extensions:
|
||||
|
||||
Reference in New Issue
Block a user