App-SpreadRevolutionaryDate
view release on metacpan or search on metacpan
lib/App/SpreadRevolutionaryDate/Target/Freenode/Bot.pm view on Meta::CPAN
#
# This file is part of App-SpreadRevolutionaryDate
#
# This software is Copyright (c) 2019-2026 by Gérald Sédrati.
#
# This is free software, licensed under:
#
# The GNU General Public License, Version 3, June 2007
#
use 5.014;
use utf8;
package App::SpreadRevolutionaryDate::Target::Freenode::Bot;
$App::SpreadRevolutionaryDate::Target::Freenode::Bot::VERSION = '0.54';
# ABSTRACT: Subclass overloading L<Bot::BasicBot> to post a message on some Freenode channels
use Moose;
use MooseX::NonMoose;
extends 'Bot::BasicBot';
use Locale::TextDomain 'App-SpreadRevolutionaryDate';
use namespace::autoclean;
has 'nb_said' => (
traits => ['Counter'],
is => 'rw',
isa => 'Num',
default => 0,
handles => {
inc_said => 'inc',
},
);
has 'nb_ticks' => (
traits => ['Counter'],
is => 'rw',
isa => 'Num',
default => 0,
handles => {
inc_ticks => 'inc',
},
);
has 'msg' => (
is => 'rw',
isa => 'Str',
default => '',
);
sub connected {
my $self = shift;
$self->say({who => 'NickServ', channel => 'msg', body => 'IDENTIFY ' . $self->{freenode_nickname} . ' ' . $self->{freenode_password}});
}
sub said {
my ($self, $message) = @_;
$self->nb_said(1) if ($message->{who} eq 'NickServ' && $message->{body} =~ /^You are now identified for/);
return;
}
sub tick {
my $self = shift;
if ($self->nb_said) {
if ($self->nb_said > scalar($self->channels)) {
$self->shutdown;
}
foreach my $channel ($self->channels) {
$self->say({channel => $channel, body => $self->{msg}});
$self->inc_said;
}
}
$self->inc_ticks;
$self->shutdown if ($self->nb_ticks > 10);
return 5;
}
sub log {
( run in 0.559 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )