feat(matrix): add adapter baseline and platform-aware command hints
This commit is contained in:
parent
bcdaea5143
commit
82eb711844
20 changed files with 1127 additions and 3 deletions
|
|
@ -4,9 +4,19 @@ from __future__ import annotations
|
|||
from core.protocol import IncomingCommand, OutgoingMessage
|
||||
|
||||
|
||||
def _command(platform: str, name: str) -> str:
|
||||
prefix = "!" if platform == "matrix" else "/"
|
||||
return f"{prefix}{name}"
|
||||
|
||||
|
||||
async def handle_new_chat(event: IncomingCommand, 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="Введите /start чтобы начать.")]
|
||||
return [
|
||||
OutgoingMessage(
|
||||
chat_id=event.chat_id,
|
||||
text=f"Введите {_command(event.platform, 'start')} чтобы начать.",
|
||||
)
|
||||
]
|
||||
name = " ".join(event.args) if event.args else None
|
||||
ctx = await chat_mgr.get_or_create(
|
||||
user_id=event.user_id,
|
||||
|
|
@ -20,7 +30,12 @@ async def handle_new_chat(event: IncomingCommand, auth_mgr, platform, chat_mgr,
|
|||
|
||||
async def handle_rename(event: IncomingCommand, auth_mgr, platform, chat_mgr, settings_mgr) -> list:
|
||||
if not event.args:
|
||||
return [OutgoingMessage(chat_id=event.chat_id, text="Укажите название: /rename Название")]
|
||||
return [
|
||||
OutgoingMessage(
|
||||
chat_id=event.chat_id,
|
||||
text=f"Укажите название: {_command(event.platform, 'rename')} Название",
|
||||
)
|
||||
]
|
||||
ctx = await chat_mgr.rename(event.chat_id, " ".join(event.args))
|
||||
return [OutgoingMessage(chat_id=event.chat_id, text=f"Переименован в: {ctx.display_name}")]
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,18 @@ 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="Введите /start чтобы начать.")]
|
||||
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":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue