https://github.com/premshree/lib-slackbot
A thin library to make writing slackbot commands super simple
https://github.com/premshree/lib-slackbot
golang productivity slack slackbot
Last synced: 2 months ago
JSON representation
A thin library to make writing slackbot commands super simple
- Host: GitHub
- URL: https://github.com/premshree/lib-slackbot
- Owner: premshree
- Created: 2017-07-27T21:53:30.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-04T01:01:56.000Z (almost 9 years ago)
- Last Synced: 2025-10-06T15:51:33.761Z (9 months ago)
- Topics: golang, productivity, slack, slackbot
- Language: Go
- Size: 70.3 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# lib-slackbot
[](https://travis-ci.org/premshree/lib-slackbot)
lib-slackbot is a thin convenience wrapper around nlopes' excellent [Slack API in Go](https://github.com/nlopes/slack).
When writing [slack](https://slack.com/) bots in [Go](https://golang.org/) I found myself repeating a lot of the same boilerplate. This is where lib-slackbot is useful. Currently, lib-slackbot is useful whenever you want to write a bot that listens to commands with optional arguments like so:
```
?weather 11231
?oncall
```
See the `examples` directory for an implementation.
## Installation
```
$ go get github.com/premshree/lib-slackbot
```
## Example
```go
package main
import(
"time"
"github.com/premshree/lib-slackbot"
)
func main() {
token := "YOUR_SLACK_BOT_TOKEN"
bot := slackbot.New(token)
bot.AddCommand("?time", "What's the local time?", func(bot *slackbot.Bot, channelID string, channelName string, args ...string) {
t := time.Now()
bot.Reply(channelID, t.Format("Mon Jan _2 15:04:05 2006"))
})
// Run starts the bot's listen loop
bot.Run()
}
```