m 2 wiki-irc: use git.io shortener

This commit is contained in:
makefu 2017-04-28 12:43:20 +02:00
parent b1cad2a649
commit 609a641ea4
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225

View File

@ -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")
'
}
}