m 2 wiki-irc: use git.io shortener
This commit is contained in:
parent
ac3eec386c
commit
919b028fff
|
@ -16,9 +16,22 @@ in {
|
|||
if ([pages]) {
|
||||
ruby {
|
||||
code => '
|
||||
o = ""
|
||||
event["pages"].each { |p| o = o + "\"" + p["title"] + "\" " + p["action"] +" by "+ event["sender"]["login"]+" " +p["html_url"] + "/_compare/" + p["sha"] + "\n" }
|
||||
event["output"] = o
|
||||
require "net/http"
|
||||
require "net/https"
|
||||
http = Net::HTTP.new("git.io", 443)
|
||||
http.use_ssl = true
|
||||
lines = []
|
||||
event["pages"].each {|p|
|
||||
url = "#{p["html_url"]}/_compare/#{p["sha"]}"
|
||||
short_url = begin
|
||||
request = Net::HTTP::Post.new "/"
|
||||
request.set_form_data ({"url" => url })
|
||||
response = http.request(request)
|
||||
response["location"]
|
||||
end
|
||||
lines << "\"#{p["title"]}\" #{p["action"]} by #{event["sender"]["login"]} #{short_url}"
|
||||
}
|
||||
event["output"] = lines.join("\n")
|
||||
'
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue