Categorygithub.com/CapstoneLabs/slick
modulepackage
0.0.1
Repository: https://github.com/capstonelabs/slick.git
Documentation: pkg.go.dev

# README

Build Status

Slick - A Slack bot in Go

Slick is a Slack bot to do ChatOps and other cool things. Slick was originally developed here and has since been adopted by Capstone for internal use :)

Features

Supported features:

  • Plugin interface for chat messages
  • Plugin-based HTTP handlers
  • Simple API to reply to users
  • Keeps an internal state of channels, users and their state.
  • Listen for Reactions; take actions based on them (like buttons).
  • Simple API to message users privately
  • Simple API to update a previously sent message
  • Simple API to delete bot messages after a given time duration.
  • Easy plugin interface, listeners with criteria such as:
    • Messages directed to the bot only
    • Private or public messages
    • Listens for a duration or until a given time.Time
    • Selectively on a channel, or from a user
    • Expire listeners and unregister them dynamically
    • Supports listening for edits or not
    • Regexp match messages, or Contains checks
  • Built-in KV store for data persistence (backed by BoltDB and JSON serialization)
  • The bot has a mood (happy and hyper) which changes randomly.. you can base some decisions on it, to spice up conversations.
  • Supports listening for any Slack events (ChannelCreated, ChannelJoined, EmojiChanged, FileShared, GroupArchived, etc..)
  • A PubSub system to facilitate inter-plugins (or chat-to-web) communications.

Stock plugins

  1. Recognition: a plugin to recognize your peers (!recognize @user1 for doing an awesome job)

  2. 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.

  3. Vote: a simple voting plugin to decide where to lunch

  4. Funny: a bunch of jokes and memes in reply to some strings in channels.. (inspired by Hubot's jokes)

  5. Healthy: a very simple plugin that pokes URLs and reports on their health

  6. Deployer: an example plugin to do deployments wth ansible (you'll probably want to roll out your own though).

  7. Todo: todo list manager, one per channel

Local build and install

Try it with:

go get github.com/CapstoneLabs/slick
cd $GOPATH/src/github.com/CapstoneLabs/slick/example-bot
go install -v && $GOPATH/bin/example-bot

There's a Dockerfile and example configuration in the example-bot directory.

Writing your own plugin

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

# Packages

Package asana is a plugin for Slick that interacts with Asana.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Package GitHub is a plugin for Slick that interacts with GitHub.
Package healthy is a Slick plugin that evaluates whether URLs return 200's or not.
No description provided by the author
No description provided by the author
No description provided by the author
Package plotberry is a plugin for Slick that reads Plotly graphs.
Package recognition is a plugin for Slick that recognizes team members.
Package standup is a plugin for Slick that facilitates standups for teams.
No description provided by the author
Package todo is a plugin for Slick that creates to do lists per channel.
pulled from this anonymous playground http://play.golang.org/p/x4CoUsJ5tK.
Package vote is a plugin for Slick that aids in picking a lunch spot.
No description provided by the author
No description provided by the author
No description provided by the author
Package wicked is a plugin for Slick that facilitates conferences over Slack.

# Functions

AfterNextWeekdayTime from a given Time and a Weekday + hour + minute returns a channel that waits for the duration to elapse and then sends the current time on the returned channel.
No description provided by the author
No description provided by the author
No description provided by the author
Format conditionally formats using fmt.Sprintf if there is more than one argument, otherwise returns the first parameter uninterpreted.
No description provided by the author
NextWeekdayTime from a given Time and a Weekday + hour + minute returns the next WeekdayTime and the elapsed time between the two instants as an int64 nanosecond count.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
ReactionAdded is used as the `Type` field of `ReactionEvent` (which you can register with `Reply.OnReaction()`).
ReactionRemoved is the flipside of `ReactionAdded`.

# Structs

Bot is the main slick bot instance.
Channel is an abstraction of the Slack channels, with merged and distinguished data from IMs, Groups and Channels.
No description provided by the author
No description provided by the author
Logging contains the configuration for logrus.
No description provided by the author
No description provided by the author
No description provided by the author
Reply .
No description provided by the author
UpdateableReply is a Reply that the bot sent, and that it is able to update after the fact.

# Interfaces

No description provided by the author
No description provided by the author
WebPlugin initializes plugins with a `Bot` instance, a `privateRouter` and a `publicRouter`.
No description provided by the author
WebServerAuth returns a middleware warpping the passed on `http.Handler`.

# Type aliases

No description provided by the author