Basic database function implemented
This commit is contained in:
10
main.py
10
main.py
@@ -10,6 +10,7 @@ from pathlib import Path
|
||||
from mab import MatrixBot, MatrixBotConfig
|
||||
|
||||
from datatypes import AppConfig
|
||||
import database
|
||||
import config
|
||||
import util
|
||||
import bot_callbacks
|
||||
@@ -42,9 +43,15 @@ async def main() -> None:
|
||||
storage_directory=Path(cfg.store_dir)
|
||||
)
|
||||
bot = MatrixBot(matrix_bot_config)
|
||||
bot_callbacks.setup(bot)
|
||||
# setup the database
|
||||
db = database.Database(Path("database.sqlite"))
|
||||
# setup the callbacks
|
||||
bot_callbacks.setup(bot, db)
|
||||
|
||||
# start the app
|
||||
if not await db.connect():
|
||||
util.log_error("Can't connect to the database!")
|
||||
return
|
||||
bot.start()
|
||||
|
||||
# wait for Ctrl+C
|
||||
@@ -52,6 +59,7 @@ async def main() -> None:
|
||||
|
||||
# stop the app
|
||||
await bot.stop()
|
||||
await db.disconnect()
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user