Last active
August 29, 2015 14:17
-
-
Save alexshd/682bd7e9a3d764659422 to your computer and use it in GitHub Desktop.
slack ruby notifier
This file contains hidden or 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
#! /opt/chef/embedded/bin/ruby | |
require 'slack-notifier' | |
require 'trollop' | |
host = ENV['HOSTNAME'] | |
opts = Trollop.options do | |
opt :message, 'message to send', type: :string, default: 'OK' | |
opt :channel, 'slack channel to use', type: :string, default: '#shd-test' | |
opt :user, 'user name to use in the message', type: :string, default: host | |
opt :web_huk, 'the URL of the Web Huk', type: :string | |
opt :icon, 'icon to use, as specified in slack', type: :string, default: ':+1:' | |
end | |
notifier = Slack::Notifier.new opts.web_huk | |
notifier.channel = opts.channel | |
notifier.username = opts.user | |
notifier.ping opts.message, icon_emoji: opts.icon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment