| 1 | package Bot::IRC::Ping; | ||||||||||
| 2 | # ABSTRACT: Bot::IRC ping the bot and check its health | ||||||||||
| 3 | |||||||||||
| 4 | 2 | ▶ | use 5.016; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use exact; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 2 | our $VERSION = '1.49'; # VERSION | |||||||||
| 8 | |||||||||||
| 9 | 1 | ▶ | sub init { | ||||||||
|
Subroutine
init: called CC=1 SCAR=3.5
Pod
undocumented
| |||||||||||
| 10 | 1 | my ($bot) = @_; | |||||||||
| 11 | |||||||||||
| 12 | $bot->hook( | ||||||||||
| 13 | { | ||||||||||
| 14 | to_me => 1, | ||||||||||
| 15 | text => qr/^(?<ping>ping)\b/i, | ||||||||||
| 16 | }, | ||||||||||
| 17 | 0 | ▶ | sub { | ||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||
| 18 | 0 | my ( $bot, $in, $m ) = @_; | |||||||||
| 19 | 0 | ▶ | ( my $pong = $m->{ping} ) =~ s/(i)/ ( $1 eq 'i' ) ? 'o' : 'O' /ie; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 0 | my $health = $bot->health; | |||||||||
| 21 | |||||||||||
| 22 | $bot->reply_to( | ||||||||||
| 23 | "$pong. Connected to $health->{server} on port $health->{port} (" . | ||||||||||
| 24 | 0 | ▶ | ( ( $health->{ssl} ) ? 'over SSL/TLS' : 'direct connection' ) . '). ' . | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | ); | |||||||||
| 31 | |||||||||||
| 32 | 1 | $bot->helps( ping => 'Ping the bot and check its health. Usage: <bot> ping.' ); | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 2 | 1; | |||||||||
| 36 | |||||||||||
| 37 | __END__ | ||||||||||