Skip to content

Instantly share code, notes, and snippets.

@nna774 nna774/acpi.rb
Last active Jun 26, 2016

Embed
What would you like to do?
#! /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
You can’t perform that action at this time.