slackpipe 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/slackpipe +68 -0
- metadata +47 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 6a95f976f4f19fa4b8c62a60fdff0f0b4fa47602
|
|
4
|
+
data.tar.gz: c697abcde8b728390ca8a9dec43ce80e55ed579a
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: be6d0bbcbf53dede22021aa65ab4e2fd7d9c29c1fd17294d6b390a913441e663b1bbe697d6828a16bd6ebe2097081d83796b350c3044db7892ec4c443124af16
|
|
7
|
+
data.tar.gz: c2850d9ea88f9b0518094bb985da0ce9537fb8bd5b6aea92be86faf1556ae5a8ec3f20fa2c5e7236a8019d5e8d2a5934e624c8c4bf5279f5df895b3e32770e71
|
data/bin/slackpipe
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require "net/http"
|
|
3
|
+
require 'json'
|
|
4
|
+
require 'optparse'
|
|
5
|
+
|
|
6
|
+
options = {:url => ENV["SLACKPIPE_URL"],
|
|
7
|
+
:channel => ENV["SLACKPIPE_CHANNEL"],
|
|
8
|
+
:username => ENV["SLACKPIPE_USERNAME"],
|
|
9
|
+
:icon_emoji => ENV["SLACKPIPE_ICON"]}
|
|
10
|
+
|
|
11
|
+
## parse command line args
|
|
12
|
+
parser = OptionParser.new do|opts|
|
|
13
|
+
opts.banner = "Usage: #{$0} [options]"
|
|
14
|
+
|
|
15
|
+
opts.on('-h', '--help', 'Displays this help message') do
|
|
16
|
+
puts opts
|
|
17
|
+
exit
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
opts.on('-u', '--url slack_webhook_url', 'Slack Incoming WebHooks URL') do |url|
|
|
21
|
+
options[:url] = url;
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
opts.on('-c', '--channel channel', 'Channel (#lobby, @mpv)') do |channel|
|
|
25
|
+
options[:channel] = channel;
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
opts.on('-f', '--from username', 'Username (bob)') do |username|
|
|
29
|
+
options[:username] = username;
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
opts.on('-i', '--icon icon_emoji', 'Icon Emoji (:ghost:)') do |icon_emoji|
|
|
33
|
+
options[:icon_emoji] = icon_emoji;
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
opts.on('-m', '--message message', 'Message') do |message|
|
|
37
|
+
options[:message] = message;
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
begin
|
|
42
|
+
parser.parse!
|
|
43
|
+
mandatory = [:url]
|
|
44
|
+
missing = mandatory.select{ |param| options[param].nil? }
|
|
45
|
+
unless missing.empty?
|
|
46
|
+
raise OptionParser::MissingArgument.new(missing.join(', '))
|
|
47
|
+
end
|
|
48
|
+
rescue OptionParser::InvalidOption, OptionParser::MissingArgument
|
|
49
|
+
puts $!.to_s
|
|
50
|
+
puts parser
|
|
51
|
+
exit
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
## if no message is provided on the command line read it from stdin
|
|
55
|
+
if options[:message] == nil
|
|
56
|
+
options[:message] = $stdin.read
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
## post to slack
|
|
60
|
+
payload_args = {:text => options[:message], :channel => options[:channel], :username => options[:username], :icon_emoji => options[:icon_emoji]}
|
|
61
|
+
payload = {:payload => payload_args.to_json}
|
|
62
|
+
|
|
63
|
+
begin
|
|
64
|
+
response = Net::HTTP.post_form(URI.parse(options[:url]), payload)
|
|
65
|
+
response.value # raise error if the response is not 2xx
|
|
66
|
+
rescue StandardError => e
|
|
67
|
+
raise e
|
|
68
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: slackpipe
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Mike Vosseller
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-05-04 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Slackpipe allows you to easily post messages to Slack from the command
|
|
14
|
+
line. You might for example use this to post results of a nightly script to a Slack
|
|
15
|
+
channel.
|
|
16
|
+
email: michael.vosseller@gmail.com
|
|
17
|
+
executables:
|
|
18
|
+
- slackpipe
|
|
19
|
+
extensions: []
|
|
20
|
+
extra_rdoc_files: []
|
|
21
|
+
files:
|
|
22
|
+
- bin/slackpipe
|
|
23
|
+
homepage: https://github.com/mpvosseller/slackpipe
|
|
24
|
+
licenses:
|
|
25
|
+
- MIT
|
|
26
|
+
metadata: {}
|
|
27
|
+
post_install_message:
|
|
28
|
+
rdoc_options: []
|
|
29
|
+
require_paths:
|
|
30
|
+
- lib
|
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
32
|
+
requirements:
|
|
33
|
+
- - ">="
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '0'
|
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
requirements: []
|
|
42
|
+
rubyforge_project:
|
|
43
|
+
rubygems_version: 2.6.13
|
|
44
|
+
signing_key:
|
|
45
|
+
specification_version: 4
|
|
46
|
+
summary: Post messages to Slack from the command line
|
|
47
|
+
test_files: []
|