fix: Finale Fix-Runde — ::restart State-Cleanup+SIGTERM, ::approve in Dangerous msg, Proaktiver Message Split, install.sh --update-only, number_buttons=False, FAKT 3 Attachments, Toter Code entfernt
This commit is contained in:
@@ -158,20 +158,20 @@ def _persist_room_map_changes(
|
||||
# Emoji-Nummern für bis zu 10 Buttons
|
||||
_EMOJI_NUMBERS = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣", "🔟"]
|
||||
|
||||
# Sonderschaltflächen-Erkennung (diese bekommen KEINE Nummer)
|
||||
_SPECIAL_BUTTON_PATTERNS = ["↩️", "⏭️", "➕"]
|
||||
|
||||
|
||||
def build_button_attachments(
|
||||
num_buttons: List[Tuple[str, str]],
|
||||
special_buttons: List[Tuple[str, str, str]],
|
||||
color: str = "#1d74f5",
|
||||
title: str = "",
|
||||
number_buttons: bool = True,
|
||||
button_style: str = "primary",
|
||||
) -> List[dict]:
|
||||
"""Baut Attachments nach Andreas' 2-Reihen-Button-Pattern.
|
||||
|
||||
Regeln:
|
||||
- Nummerierte Buttons: max 3 pro Attachment, mit 1️⃣ 2️⃣ 3️⃣...
|
||||
(Nummerierung kann via number_buttons=False deaktiviert werden)
|
||||
- Sonderschaltflächen (↩️ Zurück, ⏭️ Skip, ➕ Neu): KEINE Nummer,
|
||||
IMMER in separatem (letztem) Attachment
|
||||
- Jedes Attachment hat max 3 actions
|
||||
@@ -179,8 +179,11 @@ def build_button_attachments(
|
||||
Args:
|
||||
num_buttons: Liste von (label, prefix) Tuples für nummerierte Buttons
|
||||
special_buttons: Liste von (label, prefix, style) Tuples für Sonderschaltflächen
|
||||
color: Attachment-Farbe
|
||||
color: Attachment-Farbe (default: "#1d74f5")
|
||||
title: Attachment-Titel (nur für erstes Attachment)
|
||||
number_buttons: Wenn False, werden Buttons NICHT nummeriert
|
||||
(z.B. für X-Buttons in Keywords-Edit)
|
||||
button_style: Rocket.Chat button style für num_buttons (default: "primary")
|
||||
|
||||
Returns:
|
||||
Liste von Attachment-Dicts (jedes mit max 3 actions)
|
||||
@@ -192,14 +195,18 @@ def build_button_attachments(
|
||||
chunk = num_buttons[i:i + 3]
|
||||
actions = []
|
||||
for j, (label, prefix) in enumerate(chunk):
|
||||
num_idx = i + j
|
||||
emoji = _EMOJI_NUMBERS[num_idx] if num_idx < len(_EMOJI_NUMBERS) else str(num_idx + 1)
|
||||
if number_buttons:
|
||||
num_idx = i + j
|
||||
emoji = _EMOJI_NUMBERS[num_idx] if num_idx < len(_EMOJI_NUMBERS) else str(num_idx + 1)
|
||||
text = f"{emoji} {label}"
|
||||
else:
|
||||
text = label
|
||||
actions.append({
|
||||
"type": "button",
|
||||
"text": f"{emoji} {label}",
|
||||
"text": text,
|
||||
"msg": prefix,
|
||||
"msg_in_chat_window": True,
|
||||
"style": "primary",
|
||||
"style": button_style,
|
||||
})
|
||||
att = {
|
||||
"color": color,
|
||||
@@ -440,38 +447,21 @@ def render_review_room_keywords_edit(
|
||||
lines.append("💬 Antworte mit einem neuen Keyword (2-30 Zeichen) "
|
||||
"oder klicke Zurück.")
|
||||
|
||||
# X-Buttons in 3er-Blöcke aufteilen (manuell, ohne build_button_attachments
|
||||
# da diese KEINE Nummern bekommen sollen)
|
||||
attachments: List[dict] = []
|
||||
for i in range(0, len(x_buttons), 3):
|
||||
chunk = x_buttons[i:i + 3]
|
||||
actions = []
|
||||
for label, prefix in chunk:
|
||||
actions.append({
|
||||
"type": "button",
|
||||
"text": label,
|
||||
"msg": prefix,
|
||||
"msg_in_chat_window": True,
|
||||
"style": "danger",
|
||||
})
|
||||
attachments.append({
|
||||
"color": "#1d74f5",
|
||||
"actions": actions,
|
||||
})
|
||||
|
||||
# Zurück-Button in separatem Attachment
|
||||
attachments.append({
|
||||
"color": "#1d74f5",
|
||||
"actions": [{
|
||||
"type": "button",
|
||||
"text": "↩️ Zurück",
|
||||
"msg": back_prefix,
|
||||
"msg_in_chat_window": True,
|
||||
"style": "default",
|
||||
}],
|
||||
})
|
||||
# P1-10(a): X-Buttons via build_button_attachments mit number_buttons=False
|
||||
# Eliminiert Code-Duplikation (vorher manuelles Attachment-Building)
|
||||
special_buttons: List[Tuple[str, str, str]] = [
|
||||
("↩️ Zurück", back_prefix, "default"),
|
||||
]
|
||||
|
||||
text = "\n".join(lines)
|
||||
attachments = build_button_attachments(
|
||||
x_buttons,
|
||||
special_buttons,
|
||||
color="#1d74f5",
|
||||
title=f"{kind_label} bearbeiten: {entry.name}",
|
||||
number_buttons=False,
|
||||
button_style="danger",
|
||||
)
|
||||
|
||||
return text, attachments
|
||||
|
||||
|
||||
Reference in New Issue
Block a user