line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bot::BasicBot::Pluggable::Module::Title; |
2
|
|
|
|
|
|
|
$Bot::BasicBot::Pluggable::Module::Title::VERSION = '1.20'; |
3
|
1
|
|
|
1
|
|
3
|
use base qw(Bot::BasicBot::Pluggable::Module); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
60
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
28
|
|
|
1
|
|
|
|
|
22
|
|
5
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
423
|
use Text::Unidecode; |
|
1
|
|
|
|
|
1543
|
|
|
1
|
|
|
|
|
55
|
|
8
|
1
|
|
|
1
|
|
377
|
use URI::Title qw(title); |
|
1
|
|
|
|
|
36791
|
|
|
1
|
|
|
|
|
59
|
|
9
|
1
|
|
|
1
|
|
440
|
use URI::Find::Simple qw(list_uris); |
|
1
|
|
|
|
|
2512
|
|
|
1
|
|
|
|
|
46
|
|
10
|
1
|
|
|
1
|
|
5
|
use URI; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
209
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub help { |
13
|
0
|
|
|
0
|
1
|
0
|
return "Speaks the title of URLs mentioned."; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub init { |
17
|
1
|
|
|
1
|
1
|
1
|
my $self = shift; |
18
|
1
|
|
|
|
|
7
|
$self->config( |
19
|
|
|
|
|
|
|
{ |
20
|
|
|
|
|
|
|
user_asciify => 1, |
21
|
|
|
|
|
|
|
user_ignore_re => '', |
22
|
|
|
|
|
|
|
user_be_rude => 0, |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub admin { |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# do this in admin so we always get a chance to see titles |
30
|
3
|
|
|
3
|
1
|
4
|
my ( $self, $mess ) = @_; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# If the message was from the bot (for e.g. another module announcing the |
33
|
|
|
|
|
|
|
# title of an URL we just said, etc), go no further, to avoid loops |
34
|
3
|
50
|
|
|
|
10
|
return if $mess->{who} eq $self->bot->nick; |
35
|
|
|
|
|
|
|
|
36
|
3
|
|
|
|
|
30
|
my $ignore_regexp = $self->get('user_ignore_re'); |
37
|
|
|
|
|
|
|
|
38
|
3
|
|
|
|
|
4
|
my $reply = ""; |
39
|
3
|
|
|
|
|
12
|
for ( list_uris( $mess->{body} ) ) { |
40
|
3
|
100
|
66
|
|
|
21474
|
next if $ignore_regexp && /$ignore_regexp/; |
41
|
2
|
|
|
|
|
7
|
my $uri = URI->new($_); |
42
|
2
|
50
|
|
|
|
78
|
next unless $uri; |
43
|
2
|
50
|
|
|
|
18
|
if ( $uri->scheme eq "file" ) { |
44
|
0
|
0
|
|
|
|
0
|
next unless $self->get("user_be_rude"); |
45
|
0
|
|
|
|
|
0
|
my $who = $mess->{who}; |
46
|
0
|
|
|
|
|
0
|
$self->reply( $mess, "Nice try $who, you tosser" ); |
47
|
0
|
|
|
|
|
0
|
return; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
2
|
|
|
|
|
108
|
my $title = title("$_"); |
51
|
2
|
50
|
|
|
|
316169
|
next unless defined $title; |
52
|
2
|
50
|
|
|
|
15
|
$title = unidecode($title) if $self->get("user_asciify"); |
53
|
2
|
|
|
|
|
54
|
$reply .= "[ $title ] "; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
3
|
100
|
|
|
|
11
|
if ($reply) { $self->reply( $mess, $reply ) } |
|
2
|
|
|
|
|
18
|
|
57
|
|
|
|
|
|
|
|
58
|
3
|
|
|
|
|
14
|
return; # Title.pm is passive, and doesn't intercept things. |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 NAME |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Bot::BasicBot::Pluggable::Module::Title - speaks the title of URLs mentioned |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 VERSION |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
version 1.20 |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 IRC USAGE |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
None. If the module is loaded, the bot will speak the titles of all URLs mentioned. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 VARS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=over 4 |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item asciify |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Defaults to 1; whether or not we should convert all titles to ascii from Unicode |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item ignore_re |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
If set to a nonempty string, ignore URLs matching this re |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=back |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 REQUIREMENTS |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
L<URI::Title> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
L<URI::Find::Simple> |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 AUTHOR |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Mario Domgoergen <mdom@cpan.org> |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This program is free software; you can redistribute it |
102
|
|
|
|
|
|
|
and/or modify it under the same terms as Perl itself. |