ttaylorr/slacker — pull request #9 by justinhennessy (2014-09-01 02:31:42+00:00)
Title: Add JSON Responder module

This module sets up a rapid mechanism for people to develop Slacker plugins that call an HTTP end point then render the JSON returned for use in slacker.

So here is a simple scenario, I have an HTTP service that tells me what my IP is:

```
http://jsonip.com
```

And when called this is what it returns:

```
{"ip"=>"59.167.218.225, 202.177.218.91", "about"=>"/about", "Pro!"=>"http://getjsonip.com"}
```

So with JSON Responder you can build a plugin as follows:

```ruby
require_relative 'json_responder'

module Slacker
class MyIP < Plugin
include JSONResponder

def help
"slacker myip"
end

def pattern
/myip/i
end

def url_for
'http://jsonip.com'
end

def process_response (result)
result["ip"]
end

Bot.register(MyIP)
end
end
```