Created
April 17, 2012 19:09
-
-
Save EnriqueVidal/2408349 to your computer and use it in GitHub Desktop.
Simple hubot repoter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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'] || "[email protected]" ), | |
"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