Adam
view release on metacpan or search on metacpan
lib/Adam.pm view on Meta::CPAN
package Adam;
# ABSTRACT: The patriarch of IRC Bots
our $VERSION = '1.003';
use MooseX::POE;
use namespace::autoclean;
use POE::Component::IRC::Common qw( :ALL );
use POE qw(
Component::IRC::State
Component::IRC::Plugin::PlugMan
Component::IRC::Plugin::Connector
Component::IRC::Plugin::ISupport
Component::IRC::Plugin::NickReclaim
Component::IRC::Plugin::BotAddressed
Component::IRC::Plugin::AutoJoin
);
use MooseX::Aliases;
use Adam::Logger::Default;
with qw(
MooseX::SimpleConfig
MooseX::Getopt
);
has logger => (
does => 'Adam::Logger::API',
is => 'ro',
traits => ['NoGetopt'],
lazy_build => 1,
handles => 'Adam::Logger::API',
);
sub _build_logger { Adam::Logger::Default->new() }
has nickname => (
isa => 'Str',
reader => 'get_nickname',
alias => 'nick',
traits => ['Getopt'],
cmd_flag => 'nickname',
required => 1,
builder => 'default_nickname',
);
sub default_nickname { $_[0]->meta->name }
has server => (
isa => 'Str',
reader => 'get_server',
traits => ['Getopt'],
cmd_flag => 'server',
required => 1,
builder => 'default_server',
);
sub default_server { 'irc.perl.org' }
has port => (
isa => 'Int',
reader => 'get_port',
traits => ['Getopt'],
cmd_flag => 'port',
required => 1,
builder => 'default_port',
);
sub default_port { 6667 }
has channels => (
isa => 'ArrayRef',
reader => 'get_channels',
traits => ['Getopt'],
cmd_flag => 'channels',
builder => 'default_channels',
auto_deref => 1,
);
sub default_channels { [] }
has owner => (
isa => 'Str',
accessor => 'get_owner',
traits => ['Getopt'],
cmd_flag => 'owner',
builder => 'default_owner',
);
sub default_owner { 'perigrin!~perigrin@217.168.150.167' }
lib/Adam.pm view on Meta::CPAN
}
has _loop => (
is => 'rw',
traits => ['NoGetopt'],
predicate => 'has_loop',
);
sub async {
my $self = shift;
require IO::Async::Loop::POE;
$self = $self->new_with_options unless blessed $self;
my $loop = IO::Async::Loop::POE->new();
$self->_loop($loop);
$loop->run;
}
sub stop {
my $self = shift;
if ($self->has_loop) {
$self->_loop->stop;
} else {
POE::Kernel->stop;
}
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Adam - The patriarch of IRC Bots
=head1 VERSION
version 1.003
=head1 SYNOPSIS
See the Synopsis in L<Moses>. Adam is not meant to be used directly.
=head1 DESCRIPTION
The Adam class implements an IRC bot based on L<POE::Component::IRC::State>,
L<Moose>, and L<MooseX::POE>. It supports two event loop modes: the default
L<POE> loop via C<run()>, and an L<IO::Async> mode via C<async()> that allows
integration with other L<IO::Async>-based components through
L<IO::Async::Loop::POE>.
Adam is not meant to be used directly â see L<Moses> for the declarative
sugar layer.
=head2 logger
Logger object that implements the L<Adam::Logger::API> role. Defaults to
L<Adam::Logger::Default>.
=head2 nickname
The IRC nickname for the bot. Defaults to the package name. Required.
=head2 server
The IRC server to connect to. Defaults to C<irc.perl.org>. Required.
=head2 port
The port for the IRC server. Defaults to C<6667>.
=head2 channels
IRC channels to connect to. ArrayRef of channel names.
=head2 owner
The hostmask of the owner of the bot. The owner can control the bot's plugins
through IRC using the L<POE::Component::IRC::Plugin::PlugMan> interface.
=head2 username
The username to use for IRC connection. Defaults to C<adam>.
=head2 password
The server password to use for IRC connection. Defaults to empty string.
=head2 flood
Disable flood protection. Defaults to C<0> (false).
=head2 plugins
A HashRef of plugins associated with the IRC bot. See L<Moses::Plugin> for more
details.
=head2 core_plugins
Returns the core plugins that are loaded by default.
=head2 custom_plugins
Returns custom plugins to be loaded. Override this in subclasses.
=head2 default_plugins
Returns all plugins (core and custom) to be loaded.
=head2 plugin_manager
The L<POE::Component::IRC::Plugin::PlugMan> instance for managing plugins.
=head2 poco_irc_args
( run in 2.743 seconds using v1.01-cache-2.11-cpan-5837b0d9d2c )