File Coverage

blib/lib/Bot/IRC/Ping.pm
Criterion Covered Total %
statement 8 13 61.5
branch 0 4 0.0
condition n/a
subroutine 3 4 75.0
pod 0 1 0.0
total 11 22 50.0


line stmt bran cond sub pod time code
1             # ABSTRACT: Bot::IRC ping the bot and check its health
2              
3             use 5.014;
4 1     1   1870 use exact;
  1         3  
5 1     1   15  
  1         1  
  1         5  
6             our $VERSION = '1.39'; # VERSION
7              
8             my ($bot) = @_;
9              
10 1     1 0 5003 $bot->hook(
11             {
12             to_me => 1,
13             text => qr/^(?<ping>ping)\b/i,
14             },
15             sub {
16             my ( $bot, $in, $m ) = @_;
17             ( my $pong = $m->{ping} ) =~ s/(i)/ ( $1 eq 'i' ) ? 'o' : 'O' /ie;
18 0     0   0 my $health = $bot->health;
19 0 0       0  
  0         0  
20 0         0 $bot->reply_to(
21             "$pong. Connected to $health->{server} on port $health->{port} (" .
22             ( ( $health->{ssl} ) ? 'over SSL/TLS' : 'direct connection' ) . '). ' .
23             "Spawned $health->{spawn} child processes. " .
24 0 0       0 "There are $health->{hooks} hooks and $health->{ticks} ticks " .
25             "installed via $health->{plugins} loaded plugins."
26             );
27             },
28             );
29              
30 1         14 $bot->helps( ping => 'Ping the bot and check its health. Usage: <bot> ping.' );
31             }
32 1         16  
33             1;
34              
35              
36             =pod
37              
38             =encoding UTF-8
39              
40             =head1 NAME
41              
42             Bot::IRC::Ping - Bot::IRC ping the bot and check its health
43              
44             =head1 VERSION
45              
46             version 1.39
47              
48             =head1 SYNOPSIS
49              
50             use Bot::IRC;
51              
52             Bot::IRC->new(
53             connect => { server => 'irc.perl.org' },
54             plugins => ['Ping'],
55             )->run;
56              
57             =head1 DESCRIPTION
58              
59             This L<Bot::IRC> plugin causes the bot to respond to pings from users
60             and reports on the bot's health.
61              
62             =head2 SEE ALSO
63              
64             L<Bot::IRC>
65              
66             =for Pod::Coverage init
67              
68             =head1 AUTHOR
69              
70             Gryphon Shafer <gryphon@cpan.org>
71              
72             =head1 COPYRIGHT AND LICENSE
73              
74             This software is Copyright (c) 2016-2050 by Gryphon Shafer.
75              
76             This is free software, licensed under:
77              
78             The Artistic License 2.0 (GPL Compatible)
79              
80             =cut