Improved net bot implementation

This commit is contained in:
2026-08-18 02:21:17 +03:00
parent 8c056c1da3
commit 75388d8693
2 changed files with 106 additions and 32 deletions

28
main.py
View File

@@ -5,11 +5,16 @@
import asyncio
import traceback
import signal
from pathlib import Path
import config
import util
import bot
import logic
#import bot
#import logic
from new_bot import MatrixBot
from bot_types import MatrixBotConfig
from datatypes import AppConfig
async def main() -> None:
@@ -29,18 +34,17 @@ async def main() -> None:
if cfg is None:
util.log_error("Could't load config")
return
# start the bot
if not await bot.start(cfg):
util.log_error("Could't start the bot")
return
await logic.setup(bot.get_client())
# wait for stop
matrix_bot_config = MatrixBotConfig(
matrix_homeserver_url=cfg.matrix_homeserver,
matrix_username_localpart=cfg.matrix_user,
storage_directory=Path(cfg.store_dir)
)
bot = MatrixBot(matrix_bot_config)
bot.start()
await util.get_app_stop_event().wait()
# stop
await logic.stop()
await bot.stop()
if __name__ == "__main__":