Skip to content

Instantly share code, notes, and snippets.

@eiel
Created November 8, 2014 14:58
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 eiel/8161dd7573d879eb4309 to your computer and use it in GitHub Desktop.
Save eiel/8161dd7573d879eb4309 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'uri'
require 'net/http'
message = ARGV.join(" ")
host = `hostname -s`
if message.empty?
message = 'なにか終わったかも'
end
text = URI.escape(message)
token = ENV['SLACK_TOKEN']
channel = "#random"
params = {
:text => message,
:token => token,
:channel => channel,
:username => host,
}
uri = URI::HTTPS.build(:host => "slack.com", :path => "/api/chat.postMessage")
uri.query = URI.encode_www_form(params)
Net::HTTP.get(uri)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment