A C# port of Hubot
Clone or download
Latest commit b728f90 Oct 11, 2015
Permalink
Failed to load latest commit information.
.nuget add nuget exe Sep 19, 2013
Docs/Images
MMBot.AzureTableBrain
MMBot.Core
MMBot.HipChat
MMBot.Jabbr
MMBot.Powershell
MMBot.RedisBrain
MMBot.Router.Nancy Fix tests Sep 16, 2014
MMBot.ScriptIt
MMBot.Slack
MMBot.Spotify
MMBot.Tests
MMBot.XMPP
build
lib
mmbot
packages More ref fixes Nov 14, 2014
.gitattributes
.gitignore
CreatePackages.ps1
LICENSE.md Added license Sep 28, 2013
MMBot.sln
README.md Update README.md Jun 14, 2014
mmbot.chocolatey.nuspec

README.md

Stories in You Take It
Build Status
Gitter chat

mmbot

Overview

mmbot is a port of github's Hubot to C#.

mmbot

Goals

  1. Provide a chat bot written in C# with all the functionality of Hubot but with a script environment more familiar to .Net devs. (done)
  2. Hubot scripts should be easy to convert into mmbot scripts. (done)
    This may mean that some weird design choices are made in the API 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 (done)
  4. Eventually provide the ability to run from scriptcs. (blocked)
    There are some blockers here in the NuGet package resolution and dynamic loading of scripts

Getting started

The best plan is to use chocolatey...

# chocolatey can install mmbot globally
cinst mmbot

# Now create a folder to host the scripts and config, then from that dir...
mmbot --init

# You're ready to go...
mmbot

When you need an adapter to talk to your chat rooms

nuget install mmbot.jabbr -o packages

When you want a script that is in nuget use the nuget command line in your path (installed via cinst nuget.commandline)

nuget install mmbot.scriptit -o packages

...or simply drop the .csx file in the "scripts" folder ...or even better use the scriptthis and scriptthat scripts to input them inline or pull from a gist!!!

For more info read the getting started guide

Adapters

Currently adapters exist for jabbr, HipChat, Slack and XMPP but with plans to add a CampFire adapter soon. The implementation is extremely similar to Hubot so other adapters could easily be added. Learn how to get your preferred adapter up and running in configuring mmbot.

Scripts

Writing scripts is easy. You can either implement the IMMBotScript interface and register your script or you can write a simple scriptcs script and drop it into a scripts folder beside the MMBot runner executable.

Here is a simple script that responds to "mmbot yo" with "sup?"

var robot = Require<Robot>();

robot.Respond("yo", msg => msg.Send("sup?"));

This script is a port of the Hubot math script

var robot = Require<Robot>();

robot.Respond(@"(calc|calculate|calculator|convert|math|maths)( me)? (.*)", msg =>
	{
	    msg
	    .Http("https://www.google.com/ig/calculator")
        .Query(new
        {
            hl = "en",
            q = msg.Match[3]
        })
        .Headers(new Dictionary<string, string>
        {
            {"Accept-Language", "en-us,en;q=0.5"},
            {"Accept-Charset", "utf-8"},
            {"User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"}
        })
        .GetJson((err, res, body) => 
        {
        	if(err != null)
        	{
        		msg.Send("Could not compute");
        	}
        	else 
        	{
        		msg.Send((string)body["rhs"] ?? "Could not compute");
        	}
        });
});

robot.AddHelp(
    "mmbot math me <expression> - Calculate the given expression.",
    "mmbot convert me <expression> to <units> - Convert expression to given units."
);

You can even tell mmbot to watch for changes to script files when you run him

mmbot --watch

Current Script Implementations

The script catalog is available at mmbot.github.io/mmbot.scripts

You can also search the script catalog from within mmbot and even install scripts from there.

# List the scripts in the catalog
mmbot scripts

# Install a script (Pug)
mmbot download script Pug