First API implementation

This commit is contained in:
Nikita Tyukalov, ASUS, Linux
2026-08-29 17:24:39 +03:00
parent 28ef360d5f
commit 8094aaab10
6 changed files with 278 additions and 31 deletions

View File

@@ -14,6 +14,7 @@ import database
import config
import util
import bot_callbacks
import web
bot: MatrixBot = None # type: ignore
@@ -47,17 +48,21 @@ async def main() -> None:
db = database.Database(Path("database.sqlite"))
# setup the callbacks
bot_callbacks.setup(bot, db)
# setup the web server
web_server = web.Web(cfg, bot, db)
# start the app
if not await db.connect():
util.log_error("Can't connect to the database!")
return
bot.start()
await web_server.start()
# wait for Ctrl+C
await util.get_app_stop_event().wait()
# stop the app
await web_server.stop()
await bot.stop()
await db.disconnect()