blib/lib/Bot/Cobalt/IRC/Role/UserEvents.pm

filter: Statementstmt 10.8% 17 / 157 Branchbran 0.0% 0 / 54 Conditioncond 0.0% 0 / 33 MC/DCmcdc 0.0% 0 / 21 Subroutinesub 29.4% 5 / 17 Podpod 0.0% 0 / 12 totaltotal 7.4% 22 / 294 CC 39 SCAR 34.8
CC
39
Cov
7%
Bot_message
72.0
Bot_topic
42.0
Bot_kick
42.0
CRAP 32.4
« blib/lib/Bot/Cobalt/Core/ContextMeta/Auth.pm ↑ Summary blib/lib/Bot/Cobalt/IRC/Role/AdminCmds.pm »
1 package Bot::Cobalt::IRC::Role::UserEvents;
2 1 $Bot::Cobalt::IRC::Role::UserEvents::VERSION = '0.021003';
3 ## POD lives in Bot::Cobalt::IRC for now ...
4  
5 1 ▶use 5.12.1;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Bot::Cobalt;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Bot::Cobalt::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 requires qw/
15 ircobjs
16 /;
17  
18 0 ▶sub Bot_send_message { Bot_message(@_) }
Subroutine Bot_send_message: not called CC=1 SCAR=6.9
Pod undocumented
19 0 ▶sub Bot_message {
Subroutine Bot_message: not called CC=8 SCAR=42.8
Pod undocumented
20 0 my ($self, $core) = splice @_, 0, 2;
21
22 0 ▶ unless (defined $_[2]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $_[2]) 0 0 0
23 0 logger->error("Bot_message received without enough arguments");
24 0 return PLUGIN_EAT_NONE
25 }
26  
27 0 my $context = ${$_[0]};
28 0 my $target = ${$_[1]};
29 0 my $txt = ${$_[2]};
30  
31 return PLUGIN_EAT_NONE
32 0 ▶ unless defined $self->ircobjs->{$context}
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->ircobjs->{$context} and $core->is_connected($context) 0 0 0
Condition0%0/3
defined $self->ircobjs->{$context} and $core->is_connected($context)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->ircobjs->{$context} and $core->is_connected($context)
defined $self->ircobjs->{$context} $core->is_connected($context)
Truth table0%0/3
A and B
A= defined $self->ircobjs->{$context}B= $core->is_connected($context)
ABresult
0X0
100
111
33 and $core->is_connected($context);
34  
35 ## USER event Outgoing_message for output filters
36 0 my @msg = ( $context, $target, $txt );
37 0 my $eat = $core->send_user_event( 'message', \@msg );
38  
39 0 ▶ unless ($eat == PLUGIN_EAT_ALL) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($eat == 4) 0 0 0
40 0 my ($target, $txt) = @msg[1,2];
41
42 0 ▶ if (defined $target && defined $txt && $txt ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $target and defined $txt and $txt ne '') { } 0 0 0
Condition0%0/6
defined $target and defined $txt and $txt ne ""
!ll&&!rl&&r
000
defined $target and defined $txt
!ll&&!rl&&r
000
MC/DC0%0/3
defined $target and defined $txt and $txt ne ""
defined $target defined $txt $txt ne ""
Truth table0%0/4
A and B and C
A= defined $targetB= defined $txtC= $txt ne ""
ABCresult
0XX0
10X0
1100
1111
43 0 $self->ircobjs->{$context}->yield( 'privmsg',
44 $target,
45 $txt
46 );
47  
48 0 broadcast( 'message_sent',
49 $context, $target, $txt
50 );
51  
52 0 ++$core->State->{Counters}->{Sent};
53 } else {
54 0 logger->error(
55 "Bot_message without defined target and txt after Outgoing_message"
56 )
57 }
58 }
59  
60 0 return PLUGIN_EAT_NONE
61 }
62  
63  
64 0 ▶sub Bot_send_notice { Bot_notice(@_) }
Subroutine Bot_send_notice: not called CC=1 SCAR=6.9
Pod undocumented
65 0 ▶sub Bot_notice {
Subroutine Bot_notice: not called CC=5 SCAR=34.0
Pod undocumented
66 0 my ($self, $core) = splice @_, 0, 2;
67  
68 0 ▶ unless (defined $_[2]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $_[2]) 0 0 0
69 0 logger->error("Bot_notice received without enough arguments");
70 0 return PLUGIN_EAT_NONE
71 }
72  
73 0 my $context = ${$_[0]};
74 0 my $target = ${$_[1]};
75 0 my $txt = ${$_[2]};
76  
77 return PLUGIN_EAT_NONE
78 0 ▶ unless defined $self->ircobjs->{$context}
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->ircobjs->{$context} and $core->is_connected($context) 0 0 0
Condition0%0/3
defined $self->ircobjs->{$context} and $core->is_connected($context)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->ircobjs->{$context} and $core->is_connected($context)
defined $self->ircobjs->{$context} $core->is_connected($context)
Truth table0%0/3
A and B
A= defined $self->ircobjs->{$context}B= $core->is_connected($context)
ABresult
0X0
100
111
79 and $core->is_connected($context);
80  
81 ## USER event Outgoing_notice
82 0 my @notice = ( $context, $target, $txt );
83 0 my $eat = $core->send_user_event( 'notice', \@notice );
84  
85 0 ▶ unless ($eat == PLUGIN_EAT_ALL) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($eat == 4) 0 0 0
86 0 my ($target, $txt) = @notice[1,2];
87  
88 0 $self->ircobjs->{$context}->yield( 'notice',
89 $target,
90 $txt
91 );
92  
93 0 broadcast( 'notice_sent', $context, $target, $txt );
94 }
95  
96 0 return PLUGIN_EAT_NONE
97 }
98  
99  
100 0 ▶sub Bot_send_action { Bot_action(@_) }
Subroutine Bot_send_action: not called CC=1 SCAR=6.9
Pod undocumented
101 0 ▶sub Bot_action {
Subroutine Bot_action: not called CC=5 SCAR=34.0
Pod undocumented
102 0 my ($self, $core) = splice @_, 0, 2;
103  
104 0 ▶ unless (defined $_[2]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $_[2]) 0 0 0
105 0 logger->error("Bot_action received without enough arguments");
106 0 return PLUGIN_EAT_NONE
107 }
108  
109 0 my $context = ${$_[0]};
110 0 my $target = ${$_[1]};
111 0 my $txt = ${$_[2]};
112  
113 return PLUGIN_EAT_NONE
114 0 ▶ unless defined $self->ircobjs->{$context}
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->ircobjs->{$context} and $core->is_connected($context) 0 0 0
Condition0%0/3
defined $self->ircobjs->{$context} and $core->is_connected($context)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->ircobjs->{$context} and $core->is_connected($context)
defined $self->ircobjs->{$context} $core->is_connected($context)
Truth table0%0/3
A and B
A= defined $self->ircobjs->{$context}B= $core->is_connected($context)
ABresult
0X0
100
111
115 and $core->is_connected($context);
116  
117 ## USER event Outgoing_ctcp (CONTEXT, TYPE, TARGET, TEXT)
118 0 my @ctcp = ( $context, 'ACTION', $target, $txt );
119 0 my $eat = $core->send_user_event( 'ctcp', \@ctcp );
120  
121 0 ▶ unless ($eat == PLUGIN_EAT_ALL) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($eat == 4) 0 0 0
122 0 my ($target, $txt) = @ctcp[2,3];
123  
124 0 $self->ircobjs->{$context}->yield( 'ctcp',
125 $target,
126 'ACTION '.$txt
127 );
128  
129 0 broadcast( 'ctcp_sent', $context, 'ACTION', $target, $txt );
130 }
131  
132 0 return PLUGIN_EAT_NONE
133 }
134  
135  
136 0 ▶sub Bot_topic {
Subroutine Bot_topic: not called CC=6 SCAR=37.4
Pod undocumented
137 0 my ($self, $core) = splice @_, 0, 2;
138  
139 0 ▶ unless (defined $_[1]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $_[1]) 0 0 0
140 0 logger->error("Bot_topic received without enough arguments");
141 0 return PLUGIN_EAT_NONE
142 }
143  
144 0 my $context = ${$_[0]};
145 0 my $channel = ${$_[1]};
146 0 ▶ my $topic = defined $_[2] ? ${$_[2]} : "" ;
Branch: 1 branch
BranchTrueFalseTotal
defined $_[2] ? : 0 0 0
147  
148 return PLUGIN_EAT_NONE
149 0 ▶ unless defined $self->ircobjs->{$context}
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->ircobjs->{$context} and $core->is_connected($context) 0 0 0
Condition0%0/3
defined $self->ircobjs->{$context} and $core->is_connected($context)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->ircobjs->{$context} and $core->is_connected($context)
defined $self->ircobjs->{$context} $core->is_connected($context)
Truth table0%0/3
A and B
A= defined $self->ircobjs->{$context}B= $core->is_connected($context)
ABresult
0X0
100
111
150 and $core->is_connected($context);
151  
152 0 ▶ return PLUGIN_EAT_NONE unless $core->is_connected($context);
Branch: 1 branch
BranchTrueFalseTotal
unless $core->is_connected($context) 0 0 0
153  
154 0 $self->irc->yield( 'topic', $channel, $topic );
155  
156 0 return PLUGIN_EAT_NONE
157 }
158  
159 0 ▶sub Bot_mode {
Subroutine Bot_mode: not called CC=4 SCAR=30.0
Pod undocumented
160 0 my ($self, $core) = splice @_, 0, 2;
161  
162 0 ▶ unless (defined $_[2]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $_[2]) 0 0 0
163 0 logger->error("Bot_mode received without enough arguments");
164 0 return PLUGIN_EAT_NONE
165 }
166  
167 0 my $context = ${$_[0]};
168 0 my $target = ${$_[1]}; ## channel or self normally
169 0 my $modestr = ${$_[2]}; ## modes + args
170  
171 return PLUGIN_EAT_NONE
172 0 ▶ unless defined $self->ircobjs->{$context}
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->ircobjs->{$context} and $core->is_connected($context) 0 0 0
Condition0%0/3
defined $self->ircobjs->{$context} and $core->is_connected($context)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->ircobjs->{$context} and $core->is_connected($context)
defined $self->ircobjs->{$context} $core->is_connected($context)
Truth table0%0/3
A and B
A= defined $self->ircobjs->{$context}B= $core->is_connected($context)
ABresult
0X0
100
111
173 and $core->is_connected($context);
174  
175 0 my ($mode, @args) = split ' ', $modestr;
176  
177 0 $self->ircobjs->{$context}->yield( 'mode', $target, $mode, @args );
178  
179 0 return PLUGIN_EAT_NONE
180 }
181  
182 0 ▶sub Bot_kick {
Subroutine Bot_kick: not called CC=6 SCAR=37.4
Pod undocumented
183 0 my ($self, $core) = splice @_, 0, 2;
184  
185 0 ▶ unless (defined $_[2]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $_[2]) 0 0 0
186 0 logger->error("Bot_kick received without enough arguments");
187 0 return PLUGIN_EAT_NONE
188 }
189  
190 0 my $context = ${$_[0]};
191 0 my $channel = ${$_[1]};
192 0 my $target = ${$_[2]};
193 0 ▶ my $reason = defined $_[3] ? ${$_[3]} : 'Kicked';
Branch: 1 branch
BranchTrueFalseTotal
defined $_[3] ? : 0 0 0
194  
195 return PLUGIN_EAT_NONE
196 0 ▶ unless defined $self->ircobjs->{$context}
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->ircobjs->{$context} and $core->is_connected($context) 0 0 0
Condition0%0/3
defined $self->ircobjs->{$context} and $core->is_connected($context)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->ircobjs->{$context} and $core->is_connected($context)
defined $self->ircobjs->{$context} $core->is_connected($context)
Truth table0%0/3
A and B
A= defined $self->ircobjs->{$context}B= $core->is_connected($context)
ABresult
0X0
100
111
197 and $core->is_connected($context);
198  
199 0 ▶ return PLUGIN_EAT_NONE unless $core->is_connected($context);
Branch: 1 branch
BranchTrueFalseTotal
unless $core->is_connected($context) 0 0 0
200  
201 0 $self->ircobjs->{$context}->yield( 'kick', $channel, $target, $reason
202 );
203  
204 0 return PLUGIN_EAT_NONE
205 }
206  
207  
208 0 ▶sub Bot_join {
Subroutine Bot_join: not called CC=4 SCAR=30.0
Pod undocumented
209 0 my ($self, $core) = splice @_, 0, 2;
210  
211 0 ▶ unless (defined $_[1]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $_[1]) 0 0 0
212 0 logger->error("Bot_join received without enough arguments");
213 0 return PLUGIN_EAT_NONE
214 }
215  
216 0 my $context = ${$_[0]};
217 0 my $channel = ${$_[1]};
218  
219 return PLUGIN_EAT_NONE
220 0 ▶ unless defined $self->ircobjs->{$context}
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->ircobjs->{$context} and $core->is_connected($context) 0 0 0
Condition0%0/3
defined $self->ircobjs->{$context} and $core->is_connected($context)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->ircobjs->{$context} and $core->is_connected($context)
defined $self->ircobjs->{$context} $core->is_connected($context)
Truth table0%0/3
A and B
A= defined $self->ircobjs->{$context}B= $core->is_connected($context)
ABresult
0X0
100
111
221 and $core->is_connected($context);
222  
223 0 $self->ircobjs->{$context}->yield( 'join', $channel );
224  
225 0 return PLUGIN_EAT_NONE
226 }
227  
228 0 ▶sub Bot_part {
Subroutine Bot_part: not called CC=5 SCAR=34.0
Pod undocumented
229 0 my ($self, $core) = splice @_, 0, 2;
230  
231 0 ▶ unless (defined $_[1]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $_[1]) 0 0 0
232 0 logger->error("Bot_part received without enough arguments");
233 0 return PLUGIN_EAT_NONE
234 }
235  
236 0 my $context = ${$_[0]};
237 0 my $channel = ${$_[1]};
238 0 ▶ my $reason = defined $_[2] ? ${$_[2]} : 'Leaving' ;
Branch: 1 branch
BranchTrueFalseTotal
defined $_[2] ? : 0 0 0
239  
240 return PLUGIN_EAT_NONE
241 0 ▶ unless defined $self->ircobjs->{$context}
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->ircobjs->{$context} and $core->is_connected($context) 0 0 0
Condition0%0/3
defined $self->ircobjs->{$context} and $core->is_connected($context)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->ircobjs->{$context} and $core->is_connected($context)
defined $self->ircobjs->{$context} $core->is_connected($context)
Truth table0%0/3
A and B
A= defined $self->ircobjs->{$context}B= $core->is_connected($context)
ABresult
0X0
100
111
242 and $core->is_connected($context);
243  
244 0 $self->ircobjs->{$context}->yield( 'part', $channel, $reason );
245  
246 0 return PLUGIN_EAT_NONE
247 }
248  
249 0 ▶sub Bot_send_raw {
Subroutine Bot_send_raw: not called CC=4 SCAR=30.0
Pod undocumented
250 0 my ($self, $core) = splice @_, 0, 2;
251  
252 0 ▶ unless (defined $_[1]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $_[1]) 0 0 0
253 0 logger->error("Bot_send_Raw received without enough arguments");
254 0 return PLUGIN_EAT_NONE
255 }
256  
257 0 my $context = ${$_[0]};
258 0 my $raw = ${$_[1]};
259  
260 return PLUGIN_EAT_NONE
261 0 ▶ unless defined $self->ircobjs->{$context}
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->ircobjs->{$context} and $core->is_connected($context) 0 0 0
Condition0%0/3
defined $self->ircobjs->{$context} and $core->is_connected($context)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->ircobjs->{$context} and $core->is_connected($context)
defined $self->ircobjs->{$context} $core->is_connected($context)
Truth table0%0/3
A and B
A= defined $self->ircobjs->{$context}B= $core->is_connected($context)
ABresult
0X0
100
111
262 and $core->is_connected($context);
263  
264 0 $self->ircobjs->{$context}->yield( 'quote', $raw );
265  
266 0 broadcast( 'raw_sent', $context, $raw );
267  
268 0 return PLUGIN_EAT_NONE
269 }
270  
271  
272 1 1
« blib/lib/Bot/Cobalt/Core/ContextMeta/Auth.pm ↑ Summary blib/lib/Bot/Cobalt/IRC/Role/AdminCmds.pm »