Peter Goodman bio photo

Peter Goodman

A developer living in Auckland building software using all sorts of bits and pieces I find along the way. Originally from Northern Ireland.

Twitter Google+ LinkedIn Github

I’ve been playing recently with github’s Hubot chat bot, written in Coffee script on Node. I wanted to connect it to our jabbr instance with the least amount of friction and to provide our team with an office jukebox, build automation and various meme-oriented distractions. There is a pretty good adapter for Hubot to do this but after having a few issues I decided it might be easier to do a port to C# so I could more easily write scripts and connect to jabbr (which is written in C# and has some ready made APIs).

The result is mmbot, a hubot port that follows the same basic architecture of Hubot with minimal changes. The basic goals of mmbot are thusly:

  1. Provide a chat bot written in C# with all the functionality of Hubot but with a script environment more familiar to .Net devs.
  2. Hubot scripts should be easy to convert into mmbot scripts.
    This may mean that there are some weird overloads in the API for writing scripts that look like hubot scripts but it should still be very usable, customizable and familiar to .Net devs.
  3. ScriptCS style scripts should be automatically picked up and run from a scripts folder
  4. Hubot scripts should be easy to convert into mmbot scripts.
    There are some blockers here in the NuGet package resolution and dynamic loading of scripts

Currently there are 2 adapters for mmbot - jabbr and HipChat. The jabbr adapter is the most used at the moment but the HipChat one should also be working.

Scripts can be written in code by implementing IMMBotScript or by dropping a scriptcs csx file into a scripts folder beside the executable. The pre-compiled approach gives you the power of async/await and the speed of using dynamic while scriptcs means you don’t need to create dll. The experience of porting Hubot scripts has so far been pretty painless as the API was designed to make this process incredibly easy.

Here is the hubot math script in scriptcs form

And as an IMMBot script

Notice that there is an Http fluent style helper for creating requests and processing the responses using HttpClient and Json.Net.

Starting mmbot

Starting mmbot is easy. You can choose to configure him by environment variables or by passing in config parameters in code


What scripts does it have?

mmbot currently has the following scripts

  • Searching for images, animated gifs, cats, pugs, maps, youtube videos
  • Urban Dictionary definitions
  • Ascii art generator
  • Mustache me (place a mustache on someone’s face)
  • Xkcd comics
  • Spotify player /office jukebox with playlist, query, album, track playing and queuing and volume control.
  • Jetbrains TeamCity build server – querying build status, starting builds etc.

Thanks to Damian Karzon for contributing some of the scripts. Check out the current catalog at http://github.com/petegoo/mmbot

What's next?

Next for mmbot is to try to implement a few cooler features like loading and saving scripts from gists, starting from scriptcs (some issues here currently) and to get the script catalog expanded.

Go check out the mmbot code on github.