justinweiss / robut

A simple plugin-enabled HipChat bot
171 stars 48 forks source link

HTTP handler #29

Closed ejholmes closed 11 years ago

ejholmes commented 11 years ago

This adds support for receiving events (heroku deploy hooks, GitHub post receive hooks, etc.) and outputting messages to all rooms.

Example

# config.ru

require 'rubygems'
require 'bundler/setup'
Bundler.require :default

require 'robut'
require 'ostruct'
require 'logger'

load './Chatfile'

Robut::Web.set :connection, Robut::Connection.new.connect

run Robut::Web


# lib/robut/plugin/heroku.rb

class Robut::Plugin::Heroku
  include Robut::Plugin

  http do
    post '/heroku' do
      payload = Hashie::Mash.new(params)
      say "#{payload.user} deployed #{payload.head} to #{payload.app}", nil
      halt 200
    end
  end
end
justinweiss commented 11 years ago

Hey, I'm totally not ignoring this! I've been super busy and haven't had a chance to look it this yet, but it's a cool idea. I'll try to take a look sometime in the next few days.

ejholmes commented 11 years ago

No rush :)

justinweiss commented 11 years ago

Sorry this took so long! Turns out home buying takes all the time.

Code looks good, I didn't see any problems. If you could, though, I'd appreciate if you could rdoc the web plugin and http method, and maybe add an example to the readme? I think pretty much exactly what you have in the pull request would be great.

ejholmes commented 11 years ago

Added some rdocs!

Congrats on the :house: buying :)

justinweiss commented 11 years ago

Awesome, thanks!