Updated bot implementation

- Added ability to send text messages
- Added ability to verify all devices
- Added configuration field to enable autoverification of all known devices
- Added ability to get client
This commit is contained in:
2026-08-21 06:25:27 +03:00
parent c519ae379d
commit a2a1b6c2ed
3 changed files with 122 additions and 2 deletions

11
main.py
View File

@@ -5,6 +5,7 @@
import asyncio
import traceback
import signal
import html
from pathlib import Path
import config
@@ -14,11 +15,20 @@ from new_bot import MatrixBot
from bot_types import MatrixBotConfig
import nio.events
from nio import MatrixRoom, RoomMessageText
from datatypes import AppConfig
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
# setup signal handler
util.setup_app_stop_event()
loop = asyncio.get_running_loop()
@@ -42,6 +52,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)
# start the app