send_clarify(): chunk buttons into max 3 per attachment row
Matches the Archivar-Clarify pattern (MAX_BUTTONS_PER_ROW = 3, line 5085). Instead of one attachment with all actions, split into multiple attachments each with max 3 buttons. The 'Other' button counts as one of the 3. Example: 4 choices + Other = 5 buttons -> 2 attachments: [1 2 3] + [4 Other]
This commit is contained in:
+13
-1
@@ -7547,12 +7547,24 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
"style": "default",
|
"style": "default",
|
||||||
})
|
})
|
||||||
|
|
||||||
# Create attachment with buttons
|
# Create attachment(s) with buttons — max 3 per row (UX: mobile readability)
|
||||||
|
MAX_BUTTONS_PER_ROW = 3
|
||||||
attachments = [{
|
attachments = [{
|
||||||
"color": "#1d74f5",
|
"color": "#1d74f5",
|
||||||
"title": "Please choose an option:",
|
"title": "Please choose an option:",
|
||||||
"actions": buttons,
|
"actions": buttons,
|
||||||
}]
|
}]
|
||||||
|
if len(buttons) > MAX_BUTTONS_PER_ROW:
|
||||||
|
attachments = []
|
||||||
|
for i in range(0, len(buttons), MAX_BUTTONS_PER_ROW):
|
||||||
|
chunk = buttons[i:i + MAX_BUTTONS_PER_ROW]
|
||||||
|
attachments.append({
|
||||||
|
"color": "#1d74f5",
|
||||||
|
"actions": chunk,
|
||||||
|
})
|
||||||
|
# First attachment gets the title
|
||||||
|
if attachments:
|
||||||
|
attachments[0]["title"] = "Please choose an option:"
|
||||||
|
|
||||||
# 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