Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/k1low/slkm

slkm is github.com/slack-go/slack wrapper package for posting message.
https://github.com/k1low/slkm

slack

Last synced: 2 months ago
JSON representation

slkm is github.com/slack-go/slack wrapper package for posting message.

Awesome Lists containing this project

README

        

# slkm

slkm is `github.com/slack-go/slack` wrapper package for posting message.

This package converts channels and mentions of users and user groups into the correct ID notation.

- `#channel-name` -> `CXXXXXXXX`
- `@username` -> `<@UXXXXXXXX>`
- `@usergroup-name` -> ``

## Usage

``` go
package main

import (
"context"
"fmt"
"os"

"github.com/k1LoW/slkm"
"github.com/slack-go/slack"
)

const (
notifyChannel = "#service-alerts"
)

func main() {
ctx := context.Background()
c, err := slkm.New()
if err != nil {
log.Fatal(err)
}
c.SetUsername("wakeup-bot")
blocks := []slack.Block{
slack.NewSectionBlock(slack.NewTextBlockObject("mrkdwn", "Wake up @k1low !!", false, false), nil, nil),
}
if err := c.PostMessage(ctx, notifyChannel, blocks...); err != nil {
log.Fatal(err)
}
}

```

## Required scope of `SLACK_API_TOKEN`

- `channel:read`
- `chat:write`
- `chat:write.public`
- `users:read`
- `usergroups:read`
- `chat:write.customize` ( optional )