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