Skip to content

Instantly share code, notes, and snippets.

@nna774
Created March 2, 2019 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nna774/a67379c6d140b46086bfd02ccdaf9b71 to your computer and use it in GitHub Desktop.
Save nna774/a67379c6d140b46086bfd02ccdaf9b71 to your computer and use it in GitHub Desktop.
miterukun
#! /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
#! /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