feat(01-03): switch Matrix confirmations to text commands
- replace reaction-based helper text with !yes/!no and !skill commands - resolve confirm and cancel through pending confirmation state - render !settings as a read-only status dashboard
This commit is contained in:
parent
8a6a33a2ce
commit
01610ef768
4 changed files with 86 additions and 70 deletions
|
|
@ -1,19 +1,40 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from adapter.matrix.store import clear_pending_confirm, get_pending_confirm
|
||||
from core.protocol import IncomingCallback, OutgoingMessage
|
||||
|
||||
|
||||
async def handle_confirm(
|
||||
event: IncomingCallback, auth_mgr, platform, chat_mgr, settings_mgr
|
||||
) -> list:
|
||||
action_id = event.payload.get("action_id", "unknown")
|
||||
return [
|
||||
OutgoingMessage(chat_id=event.chat_id, text=f"Действие подтверждено (id: {action_id}).")
|
||||
]
|
||||
def make_handle_confirm(store=None):
|
||||
async def handle_confirm(
|
||||
event: IncomingCallback, auth_mgr, platform, chat_mgr, settings_mgr
|
||||
) -> list:
|
||||
if store is None:
|
||||
return [OutgoingMessage(chat_id=event.chat_id, text="Нет ожидающих подтверждений.")]
|
||||
|
||||
pending = await get_pending_confirm(store, event.chat_id)
|
||||
if not pending:
|
||||
return [OutgoingMessage(chat_id=event.chat_id, text="Нет ожидающих подтверждений.")]
|
||||
|
||||
description = pending.get("description", "действие")
|
||||
await clear_pending_confirm(store, event.chat_id)
|
||||
|
||||
return [OutgoingMessage(chat_id=event.chat_id, text=f"Подтверждено: {description}")]
|
||||
|
||||
return handle_confirm
|
||||
|
||||
|
||||
async def handle_cancel(
|
||||
event: IncomingCallback, auth_mgr, platform, chat_mgr, settings_mgr
|
||||
) -> list:
|
||||
action_id = event.payload.get("action_id", "unknown")
|
||||
return [OutgoingMessage(chat_id=event.chat_id, text=f"Действие отменено (id: {action_id}).")]
|
||||
def make_handle_cancel(store=None):
|
||||
async def handle_cancel(
|
||||
event: IncomingCallback, auth_mgr, platform, chat_mgr, settings_mgr
|
||||
) -> list:
|
||||
if store is None:
|
||||
return [OutgoingMessage(chat_id=event.chat_id, text="Нет ожидающих подтверждений.")]
|
||||
|
||||
pending = await get_pending_confirm(store, event.chat_id)
|
||||
if not pending:
|
||||
return [OutgoingMessage(chat_id=event.chat_id, text="Нет ожидающих подтверждений.")]
|
||||
|
||||
await clear_pending_confirm(store, event.chat_id)
|
||||
return [OutgoingMessage(chat_id=event.chat_id, text="Действие отменено.")]
|
||||
|
||||
return handle_cancel
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue