« SpreadRevolutionaryDate/Target/Freenode/Bot.pm
↑ Summary
SpreadRevolutionaryDate/MsgMaker/Telechat.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::Liberachat::Bot; | ||||||||||||||||||||||||||||
| 13 | 5 | $App::SpreadRevolutionaryDate::Target::Liberachat::Bot::VERSION = '0.54'; | |||||||||||||||||||||||||||
| 14 | # ABSTRACT: Subclass overloading L<Bot::BasicBot> to post a message on some Liberachat 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->{liberachat_nickname} . ' ' . $self->{liberachat_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
Condition0%0/3
$message->{"who"} eq "NickServ" and $message->{"body"} =~ /^You are now identified for/u
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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ($self->nb_said > scalar($self->channels)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||