Giter Site home page Giter Site logo

mmbot's Introduction

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

mmbot's People

Contributors

andreasohlund avatar antoinne85 avatar distantcam avatar dkarzon avatar ghosttw avatar jamesbascle avatar jamessantiago avatar janovesk avatar moserware avatar petegoo avatar porges avatar spksh avatar waffle-with-pears avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.