lazlo

A chatops automation framework for Slack in Go

  • Owner: djosephsen/lazlo
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

Lazlo

An event-driven, lua-scriptable chatops automation framework for Slack in Go. (phew)

The prototypical IRC bot responds to text. Generally, the pattern is you
provide a regex to match on, and some code to run when someone says something
in chat that matches your regular expression. Your plugin runs when a pattern
match happens, and then returns.

Your Lazlo module, by comparison is started at runtime and stays resident in
memory. Outwardly, Lazlo acts like a bot, but internally Lazlo works as an
event broker. Your module registers for callbacks -- you can tell Lazlo what
sorts of events your module finds interesting. For each callback your module
registers, Lazlo will hand back a channel. Your module can block on the
channel, waiting for something to happen, or it can register more callbacks (as
many as you have memory for), and select between them in a loop. Throughout its
lifetime, your Module can de-register the callbacks it doesn't need anymore, and
ask for new ones as circumstances demand.

Currently there are five different kinds of callbacks you can ask for.

  • Message callbacks specify regex you want to listen for and respond to.
  • Event callbacks specify slack api events you want to listen for and respond to.
  • Timer Callbacks start a (possibly reoccuring) timer (in cron syntax), and notify you when it runs down
  • Link Callbacks create a URL that users can click on. When they do, their GET request is brokered back to your module. (Post and Put support coming soon)
  • Question Callbacks make it easy to ask users a question, and capture their response.

Your module can register for all or none of these, as many times as it likes
during the lifetime of the bot. Lazlo makes it easier to write modules that
carry out common chat-ops patterns. For example, you can pretty easily write a
module that:

  1. registers for a message callback for bot deploy (\w+)
  2. blocks waiting for that command to be executed
  3. when executed, registers for a message callback that matches the specific user that asked for the deploy with the regex: 'authenticate '
  4. DM's that user prompting for a password
  5. registers a timer callback that expires in 3 minutes
  6. Blocks waiting for either the password or the timer
  7. Authenticates the user, and runs the CM tool of the week to perform the deploy
  8. Captures output from that tool and presents it back to the user
  9. de-registers the timer and password callbacks

That's an oversimplified example, but I hope you get the idea. Check out the
Modules directory for working examples that use the various callbacks.

Lua plug-ins

Lazlo's event-driven framework is quite flexible. You can use it to write some
pretty powerful modules in Go. For example, I implemented a module that embeds
a lua state machine which makes it possible to extend Lazlo by write simple
plugins that use hubot-like syntax in lua

Whats next?

Current Status

Lazlo is basically working and basically documented. All callback types are
implemented and functional and there are several included modules of varying
degress of complexity that should help get you started writing your own.

Todo's in order of when I'll probably get to them:

  • Plugin to keep lazlo metadata in synch with Slack
  • Leader-elections for HA bots. (moved up because heroku changing it's dyno pricing)
  • Godoc, Documentation Documentation and Documentation
  • Lua support is new and only includes support for message callbacks (hear respond and reply). I'd like you to be able to get timers and links via lua as well.
  • More included plugins

Main metrics

Overview
Name With Ownerdjosephsen/lazlo
Primary LanguageGo
Program languageShell (Language Count: 4)
Platform
License:MIT License
所有者活动
Created At2015-03-05 04:32:58
Pushed At2016-06-06 18:54:45
Last Commit At2016-06-06 13:54:45
Release Count0
用户参与
Stargazers Count147
Watchers Count12
Fork Count18
Commits Count68
Has Issues Enabled
Issues Count3
Issue Open Count2
Pull Requests Count4
Pull Requests Open Count1
Pull Requests Close Count1
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private