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
34
adapter/matrix/handlers/auth.py
Normal file
34
adapter/matrix/handlers/auth.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from adapter.matrix.store import get_room_meta, set_room_meta
|
||||
|
||||
|
||||
async def handle_invite(client: Any, room: Any, event: Any, platform, store, auth_mgr) -> None:
|
||||
existing = await get_room_meta(store, room.room_id)
|
||||
if existing is not None:
|
||||
return
|
||||
|
||||
user = await platform.get_or_create_user(
|
||||
external_id=getattr(event, "sender", ""),
|
||||
platform="matrix",
|
||||
display_name=getattr(room, "display_name", None),
|
||||
)
|
||||
await auth_mgr.confirm(getattr(event, "sender", ""))
|
||||
await client.join(room.room_id)
|
||||
await set_room_meta(
|
||||
store,
|
||||
room.room_id,
|
||||
{
|
||||
"room_type": "chat",
|
||||
"chat_id": "C1",
|
||||
"display_name": getattr(room, "display_name", room.room_id),
|
||||
"matrix_user_id": getattr(event, "sender", user.external_id),
|
||||
},
|
||||
)
|
||||
message = (
|
||||
f"Привет, {user.display_name or user.external_id}! Пиши — я здесь.\n\n"
|
||||
f"Команды: !new · !chats · !rename · !archive · !skills"
|
||||
)
|
||||
await client.room_send(room.room_id, "m.room.message", {"msgtype": "m.text", "body": message})
|
||||
Loading…
Add table
Add a link
Reference in a new issue