mmbot is a port of github's Hubot to C#.
- Provide a chat bot written in C# with all the functionality of Hubot but with a script environment more familiar to .Net devs. (done)
- 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 - ScriptCS style scripts should be automatically picked up and run from a scripts folder (done)
- Eventually provide the ability to run from scriptcs. (blocked)
There are some blockers here in the NuGet package resolution and dynamic loading of scripts
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
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.
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
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