Improved net bot implementation
This commit is contained in:
28
main.py
28
main.py
@@ -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__":
|
||||
|
||||
Reference in New Issue
Block a user