lib-slackbot is a thin convenience wrapper around nlopes' excellent Slack API in Go.
When writing slack bots in Go 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.
$ go get github.com/premshree/lib-slackbot
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()
}