Created
March 2, 2019 18:10
-
-
Save nna774/a67379c6d140b46086bfd02ccdaf9b71 to your computer and use it in GitHub Desktop.
miterukun
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 'json' | |
require 'shellwords' | |
require 'net/https' | |
require 'uri' | |
MAHIRO = URI.parse "~~" | |
MORI = URI.parse "~~" | |
raw_report = STDIN.read | |
report = JSON.parse(raw_report) | |
http = Net::HTTP.new MAHIRO.host, MAHIRO.port | |
http.use_ssl = true | |
req = Net::HTTP::Post.new(MAHIRO.path) | |
req['content-type'] = 'application/json' | |
req.body = raw_report | |
res = http.request(req) | |
puts res.code | |
puts res.body | |
if JSON.parse(res.body)['status'] != 'ok' | |
throw 'something wen wrong' | |
end | |
body = { | |
username: 'miterukun', | |
channel: '#nona-kanshi', | |
} | |
if report['exitCode'] != 0 | |
body[:text] = "something went wrong!\noutput:\n" | |
body[:text] += report['output'] | |
else | |
body[:text] = "miterukun exit normaly.\n" | |
if report['output'] != '' | |
body[:text] += "output:\n" | |
body[:text] += report['output'] | |
end | |
end | |
http = Net::HTTP.new MORI.host, MORI.port | |
http.use_ssl = true | |
req = Net::HTTP::Post.new(MORI.path) | |
req.body = body.to_json | |
res = http.request(req) | |
puts res.code | |
puts res.body | |
if JSON.parse(res.body)['status'] != 'ok' | |
throw 'something wen wrong' | |
end |
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
#! /bin/bash | |
curl -XPOST https://~~ \ | |
-d "{\"username\": \"miterukun\", \"text\": \"starting miterukun\", \"icon_emoji\": \":eyes:\", \"channel\": \"#nona-kanshi\"}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment