Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/k1low/slkm
- Owner: k1LoW
- License: mit
- Created: 2023-01-10T05:09:46.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-02T04:05:08.000Z (4 months ago)
- Last Synced: 2024-10-06T04:16:44.298Z (3 months ago)
- Topics: slack
- Language: Go
- Homepage:
- Size: 28.3 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
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 mainimport (
"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 )