# core/handlers/message.py from __future__ import annotations from core.protocol import IncomingMessage, OutgoingMessage, OutgoingTyping def _start_command(platform: str) -> str: return "!start" if platform == "matrix" else "/start" async def handle_message(event: IncomingMessage, auth_mgr, platform, chat_mgr, settings_mgr) -> list: if not await auth_mgr.is_authenticated(event.user_id): return [ OutgoingMessage( chat_id=event.chat_id, text=f"Введите {_start_command(event.platform)} чтобы начать.", ) ] # Voice slot fallback: audio attachment without registered voice_handler if event.attachments and event.attachments[0].type == "audio": return [OutgoingMessage( chat_id=event.chat_id, text="Голосовые сообщения скоро поддержим.", parse_mode="plain", )] response = await platform.send_message( user_id=event.user_id, chat_id=event.chat_id, text=event.text, attachments=[], ) return [ OutgoingTyping(chat_id=event.chat_id, is_typing=False), OutgoingMessage(chat_id=event.chat_id, text=response.response, parse_mode="markdown"), ]