Slick is a Slack bot to do ChatOps and other cool things.
Supported features:
time.Time
Recognition: a plugin to recognize your peers (!recognize @user1 for doing an awesome job)
Faceoff: a game to learn the names and faces of your colleagues. The code for this one is interesting to learn to build interactive features with slick
.
Vote: a simple voting plugin to decide where to lunch
Funny: a bunch of jokes and memes in reply to some strings in channels.. (inspired by Hubot's jokes)
Healthy: a very simple plugin that pokes URLs and reports on their health
Deployer: an example plugin to do deployments wth ansible (you'll probably want to roll out your own though).
Todo: todo list manager, one per channel
Try it with:
go get github.com/abourget/slick
cd $GOPATH/src/github.com/abourget/slick/example-bot
go install -v && $GOPATH/bin/example-bot
Copy the slick.sample.conf
file to $HOME/.slick
and tweak at will.
You might need mercurial
installed to get some dependencies.
Example code to handle deployments:
// listenDeploy was hooked into a plugin elsewhere..
func listenDeploy() {
keywords := []string{"project1", "project2", "project3"}
bot.Listen(&slick.Listener{
Matches: regexp.MustCompile("(can you|could you|please|plz|c'mon|icanhaz) deploy (" + strings.Join(keywords, "|") + ") (with|using)( revision| commit)? `?([a-z0-9]{4,42})`?"),
MentionsMeOnly: true,
MessageHandlerFunc: func(listen *slick.Listener, msg *slick.Message) {
projectName := msg.Match[2]
revision := msg.Match[5]
go func() {
go msg.AddReaction("work_hard")
defer msg.RemoveReaction("work_hard")
// Do the deployment with projectName and revision...
}()
},
})
}
Take inspiration by looking at the different plugins, like Funny
,
Healthy
, Storm
, Deployer
, etc.. Don't forget to update your
bot's plugins list, like in example-bot/main.go