This repository was archived by the owner on Nov 14, 2025. It is now read-only.
forked from slack-go/slack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblock.go
More file actions
51 lines (42 loc) · 1.51 KB
/
block.go
File metadata and controls
51 lines (42 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package slack
// @NOTE: Blocks are in beta and subject to change.
// More Information: https://api.slack.com/block-kit
// MessageBlockType defines a named string type to define each block type
// as a constant for use within the package.
type MessageBlockType string
type MessageElementType string
type MessageObjectType string
const (
mbtSection MessageBlockType = "section"
mbtDivider MessageBlockType = "divider"
mbtImage MessageBlockType = "image"
mbtAction MessageBlockType = "actions"
mbtContext MessageBlockType = "context"
metImage MessageElementType = "image"
metButton MessageElementType = "button"
metOverflow MessageElementType = "overflow"
metDatepicker MessageElementType = "datepicker"
metSelect MessageElementType = "static_select"
motImage MessageObjectType = "image"
motConfirmation MessageObjectType = "confirmation"
motOption MessageObjectType = "option"
motOptionGroup MessageObjectType = "option_group"
)
// block defines an interface all block types should implement
// to ensure consistency between blocks.
type block interface {
blockType() MessageBlockType
}
// NewBlockMessage creates a new Message that contains one or more blocks to be displayed
func NewBlockMessage(blocks ...block) Message {
return Message{
Msg: Msg{
Blocks: blocks,
},
}
}
// AddBlockMessage appends a block to the end of the existing list of blocks
func AddBlockMessage(message Message, newBlk block) Message {
message.Msg.Blocks = append(message.Msg.Blocks, newBlk)
return message
}