surfaces/adapter/matrix/reactions.py
Mikhail Putilovskij 01610ef768 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
2026-04-02 22:56:16 +03:00

34 lines
1.2 KiB
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from __future__ import annotations
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:
lines: list[str] = ["Скиллы"]
for idx, (name, enabled) in enumerate(settings.skills.items(), start=1):
state = "on" if enabled else "off"
emoji = SKILL_REACTIONS[idx - 1] if idx - 1 < len(SKILL_REACTIONS) else f"{idx}."
lines.append(f" {state} {emoji} {name}")
lines.append("")
lines.append("!skill on/off <название> — переключить навык.")
return "\n".join(lines)
def build_confirmation_text(description: str) -> str:
return "\n".join(
[
"Lambda",
description,
"",
"Ответьте !yes для подтверждения или !no для отмены.",
]
)
def reaction_to_skill_index(key: str) -> int | None:
return REACTION_TO_INDEX.get(key)