feat(01-06): remove matrix reaction-era adapter UX
- Drop reaction-based skill and confirmation helpers from Matrix conversion - Render !settings as a strict read-only dashboard snapshot - Align Matrix adapter regressions with command-only helper text
This commit is contained in:
parent
974935c880
commit
3e06a67e24
3 changed files with 2 additions and 52 deletions
|
|
@ -2,7 +2,6 @@ from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from adapter.matrix.reactions import CANCEL_REACTION, CONFIRM_REACTION, reaction_to_skill_index
|
|
||||||
from core.protocol import (
|
from core.protocol import (
|
||||||
Attachment,
|
Attachment,
|
||||||
IncomingCallback,
|
IncomingCallback,
|
||||||
|
|
@ -95,43 +94,6 @@ def from_command(body: str, sender: str, chat_id: str, room_id: str | None = Non
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def from_reaction(event: Any, sender: str, chat_id: str) -> IncomingCallback | None:
|
|
||||||
content = getattr(event, "content", {}) or {}
|
|
||||||
relates_to = content.get("m.relates_to", {})
|
|
||||||
key = getattr(event, "key", None) or relates_to.get("key")
|
|
||||||
event_id = getattr(event, "event_id", None) or relates_to.get("event_id")
|
|
||||||
if not key:
|
|
||||||
return None
|
|
||||||
|
|
||||||
if key == CONFIRM_REACTION:
|
|
||||||
return IncomingCallback(
|
|
||||||
user_id=sender,
|
|
||||||
platform=PLATFORM,
|
|
||||||
chat_id=chat_id,
|
|
||||||
action="confirm",
|
|
||||||
payload={"event_id": event_id, "reaction": key},
|
|
||||||
)
|
|
||||||
if key == CANCEL_REACTION:
|
|
||||||
return IncomingCallback(
|
|
||||||
user_id=sender,
|
|
||||||
platform=PLATFORM,
|
|
||||||
chat_id=chat_id,
|
|
||||||
action="cancel",
|
|
||||||
payload={"event_id": event_id, "reaction": key},
|
|
||||||
)
|
|
||||||
|
|
||||||
skill_index = reaction_to_skill_index(key)
|
|
||||||
if skill_index is not None:
|
|
||||||
return IncomingCallback(
|
|
||||||
user_id=sender,
|
|
||||||
platform=PLATFORM,
|
|
||||||
chat_id=chat_id,
|
|
||||||
action="toggle_skill",
|
|
||||||
payload={"event_id": event_id, "reaction": key, "skill_index": skill_index},
|
|
||||||
)
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def from_room_event(event: Any, room_id: str, chat_id: str) -> IncomingEvent | None:
|
def from_room_event(event: Any, room_id: str, chat_id: str) -> IncomingEvent | None:
|
||||||
body = (getattr(event, "body", None) or "").strip()
|
body = (getattr(event, "body", None) or "").strip()
|
||||||
sender = getattr(event, "sender", "")
|
sender = getattr(event, "sender", "")
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,6 @@ async def handle_settings(
|
||||||
"",
|
"",
|
||||||
f"Активные чаты ({len(chats)}):",
|
f"Активные чаты ({len(chats)}):",
|
||||||
chats_text,
|
chats_text,
|
||||||
"",
|
|
||||||
"Изменить: !skills, !soul, !safety",
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,12 @@ from __future__ import annotations
|
||||||
|
|
||||||
from sdk.interface import UserSettings
|
from sdk.interface import UserSettings
|
||||||
|
|
||||||
CONFIRM_REACTION = "👍"
|
|
||||||
CANCEL_REACTION = "❌"
|
|
||||||
SKILL_REACTIONS = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣"]
|
|
||||||
REACTION_TO_INDEX = {emoji: idx + 1 for idx, emoji in enumerate(SKILL_REACTIONS)}
|
|
||||||
|
|
||||||
|
|
||||||
def build_skills_text(settings: UserSettings) -> str:
|
def build_skills_text(settings: UserSettings) -> str:
|
||||||
lines: list[str] = ["Скиллы"]
|
lines: list[str] = ["Скиллы"]
|
||||||
for idx, (name, enabled) in enumerate(settings.skills.items(), start=1):
|
for name, enabled in settings.skills.items():
|
||||||
state = "on" if enabled else "off"
|
state = "on" if enabled else "off"
|
||||||
emoji = SKILL_REACTIONS[idx - 1] if idx - 1 < len(SKILL_REACTIONS) else f"{idx}."
|
lines.append(f" {state} {name}")
|
||||||
lines.append(f" {state} {emoji} {name}")
|
|
||||||
lines.append("")
|
lines.append("")
|
||||||
lines.append("!skill on/off <название> — переключить навык.")
|
lines.append("!skill on/off <название> — переключить навык.")
|
||||||
return "\n".join(lines)
|
return "\n".join(lines)
|
||||||
|
|
@ -28,7 +22,3 @@ def build_confirmation_text(description: str) -> str:
|
||||||
"Ответьте !yes для подтверждения или !no для отмены.",
|
"Ответьте !yes для подтверждения или !no для отмены.",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def reaction_to_skill_index(key: str) -> int | None:
|
|
||||||
return REACTION_TO_INDEX.get(key)
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue