- 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
34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
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)
|