line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Slack::IncomingWebHook::Script; |
2
|
1
|
|
|
1
|
|
865
|
use 5.008001; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
3
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
25
|
|
5
|
1
|
|
|
1
|
|
3
|
use utf8; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
520
|
use Encode qw( decode_utf8 ); |
|
1
|
|
|
|
|
7781
|
|
|
1
|
|
|
|
|
77
|
|
8
|
1
|
|
|
1
|
|
645
|
use Getopt::Long qw( :config posix_default no_ignore_case bundling auto_help ); |
|
1
|
|
|
|
|
8359
|
|
|
1
|
|
|
|
|
6
|
|
9
|
1
|
|
|
1
|
|
201
|
use WebService::Slack::IncomingWebHook; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
144
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCTIPTION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
post to slack incoming web hook. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
% post-slack --webhook_url='https://xxxxxx' --text='yahooo' |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
--webhook_url required |
20
|
|
|
|
|
|
|
--text required |
21
|
|
|
|
|
|
|
--channel |
22
|
|
|
|
|
|
|
--username |
23
|
|
|
|
|
|
|
--icon_url |
24
|
|
|
|
|
|
|
--icon_emoji |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub run { |
30
|
0
|
|
|
0
|
0
|
|
my ($class, @argv) = @_; |
31
|
0
|
|
|
|
|
|
local @ARGV = @argv; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
GetOptions( |
34
|
|
|
|
|
|
|
\my %opt => qw( |
35
|
|
|
|
|
|
|
text=s |
36
|
|
|
|
|
|
|
webhook_url=s |
37
|
|
|
|
|
|
|
channel=s |
38
|
|
|
|
|
|
|
username=s |
39
|
|
|
|
|
|
|
icon_url=s |
40
|
|
|
|
|
|
|
icon_emoji=s |
41
|
|
|
|
|
|
|
), |
42
|
|
|
|
|
|
|
); |
43
|
0
|
|
|
|
|
|
my @required_options = qw( webhook_url text ); |
44
|
0
|
|
|
|
|
|
for my $o (@required_options) { |
45
|
0
|
0
|
|
|
|
|
Carp::croak("--$o option required") if ! exists $opt{$o}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $webhook_url = delete $opt{webhook_url}; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# for multibyte character |
51
|
0
|
|
|
|
|
|
$opt{$_} = decode_utf8($opt{$_}) for keys %opt; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
WebService::Slack::IncomingWebHook->new(webhook_url => $webhook_url)->post(%opt); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |