Simple Slack block builder
package main
import . "github.com/snpkx/slacker"
func main() {
blocks := Blocks(
Section(WithTextObj(Pt("Hello, world!"))),
Section(WithFields(Pt("left"), Pt("right"))),
OptionInput(
Input("blockId", "actionId", WithLabel("Choose one")),
WithOptionStrings("A", "B", "C"),
WithOptionPlaceholder("alphabets..."),
),
)
}
package main
import . "github.com/snpkx/slacker"
type Metadata struct {
Stage int
}
func main() {
metadata := Metadata{
Stage: 1,
}
request := ModalViewRequest(
Pt("title"), nil, Pt("close"),
Blocks(
Section(WithTextObj(Pt("text"))),
),
WithJsonPrivateMetadata(metadata),
)
}
Same as slack.NewTextBlockObject(slack.PlainTextType, text, false, false)
Same as slack.NewTextBlockObject(slack.MarkdownType, text, false, false)
Run slack block providers and merge blocks into slack.Blocks
Blocks(
Section(WithTextObj(Pt("text"))),
Section(WithTextObj(Pt("text")))
)
Select block based on condition
// Pt("true") will return
OrBlock(true, Pt("true"), Pt("false"))
Same as above but condition is function.
OrFuncBlock(func() {
return random.Intn(100) & 1 == 0
}, Pt("Even"), Pt("Odd"))
Build slack.ModalViewRequest