Skip to content

Instantly share code, notes, and snippets.

@EnriqueVidal
Created April 17, 2012 19:09
Show Gist options
  • Save EnriqueVidal/2408349 to your computer and use it in GitHub Desktop.
Save EnriqueVidal/2408349 to your computer and use it in GitHub Desktop.
Simple hubot repoter
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
HUBOT_URI = ( ENV['HUBOT_URI'] || "http://your-domain.herokuapp.com/" )
OPTS = {
"partychat-hook" => ( ENV['PARTYCHAT_HOOK'] || "foo" ),
"reporter" => ( ENV['PARTYCHAT_REPORTER'] || "[Reporter]" ),
"from" => ( ENV['PARTYCHAT_FROM'] || "your.chat@im.partych.at" ),
"on-behalf-of" => ( ENV['PARTYCHAT_BEHALF_OF'] || "foo.bar" ),
"command" => ( ENV['HUBOT_COMMAND'] || "hubot echo" )
}
class Reporter
def self.send_message
url = URI.parse HUBOT_URI
request = Net::HTTP::Post.new url.path
request.set_form_data OPTS.merge( 'body' => "#{ OPTS['reporter'] } #{ OPTS['command'] } #{ ARGV.join(' ') }".strip )
Net::HTTP.new(url.host, url.port).start {|http| http.request( request ) }
end
end
Reporter.send_message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment