SpreadRevolutionaryDate/Target/Freenode/Bot.pm

filter: Statementstmt 55.1% 27 / 49 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 58.3% 7 / 12 Podpod 100% 5 / 5 totaltotal 48.1% 39 / 81 CC 9 SCAR 24.5
CC
9
Cov
44%
tick
30.0
said
12.0
chanjoin
12.0
CRAP 11.6
« SpreadRevolutionaryDate/MsgMaker/PromptUser.pm ↑ Summary SpreadRevolutionaryDate/Target/Liberachat/Bot.pm »
1 #
2 # This file is part of App-SpreadRevolutionaryDate
3 #
4 # This software is Copyright (c) 2019-2026 by Gérald Sédrati.
5 #
6 # This is free software, licensed under:
7 #
8 # The GNU General Public License, Version 3, June 2007
9 #
10 5 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 package App::SpreadRevolutionaryDate::Target::Freenode::Bot;
13 5 $App::SpreadRevolutionaryDate::Target::Freenode::Bot::VERSION = '0.54';
14 # ABSTRACT: Subclass overloading L<Bot::BasicBot> to post a message on some Freenode channels
15  
16 5 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 5 ▶use MooseX::NonMoose;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 5 extends 'Bot::BasicBot';
19  
20 5 ▶use Locale::TextDomain 'App-SpreadRevolutionaryDate';
Subroutine BEGIN: called CC=1 SCAR=0.0
21 5 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 5 has 'nb_said' => (
24 traits => ['Counter'],
25 is => 'rw',
26 isa => 'Num',
27 default => 0,
28 handles => {
29 inc_said => 'inc',
30 },
31 );
32  
33 5 has 'nb_ticks' => (
34 traits => ['Counter'],
35 is => 'rw',
36 isa => 'Num',
37 default => 0,
38 handles => {
39 inc_ticks => 'inc',
40 },
41 );
42  
43 5 has 'msg' => (
44 is => 'rw',
45 isa => 'Str',
46 default => '',
47 );
48  
49 0 ▶sub connected {
Subroutine connected: not called CC=1 SCAR=6.9
Pod documented
50 0 my $self = shift;
51  
52 0 $self->say({who => 'NickServ', channel => 'msg', body => 'IDENTIFY ' . $self->{freenode_nickname} . ' ' . $self->{freenode_password}});
53 }
54  
55 0 ▶sub said {
Subroutine said: not called CC=3 SCAR=24.8
Pod documented
56 0 my ($self, $message) = @_;
57  
58 0 ▶ $self->nb_said(1) if ($message->{who} eq 'NickServ' && $message->{body} =~ /^You are now identified for/);
Branch: 1 branch
BranchTrueFalseTotal
if $message->{"who"} eq "NickServ" and $message->{"body"} =~ /^You are now identified for/u 0 0 0
Condition0%0/3
$message->{"who"} eq "NickServ" and $message->{"body"} =~ /^You are now identified for/u
!ll&&!rl&&r
000
MC/DC0%0/2
$message->{"who"} eq "NickServ" and $message->{"body"} =~ /^You are now identified for/u
$message->{"who"} eq "NickServ" $message->{"body"} =~ /^You are now identified for/u
Truth table0%0/3
A and B
A= $message->{"who"} eq "NickServ"B= $message->{"body"} =~ /^You are now identified for/u
ABresult
0X0
100
111
59 0 return;
60 }
61  
62 0 ▶sub tick {
Subroutine tick: not called CC=5 SCAR=34.0
Pod documented
63 0 my $self = shift;
64  
65 0 ▶ if ($self->nb_said) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->nb_said) 0 0 0
66 0 ▶ if ($self->nb_said > scalar($self->channels)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->nb_said > scalar $self->channels) 0 0 0
67 0 $self->shutdown;
68 }
69 0 foreach my $channel ($self->channels) {
70 0 $self->say({channel => $channel, body => $self->{msg}});
71 0 $self->inc_said;
72 }
73 }
74  
75 0 $self->inc_ticks;
76 0 ▶ $self->shutdown if ($self->nb_ticks > 10);
Branch: 1 branch
BranchTrueFalseTotal
if $self->nb_ticks > 10 0 0 0
77  
78 0 return 5;
79 }
80  
81 0 ▶sub log {
Subroutine log: not called CC=1 SCAR=0.0
Pod documented
82 # do nothing!
83 }
84  
85 0 ▶sub chanjoin {
Subroutine chanjoin: not called CC=3 SCAR=24.8
Pod documented
86 0 my $self = shift;
87  
88 # Remove channels added by Bot::BasicBot::irc_chanjoin_state with different case
89 0 my %uniq_channels;
90 0 foreach my $channel ($self->channels) {
91 0 $uniq_channels{lc($channel)} = $channel;
92 }
93  
94 0 ▶ if (scalar(keys %uniq_channels) != scalar($self->channels)) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar keys %uniq_channels != scalar $self->channels) 0 0 0
95 0 $self->channels(values %uniq_channels);
96 }
97  
98 0 return;
99 }
100  
101  
102 5 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
103 5 __PACKAGE__->meta->make_immutable;
104  
105 # A module must return a true value. Traditionally, a module returns 1.
106 # But this module is a revolutionary one, so it discards all old traditions.
107 # Idea borrowed from Jean Forget's DateTime::Calendar::FrenchRevolutionary.
108 5 "Quand le gouvernement viole les droits du peuple,
109 l'insurrection est pour le peuple le plus sacré
110 et le plus indispensable des devoirs";
111  
112 __END__
« SpreadRevolutionaryDate/MsgMaker/PromptUser.pm ↑ Summary SpreadRevolutionaryDate/Target/Liberachat/Bot.pm »