Git Product home page Git Product logo

twitterbot-3's Introduction

Jabbot

Jabbot is a bot API for JabbR.

Why not write an apater for Hubot?

I like writing C# :).

It's as easy as:

var bot = new Bot("http://myjabbot", "username", "password");
bot.PowerUp();
bot.Join("someroom");
bot.Say("Hello", "someroom");
bot.Say("Ok I'm off");
bot.ShutDown();

Writing Sprokets

Sprokets are things you can plug-in to enhance the behavior of your bot. Simply drop a dll with classes that implement ISproket into a Sprokets folder and you're done. Here's an port of the math.coffee from hubot:

public class MathSproket : RegexSproket
{
    public override Regex Pattern
    {
        get { return new Regex("(calc|calculate|convert|math)( me)? (.*)"); }
    }

    protected override void ProcessMatch(Match match, ChatMessage message, Bot bot)
    {
        var client = new HttpClient();
        client.DefaultRequestHeaders.AcceptLanguage.Add(new StringWithQualityHeaderValue("en-us"));
        client.DefaultRequestHeaders.AcceptCharset.Add(new StringWithQualityHeaderValue("utf-8"));

        client.GetAsync("http://www.google.com/ig/calculator?hl=en&q=" + Uri.EscapeDataString(match.Groups[3].Value))
              .ContinueWith(task =>
              {
                  if (task.Result.IsSuccessStatusCode)
                  {
                      task.Result.Content.ReadAsStringAsync().ContinueWith(readTask =>
                      {
                          dynamic json =  JsonConvert.DeserializeObject(readTask.Result);

                          string solution = json.rhs;

                          bot.Reply(message.FromUser, solution ?? "Could not compute.", message.Room);
                      });
                  }
              });
    }
}

twitterbot-3's People

Contributors

davidfowl avatar sethwebster avatar

Stargazers

 avatar

Watchers

 avatar  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.