Silly/AutoOpAll.pm

filter: Statementstmt 22.6% 12 / 53 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 4 / 8 Podpod 0.0% 0 / 5 totaltotal 20.0% 16 / 80 SCAR 35.1
CC
7
Cov
18%
Bot_public_cmd_aopall
30.0
Bot_user_joined
12.0
Cobalt_register
2.0
CRAP 33.6
↑ Summary Silly/LOLCAT.pm »
1 package Bot::Cobalt::Plugin::Silly::AutoOpAll;
2 1 $Bot::Cobalt::Plugin::Silly::AutoOpAll::VERSION = '0.031001';
3 1 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Object::Pluggable::Constants qw/ :ALL /;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use IRC::Utils 'lc_irc';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶sub new { bless {}, shift }
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
10  
11 sub Cobalt_register {
12 0 ▶ my ($self, $core) = splice @_, 0, 2;
Subroutine Cobalt_register: not called CC=1 SCAR=6.9
Pod undocumented
13 0 $self->{AOPChans} = {};
14  
15 0 $core->plugin_register( $self, 'SERVER',
16 'user_joined',
17 'public_cmd_aopall',
18 );
19  
20 0 $core->log->info("Loaded");
21  
22 0 return PLUGIN_EAT_NONE
23 }
24  
25 sub Cobalt_unregister {
26 0 ▶ my ($self, $core) = splice @_, 0, 2;
Subroutine Cobalt_unregister: not called CC=1 SCAR=6.9
Pod undocumented
27  
28 0 $core->log->info("Unloaded");
29  
30 0 return PLUGIN_EAT_NONE
31 }
32  
33  
34 sub Bot_public_cmd_aopall {
35 0 ▶ my ($self, $core) = splice @_, 0, 2;
Subroutine Bot_public_cmd_aopall: not called CC=5 SCAR=34.0
Pod undocumented
36 0 my $msg = ${ $_[0] };
37 0 my $context = $msg->context;
38  
39 ## !aopall #chan
40 ## !aopall -#chan
41  
42 0 my $nick = $msg->src_nick;
43
44 0 my $lev = $core->auth->level($context, $nick);
45 0 ▶ return PLUGIN_EAT_ALL unless $lev >= 3;
Branch: 1 branch
BranchTrueFalseTotal
unless $lev >= 3 0 0 0
46  
47 my $casemap = $core->Servers->{$context}->{CaseMap}
48 0 ▶ // 'rfc1459';
Condition0%0/2
$core->Servers->{$context}{"CaseMap"} // "rfc1459"
l!l
00
MC/DC0%0/1
$core->Servers->{$context}{"CaseMap"} // "rfc1459"
$core->Servers->{$context}{"CaseMap"}
Truth table0%0/2
A
A= $core->Servers->{$context}{"CaseMap"}
Aresult
11
00
49  
50 0 my $chan = $msg->message_array->[0];
51 0 $chan = lc_irc($chan, $casemap);
52  
53 0 ▶ unless ( index($chan, '-') == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($chan, '-') == 0) { } 0 0 0
54 0 $self->{AOPChans}->{$context}->{$chan} = 1;
55 0 $core->send_event( 'notice',
56 $context,
57 $nick,
58 "AutoOpping all on $chan",
59 );
60 } else {
61 0 $chan = substr($chan, 1);
62  
63 0 my $resp;
64 0 ▶ if (delete $self->{AOPChans}->{$context}->{$chan}) {
Branch: 1 branch
BranchTrueFalseTotal
if (delete $self->{'AOPChans'}{$context}{$chan}) { } 0 0 0
65 0 $resp = "Not autoopping on $chan";
66 } else {
67 0 $resp = "No such chan ($chan) found";
68 }
69  
70 0 $core->send_event( 'notice',
71 $context,
72 $nick,
73 $resp
74 );
75 }
76
77 0 return PLUGIN_EAT_ALL
78 }
79  
80 sub Bot_user_joined {
81 0 ▶ my ($self, $core) = splice @_, 0, 2;
Subroutine Bot_user_joined: not called CC=3 SCAR=24.8
Pod undocumented
82 0 my $joined = ${ $_[0] };
83  
84 0 my $context = $joined->context;
85  
86 0 my $chan = $joined->channel;
87 0 my $nick = $joined->src_nick;
88  
89 0 ▶ my $casemap = $core->get_irc_casemap($context) || 'rfc1459' ;
Condition0%0/2
$core->get_irc_casemap($context) || 'rfc1459'
l!l
00
MC/DC0%0/1
$core->get_irc_casemap($context) || 'rfc1459'
$core->get_irc_casemap($context)
Truth table0%0/2
A
A= $core->get_irc_casemap($context)
Aresult
11
00
90  
91 0 $chan = lc_irc($chan, $casemap);
92  
93 0 ▶ if (grep { $_ eq $chan } keys %{ $self->{AOPChans}->{$context} }) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq $chan;} keys %{$$self{"AOPChans"}{$context};}) 0 0 0
94 0 $core->send_event( 'mode', $context, $chan, '+o '.$nick );
95 }
96  
97 0 return PLUGIN_EAT_NONE
98 }
99  
100 1 1;
101 __END__
↑ Summary Silly/LOLCAT.pm »