File Coverage

blib/lib/Bot/IRC/X/UriTitle.pm
Criterion Covered Total %
statement 19 26 73.0
branch n/a
condition n/a
subroutine 7 8 87.5
pod 0 1 0.0
total 26 35 74.2


line stmt bran cond sub pod time code
1             package Bot::IRC::X::UriTitle;
2             # ABSTRACT: Bot::IRC plugin to parse and print URI titles
3              
4 1     1   355583 use 5.014;
  1         11  
5 1     1   5 use exact;
  1         2  
  1         5  
6              
7 1     1   1268 use LWP::UserAgent;
  1         34088  
  1         37  
8 1     1   500 use LWP::Protocol::https;
  1         10974  
  1         35  
9 1     1   484 use Text::Unidecode 'unidecode';
  1         1236  
  1         66  
10 1     1   425 use URI::Title 'title';
  1         17833  
  1         292  
11              
12             our $VERSION = '1.04'; # VERSION
13              
14             sub init {
15 1     1 0 6167 my ($bot) = @_;
16              
17             $bot->hook(
18             {
19             command => 'PRIVMSG',
20             text => qr|https?://\S+|,
21             },
22             sub {
23 0     0     my ( $bot, $in, $m ) = @_;
24              
25 0           my %urls;
26 0           $urls{$1} = 1 while ( $in->{text} =~ m|(https?://\S+)|g );
27 0           $bot->reply("[ $_ ]") for ( grep { defined } map { unidecode( title($_) ) } keys %urls );
  0            
  0            
28 0           return;
29             },
30 1         30 );
31             }
32              
33             1;
34              
35             __END__
36              
37             =pod
38              
39             =encoding UTF-8
40              
41             =head1 NAME
42              
43             Bot::IRC::X::UriTitle - Bot::IRC plugin to parse and print URI titles
44              
45             =head1 VERSION
46              
47             version 1.04
48              
49             =for markdown [![test](https://github.com/gryphonshafer/Bot-IRC-X-UriTitle/workflows/test/badge.svg)](https://github.com/gryphonshafer/Bot-IRC-X-UriTitle/actions?query=workflow%3Atest)
50             [![codecov](https://codecov.io/gh/gryphonshafer/Bot-IRC-X-UriTitle/graph/badge.svg)](https://codecov.io/gh/gryphonshafer/Bot-IRC-X-UriTitle)
51              
52             =head1 SYNOPSIS
53              
54             use Bot::IRC;
55              
56             Bot::IRC->new(
57             connect => { server => 'irc.perl.org' },
58             plugins => ['UriTitle'],
59             )->run;
60              
61             =head1 DESCRIPTION
62              
63             This L<Bot::IRC> plugin makes the bot parse and print URI titles.
64              
65             =head1 SEE ALSO
66              
67             You can look for additional information at:
68              
69             =over 4
70              
71             =item *
72              
73             L<Bot::IRC>
74              
75             =item *
76              
77             L<GitHub|https://github.com/gryphonshafer/Bot-IRC-X-UriTitle>
78              
79             =item *
80              
81             L<MetaCPAN|https://metacpan.org/pod/Bot::IRC::X::UriTitle>
82              
83             =item *
84              
85             L<GitHub Actions|https://github.com/gryphonshafer/Bot-IRC-X-UriTitle/actions>
86              
87             =item *
88              
89             L<Codecov|https://codecov.io/gh/gryphonshafer/Bot-IRC-X-UriTitle>
90              
91             =item *
92              
93             L<CPANTS|http://cpants.cpanauthors.org/dist/Bot-IRC-X-UriTitle>
94              
95             =item *
96              
97             L<CPAN Testers|http://www.cpantesters.org/distro/T/Bot-IRC-X-UriTitle.html>
98              
99             =back
100              
101             =for Pod::Coverage init
102              
103             =head1 AUTHOR
104              
105             Gryphon Shafer <gryphon@cpan.org>
106              
107             =head1 COPYRIGHT AND LICENSE
108              
109             This software is Copyright (c) 2016-2021 by Gryphon Shafer.
110              
111             This is free software, licensed under:
112              
113             The Artistic License 2.0 (GPL Compatible)
114              
115             =cut