fix(P0-1): Raum-Setup 3er-Chunking via build_button_attachments — gemeinsames Modul button_builder.py
This commit is contained in:
+20
-25
@@ -4644,8 +4644,8 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
# Bug 3 fix: Robuster Zugriff auf _build_custom_buttons
|
||||
_build = self._get_build_custom_buttons()
|
||||
|
||||
# Emoji-Zahlen für bis zu 10 Räume
|
||||
EMOJI_NUMBERS = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣", "🔟"]
|
||||
# P0-1: build_button_attachments aus gemeinsamem Modul nutzen
|
||||
from archivar.button_builder import build_button_attachments, EMOJI_NUMBERS
|
||||
|
||||
lines = [
|
||||
"🤖 **Auto-Onboarding** — Ich habe Räume gefunden, die noch nicht in meiner Raum-Map stehen.",
|
||||
@@ -4667,27 +4667,28 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
lines.append("👉 Klicke auf eine Nummer, um den Raum einzurichten:")
|
||||
text = "\n".join(lines)
|
||||
|
||||
# Raum-Buttons: blaue Nummern (style='primary')
|
||||
buttons = []
|
||||
for i, room in enumerate(missing_rooms):
|
||||
# Raum-Buttons via build_button_attachments (3er-Chunking)
|
||||
num_buttons = []
|
||||
for room in missing_rooms:
|
||||
rid = room["room_id"]
|
||||
emoji = EMOJI_NUMBERS[i] if i < len(EMOJI_NUMBERS) else f"{i+1}."
|
||||
prefix = f"ONBOARD:{rid}"
|
||||
buttons.extend(_build(
|
||||
[emoji],
|
||||
prefix=prefix,
|
||||
style="primary"
|
||||
))
|
||||
clean_name = room["name"].lstrip("#")
|
||||
num_buttons.append((clean_name, f"ONBOARD:{rid}"))
|
||||
|
||||
# Globale Buttons (style='default' = grau)
|
||||
buttons.extend(_build(
|
||||
["⏭️ Alle überspringen", "⏰ Später"],
|
||||
prefix="ONBOARD"
|
||||
))
|
||||
special_buttons = [
|
||||
("⏭️ Alle überspringen", "ONBOARD", "default"),
|
||||
("⏰ Später", "ONBOARD", "default"),
|
||||
]
|
||||
|
||||
attachments = build_button_attachments(
|
||||
num_buttons,
|
||||
special_buttons,
|
||||
color="#1d74f5",
|
||||
title="Raum-Map unvollständig — Räume einrichten?",
|
||||
)
|
||||
|
||||
# Bug 3 fix: Wenn keine Buttons gebaut werden konnten, sende als Text
|
||||
# mit klarer Anleitung (Fallback, sollte nie eintreten)
|
||||
if not buttons:
|
||||
if not attachments:
|
||||
logger.error("[rocketchat] Onboarding: Konnte keine Buttons bauen — sende Text-Fallback")
|
||||
fallback_lines = lines + [
|
||||
"",
|
||||
@@ -4696,15 +4697,9 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
await self._post_message_with_retry(operator_room_id, "\n".join(fallback_lines))
|
||||
return
|
||||
|
||||
attachments = [{
|
||||
"color": "#1d74f5",
|
||||
"title": "Raum-Map unvollständig — Räume einrichten?",
|
||||
"actions": buttons,
|
||||
}]
|
||||
|
||||
success = await self._post_message_with_retry(operator_room_id, text, attachments=attachments)
|
||||
if success:
|
||||
logger.info("[rocketchat] Onboarding v2 gestartet: %d Räume fehlen, %d Buttons", len(missing_rooms), len(buttons))
|
||||
logger.info("[rocketchat] Onboarding v2 gestartet: %d Räume fehlen, %d Buttons", len(missing_rooms), sum(len(a.get("actions", [])) for a in attachments))
|
||||
else:
|
||||
logger.error("[rocketchat] Fehler beim Senden der Onboarding-Nachricht")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user