line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hubot::Scripts::print; |
2
|
|
|
|
|
|
|
$Hubot::Scripts::print::VERSION = '0.1.9'; |
3
|
1
|
|
|
1
|
|
1451
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
30
|
|
5
|
1
|
|
|
1
|
|
6
|
use JSON::XS; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
349
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub load { |
8
|
0
|
|
|
0
|
0
|
|
my ( $class, $robot ) = @_; |
9
|
|
|
|
|
|
|
$robot->hear( |
10
|
|
|
|
|
|
|
qr/^(?:print|say):? (.+)/i, |
11
|
|
|
|
|
|
|
sub { |
12
|
0
|
|
|
0
|
|
|
my $msg = shift; |
13
|
0
|
|
|
|
|
|
my $code = $msg->match->[0]; |
14
|
|
|
|
|
|
|
$msg->http('http://api.dan.co.jp/lleval.cgi') |
15
|
|
|
|
|
|
|
->query( { s => "#!/usr/bin/perl\nprint $code\n" } )->get( |
16
|
|
|
|
|
|
|
sub { |
17
|
0
|
|
|
|
|
|
my ( $body, $hdr ) = @_; |
18
|
0
|
0
|
0
|
|
|
|
return if ( !$body || $hdr->{Status} !~ m/^2/ ); |
19
|
0
|
|
|
|
|
|
my $data = decode_json($body); |
20
|
0
|
|
0
|
|
|
|
$msg->send( split /\n/, |
21
|
|
|
|
|
|
|
$data->{stdout} || $data->{stderr} ); |
22
|
|
|
|
|
|
|
} |
23
|
0
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
} |
25
|
0
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
1; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 NAME |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Hubot::Scripts::print |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 VERSION |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
version 0.1.9 |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 SYNOPSIS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
print <code> - evaluate <code> and show the result |
41
|
|
|
|
|
|
|
say <code> - evaluate <code> and show the result |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 AUTHOR |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Hyungsuk Hong <hshong@perl.kr> |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |