Added basic callbacks model
This commit is contained in:
17
main.py
17
main.py
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user