Added basic callbacks model

This commit is contained in:
2026-08-21 07:33:35 +03:00
parent ce9c157b72
commit 4c1507555a
2 changed files with 75 additions and 13 deletions

17
main.py
View File

@@ -8,24 +8,16 @@ import signal
import html
from pathlib import Path
import config
import util
from bot import MatrixBot
from bot_types import MatrixBotConfig
import nio.events
from nio import MatrixRoom, RoomMessageText
from datatypes import AppConfig
import config
import util
import bot_callbacks
bot: MatrixBot = None
async def callback_test_text(room: MatrixRoom, event: RoomMessageText) -> None:
if event.sender == bot.get_client().user_id:
return
await bot.send_text_to_room(room.room_id, f"<b>{html.escape(event.body)}</b>")
async def main() -> None:
"""Entry point"""
global bot
@@ -52,8 +44,7 @@ async def main() -> None:
storage_directory=Path(cfg.store_dir)
)
bot = MatrixBot(matrix_bot_config)
bot.add_event_callback(callback_test_text, RoomMessageText)
bot.add_event_callback(None, nio.events.Event)
bot_callbacks.setup(bot)
# start the app
bot.start()