fix(P-066-followup): send_clarify nutzt button_builder-Pipeline — Emojis, Chunking, action_id
ROOT CAUSE: send_clarify baute Buttons manuell mit _build_custom_buttons (plain '1','2','3' ohne Emojis, alle in EINEM Attachment ohne Chunking). FIX: - build_button_attachments() aus archivar/button_builder.py statt manueller Buttons - Emoji-Nummern (1️⃣2️⃣3️⃣) via EMOJI_NUMBERS - Chunking: max 3 Buttons pro Attachment - action_id in jedem Button (P-051-konform) - Other-Button als separates Attachment (altes Format CLARIFY:<id>:other) - Payload-Format CLARIFY:<id>:<idx> (ohne ::) — der ::-Handler war ein No-Op, das alte Format funktioniert korrekt mit resolve_gateway_clarify()
This commit is contained in:
+27
-13
@@ -7250,27 +7250,41 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
)
|
)
|
||||||
text += f"\n\n{option_lines}"
|
text += f"\n\n{option_lines}"
|
||||||
|
|
||||||
# Build buttons with short labels to avoid truncation
|
# P-066-Follow-up: Nutze button_builder-Pipeline statt manueller Buttons.
|
||||||
button_labels = [str(i + 1) for i in range(len(choices))]
|
# build_button_attachments liefert Emoji-Nummern (1️⃣2️⃣3️⃣),
|
||||||
buttons = _build_custom_buttons(button_labels, prefix=f"CLARIFY:{clarify_id}")
|
# Chunking (max 3 pro Attachment) und action_id pro Button.
|
||||||
|
# Wir nutzen das ALTE Payload-Format CLARIFY:<id>:<idx> (ohne ::),
|
||||||
|
# weil der ::-Handler in _handle_message ein No-Op ist (P-066-Follow-up).
|
||||||
|
from archivar.button_builder import build_button_attachments, EMOJI_NUMBERS
|
||||||
|
|
||||||
# Add "Other" button with special handling
|
num_buttons = []
|
||||||
|
for i, choice_text in enumerate(choices):
|
||||||
|
idx = i + 1 # 1-basierte Indizes (kompatibel mit CLARIFY-Handler)
|
||||||
|
num_buttons.append((choice_text, f"CLARIFY:{clarify_id}:{idx}"))
|
||||||
|
|
||||||
|
attachments = build_button_attachments(
|
||||||
|
num_buttons,
|
||||||
|
special_buttons=[], # Other-Button manuell (altes Format)
|
||||||
|
color="#1d74f5",
|
||||||
|
title="Bitte wähle eine Option:",
|
||||||
|
number_buttons=True,
|
||||||
|
button_style="primary",
|
||||||
|
)
|
||||||
|
|
||||||
|
# Other-Button als separates Attachment (altes Format CLARIFY:<id>:other)
|
||||||
other_payload = f"CLARIFY:{clarify_id}:other"
|
other_payload = f"CLARIFY:{clarify_id}:other"
|
||||||
buttons.append({
|
other_attachment = {
|
||||||
|
"color": "#1d74f5",
|
||||||
|
"actions": [{
|
||||||
"type": "button",
|
"type": "button",
|
||||||
"text": "✏️ Andere (Freitext)",
|
"text": "✏️ Andere (Freitext)",
|
||||||
"msg": other_payload,
|
"msg": other_payload,
|
||||||
"msg_in_chat_window": True,
|
"msg_in_chat_window": True,
|
||||||
"style": "default",
|
"style": "default",
|
||||||
"action_id": hashlib.sha1(f"{other_payload}:0".encode()).hexdigest()[:12],
|
"action_id": hashlib.sha1(f"{other_payload}:0".encode()).hexdigest()[:12],
|
||||||
})
|
}],
|
||||||
|
}
|
||||||
# Create attachment with buttons
|
attachments.append(other_attachment)
|
||||||
attachments = [{
|
|
||||||
"color": "#1d74f5",
|
|
||||||
"title": "Bitte wähle eine Option:",
|
|
||||||
"actions": buttons,
|
|
||||||
}]
|
|
||||||
|
|
||||||
# Send message with buttons
|
# Send message with buttons
|
||||||
success = await self._post_message_with_retry(real_room_id, text, attachments=attachments)
|
success = await self._post_message_with_retry(real_room_id, text, attachments=attachments)
|
||||||
|
|||||||
Reference in New Issue
Block a user