Basic database function implemented

This commit is contained in:
Nikita Tyukalov, ASUS, Linux
2026-08-25 21:13:27 +03:00
parent ff6656fdb0
commit ddc1c36c72
7 changed files with 360 additions and 63 deletions

10
main.py
View File

@@ -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: