| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package LiBot::Handler::IkachanForwarder; |
|
2
|
1
|
|
|
1
|
|
1415
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
35
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
23
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use utf8; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
5
|
1
|
|
|
1
|
|
22
|
use Furl; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
31
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Text::Shorten qw(shorten_scalar); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
53
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use URI::Escape qw(uri_escape_utf8); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
57
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
5
|
use Mouse; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
6
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has ua => ( |
|
12
|
|
|
|
|
|
|
is => 'ro', |
|
13
|
|
|
|
|
|
|
lazy => 1, |
|
14
|
|
|
|
|
|
|
default => sub { |
|
15
|
|
|
|
|
|
|
Furl->new(agent => "LiBot/$LiBot::VERSION", timeout => 3); |
|
16
|
|
|
|
|
|
|
}, |
|
17
|
|
|
|
|
|
|
); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has url => ( |
|
20
|
|
|
|
|
|
|
is => 'ro', |
|
21
|
|
|
|
|
|
|
isa => 'Str', |
|
22
|
|
|
|
|
|
|
required => 1, |
|
23
|
|
|
|
|
|
|
); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has channel => ( |
|
26
|
|
|
|
|
|
|
is => 'ro', |
|
27
|
|
|
|
|
|
|
isa => 'Str', |
|
28
|
|
|
|
|
|
|
required => 1, |
|
29
|
|
|
|
|
|
|
); |
|
30
|
|
|
|
|
|
|
|
|
31
|
1
|
|
|
1
|
|
432
|
no Mouse; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
5
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub init { |
|
34
|
0
|
|
|
0
|
0
|
|
my ($self, $bot) = @_; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$bot->register( |
|
37
|
|
|
|
|
|
|
qr/@[a-zA-Z_-]+/ => sub { |
|
38
|
0
|
|
|
0
|
|
|
my ( $cb, $event, $arg ) = @_; |
|
39
|
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
print "Send mention\n"; |
|
41
|
0
|
|
|
|
|
|
my $nickname = $event->nickname; |
|
42
|
0
|
|
|
|
|
|
substr($nickname, 1, 1) = '*'; # do not highlight me. |
|
43
|
0
|
|
|
|
|
|
my $msg = sprintf("(%s) %s", $nickname, $event->text); |
|
44
|
0
|
|
|
|
|
|
my $url = $self->url; |
|
45
|
0
|
|
|
|
|
|
$url =~ s!/$!!; |
|
46
|
0
|
|
|
|
|
|
$url .= sprintf("/privmsg?channel=%s&message=%s", uri_escape_utf8($self->channel), uri_escape_utf8($msg)); |
|
47
|
0
|
|
|
|
|
|
my $res = $self->ua->post($url); |
|
48
|
0
|
|
|
|
|
|
print "IkachanForwarder: " . $res->status_line, "\n"; |
|
49
|
0
|
|
|
|
|
|
$cb->(''); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
0
|
|
|
|
|
|
); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |