| 1 | package Bot::IRC::Greeting; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Bot::IRC greet joining users to channels | ||||||||||||||||||||||||||||||||||||||||||
| 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 | ▶ | use DateTime; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use DateTime::Format::Human::Duration; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | our $VERSION = '1.49'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=7 SCAR=23.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | my ($bot) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | my $vars = $bot->vars; | |||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | my $greeting = ( not ref $vars ) ? $vars : $vars->{greeting} // 'greetings'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$vars->{"greeting"} // "greetings"
MC/DC0%0/1
$vars->{"greeting"} // "greetings"
$vars->{"greeting"}
Truth table50%1/2
A
A= $vars->{"greeting"}
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | my $channels = ( ref $vars ) ? $vars->{channels} : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | $bot->hook( | ||||||||||||||||||||||||||||||||||||||||||
| 19 | { | ||||||||||||||||||||||||||||||||||||||||||
| 20 | command => 'JOIN', | ||||||||||||||||||||||||||||||||||||||||||
| 21 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.7
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | my ( $bot, $in ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | unless ( ref $channels and not grep { $_ eq $in->{forum} } @$channels ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $channels and not grep({$_ eq $in->{"forum"};} @$channels)
MC/DC0%0/2
ref $channels and not grep({$_ eq $in->{"forum"};} @$channels)
ref $channels
not grep({$_ eq $in->{"forum"};} @$channels)
Truth table33%1/3
A and not(B)
A= ref $channelsB= not grep({$_ eq $in->{"forum"};} @$channels)
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | $bot->reply_to( greeting_based_on_nick( $greeting, $in->{nick} ) ); | |||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | ) unless ( defined $channels and not ref $channels and $channels == 0 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $channels and not ref $channels and $channels == 0
defined $channels and not ref $channels
MC/DC0%0/3
defined $channels and not ref $channels and $channels == 0
defined $channels
not ref $channels
$channels == 0
Truth table25%1/4
A and not(B) and C
A= defined $channelsB= not ref $channelsC= $channels == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | ▶ | sub greeting_based_on_nick { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
greeting_based_on_nick: called CC=7 SCAR=20.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | my ( $greeting, $nick ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | ▶ | if ( $nick !~ /[a-z]/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | $greeting = uc($greeting); | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | ▶ | for ( my $i = 0; $i < length($greeting) and $i < length( $nick ); $i++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$i < length $greeting and $i < length $nick
MC/DC50%1/2
$i < length $greeting and $i < length $nick
$i < length $greeting
$i < length $nick
Truth table66%2/3
A and B
A= $i < length $greetingB= $i < length $nick
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 7 | my $letter = substr( $nick, $i, 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 42 | 7 | ▶ | substr( $greeting, $i, 1, uc( substr( $greeting, $i, 1 ) ) ) if ( $letter =~ /[A-Z]/ ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | ▶ | $greeting =~ tr/oi/01/ if ( $nick =~ /[0-9]/ ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | ▶ | $greeting .= $1 if ( $nick =~ /(_+)$/ ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | return $greeting; | |||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | __END__ | ||||||||||||||||||||||||||||||||||||||||||