| 1 | package App::MadEye::Plugin::Notify::HipChat; | ||||||||||||
| 2 | 1 | ▶ | use 5.008005; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 1 | ▶ | use utf8; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 1 | ▶ | use base qw/App::MadEye::Plugin::Base/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | 1 | our $VERSION = "0.02"; | |||||||||||
| 9 | |||||||||||||
| 10 | 1 | ▶ | use Furl; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | |||||||||||||
| 12 | 0 | ▶ | sub notify : Hook { | ||||||||||
|
Subroutine
notify: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||
| 13 | 0 | my ( $self, $context, $args ) = @_; | |||||||||||
| 14 | |||||||||||||
| 15 | 0 | my $conf = $self->{config}->{config}; | |||||||||||
| 16 | 0 | ▶ | my $url = $conf->{url} // "https://api.hipchat.com/v1/rooms/message"; | ||||||||||
|
Condition0%0/2
$conf->{"url"} // "https://api.hipchat.com/v1/rooms/message"
MC/DC0%0/1
$conf->{"url"} // "https://api.hipchat.com/v1/rooms/message"
$conf->{"url"}
Truth table0%0/2
A
A= $conf->{"url"}
| |||||||||||||
| 17 | 0 | $url =~ s!/$!!g; | |||||||||||
| 18 | |||||||||||||
| 19 | 0 | ▶ | my $auth_token = $conf->{auth_token} or die "missing auth_token"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 20 | 0 | ▶ | my $room_id = $conf->{room_id} or die "missing room_id"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 21 | 0 | ▶ | my $from = $conf->{from} // "ikachan"; | ||||||||||
|
Condition0%0/2
$conf->{"from"} // "ikachan"
MC/DC0%0/1
$conf->{"from"} // "ikachan"
$conf->{"from"}
Truth table0%0/2
A
A= $conf->{"from"}
| |||||||||||||
| 22 | 0 | ▶ | my $notify = $conf->{notify} // 0; | ||||||||||
|
Condition0%0/2
$conf->{"notify"} // 0
MC/DC0%0/1
$conf->{"notify"} // 0
$conf->{"notify"}
Truth table0%0/2
A
A= $conf->{"notify"}
| |||||||||||||
| 23 | 0 | ▶ | my $msg = $conf->{message} // ""; | ||||||||||
|
Condition0%0/2
$conf->{"message"} // ""
MC/DC0%0/1
$conf->{"message"} // ""
$conf->{"message"}
Truth table0%0/2
A
A= $conf->{"message"}
| |||||||||||||
| 24 | 0 | ▶ | my $message_format = $conf->{message_format} // "html"; | ||||||||||
|
Condition0%0/2
$conf->{"message_format"} // "html"
MC/DC0%0/1
$conf->{"message_format"} // "html"
$conf->{"message_format"}
Truth table0%0/2
A
A= $conf->{"message_format"}
| |||||||||||||
| 25 | 0 | ▶ | my $color = $conf->{color} // "yellow"; | ||||||||||
|
Condition0%0/2
$conf->{"color"} // "yellow"
MC/DC0%0/1
$conf->{"color"} // "yellow"
$conf->{"color"}
Truth table0%0/2
A
A= $conf->{"color"}
| |||||||||||||
| 26 | 0 | ▶ | my $format = $conf->{format} // "json"; | ||||||||||
|
Condition0%0/2
$conf->{"format"} // "json"
MC/DC0%0/1
$conf->{"format"} // "json"
$conf->{"format"}
Truth table0%0/2
A
A= $conf->{"format"}
| |||||||||||||
| 27 | |||||||||||||
| 28 | 0 | ▶ | while ( my ( $plugin, $results ) = each %$args ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 29 | 0 | $plugin =~ s/.+::Agent:://; | |||||||||||
| 30 | 0 | for my $result (@$results) { | |||||||||||
| 31 | 0 | $msg .= "$plugin: ($result->{target}): $result->{message} "; | |||||||||||
| 32 | |||||||||||||
| 33 | 0 | my $ua = Furl->new( | |||||||||||
| 34 | timeout => 5, | ||||||||||||
| 35 | agent => "MadEye/$App::MadEye::VERSION" | ||||||||||||
| 36 | ); | ||||||||||||
| 37 | 0 | my $res = $ua->post( | |||||||||||
| 38 | $url, | ||||||||||||
| 39 | [], | ||||||||||||
| 40 | [ | ||||||||||||
| 41 | auth_token => $auth_token, | ||||||||||||
| 42 | room_id => $room_id, | ||||||||||||
| 43 | from => $from, | ||||||||||||
| 44 | message => $msg, | ||||||||||||
| 45 | message_format => $message_format, | ||||||||||||
| 46 | notify => $notify, | ||||||||||||
| 47 | color => $color, | ||||||||||||
| 48 | format => $format, | ||||||||||||
| 49 | ] | ||||||||||||
| 50 | ); | ||||||||||||
| 51 | 0 | ▶ | $res->is_success or die $res->status_line; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 52 | 0 | $context->log( info => "posted to $room_id." ); | |||||||||||
| 53 | } | ||||||||||||
| 54 | } | ||||||||||||
| 55 | 1 | ▶ | } | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 56 | |||||||||||||
| 57 | 1 | 1; | |||||||||||
| 58 | __END__ | ||||||||||||