def open_modal(trigger_id: str):
    try:
        view = View(type="modal",
                    callback_id="modal-id",
                    title=PlainTextObject(text="Awesome Modal"),
                    submit=PlainTextObject(text="Submit"),
                    close=PlainTextObject(text="Cancel"),
                    blocks=[
                        InputBlock(block_id="b-id-1",
                                   label=PlainTextObject(text="Input label"),
                                   element=ConversationSelectElement(
                                       action_id="a",
                                       default_to_current_conversation=True,
                                   )),
                        InputBlock(block_id="b-id-2",
                                   label=PlainTextObject(text="Input label"),
                                   element=ConversationMultiSelectElement(
                                       action_id="a",
                                       max_selected_items=2,
                                       default_to_current_conversation=True,
                                   )),
                    ])
        api_response = client.views_open(trigger_id=trigger_id, view=view)
        return make_response("", 200)
    except SlackApiError as e:
        code = e.response["error"]
        return make_response(f"Failed to open a modal due to {code}", 200)
Пример #2
0
 def test_document(self):
     input = {
         "action_id": "text1234",
         "type": "multi_conversations_select",
         "placeholder": {
             "type": "plain_text",
             "text": "Select conversations"
         },
         "initial_conversations": ["C123", "C234"],
         "max_selected_items": 2,
         "filter": {
             "include": ["public", "mpim"],
             "exclude_bot_users": True
         },
     }
     self.assertDictEqual(input,
                          ConversationMultiSelectElement(**input).to_dict())