First API implementation
This commit is contained in:
5
main.py
5
main.py
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user