Skip to content

Instantly share code, notes, and snippets.

@nna774
Last active June 26, 2016 17:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nna774/5992a4eaf59570c086a0c9cb133c7798 to your computer and use it in GitHub Desktop.
Save nna774/5992a4eaf59570c086a0c9cb133c7798 to your computer and use it in GitHub Desktop.
#! /usr/bin/ruby
# -*- encoding: utf-8 -*-
require 'json'
require "net/https"
WH_URI = "https://hooks.slack.com/services/hoehoehoehoe~~~~~~~~"
uptime = `uptime`.chomp
hash = {
"text" => "こ、殺される~~~っ!(uptime: #{uptime})",
"icon_emoji" => ":pepper:",
"username" => `hostname`.chomp,
"channel" => "#nona-kanshi",
}.to_json
hash = "payload=" + hash
uri = URI.parse(WH_URI)
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
req = Net::HTTP::Post.new(uri.request_uri)
req.body = hash
res = https.request(req)
puts res.body
[Unit]
Description=korosareru
After=network.target
[Service]
ExecStart=/bin/sleep 86400
ExecStop=/home/nona/.dotfiles/bin/acpi.rb
[Install]
WantedBy=multi-user.target
#! /usr/bin/ruby
# -*- encoding: utf-8 -*-
require 'json'
require "net/https"
WH_URI = "https://hooks.slack.com/services/hoehoe~~~~~~"
hashO = {
"text" => "おはようございます。僕はペッパーです。",
"icon_emoji" => ":pepper:",
"username" => `hostname`.chomp,
"channel" => "#nona-kanshi",
}
hash = "payload=" + hashO.to_json
uri = URI.parse(WH_URI)
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
req = Net::HTTP::Post.new(uri.request_uri)
req.body = hash
res = https.request(req)
puts res.body
hashO["text"] = "うそだよ。"
hash = "payload=" + hashO.to_json
req.body = hash
res = https.request(req)
puts res.body
[Unit]
Description=ohayou
After=network.target
[Service]
ExecStart=/home/nona/.dotfiles/bin/login.rb
Type=oneshot
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment