Bot-Cobalt

 view release on metacpan or  search on metacpan

lib/Bot/Cobalt/Core.pm  view on Meta::CPAN

package Bot::Cobalt::Core;
$Bot::Cobalt::Core::VERSION = '0.021003';
## This is the core Syndicator singleton.

use strictures 2;

use v5.10;
use Carp;

use POE;

use Bot::Cobalt::Common;
use Bot::Cobalt::IRC;
use Bot::Cobalt::Lang;
use Bot::Cobalt::Logger;

use Bot::Cobalt::Core::ContextMeta::Auth;
use Bot::Cobalt::Core::ContextMeta::Ignore;
use Bot::Cobalt::Core::Loader;

use Scalar::Util 'blessed';
use Try::Tiny;

use Path::Tiny;
use Types::Path::Tiny -types;

use Moo;

has cfg => (
  required  => 1,
  is        => 'rw',
  isa       => InstanceOf['Bot::Cobalt::Conf'],
);

has var => (
  required  => 1,
  is        => 'ro',
  isa       => Path,
  coerce    => 1,
);

has etc => (
  lazy      => 1,
  is        => 'ro',
  isa       => Path,
  coerce    => 1,
  builder   => sub { shift->cfg->etc },
);

has log => (
  lazy      => 1,
  is        => 'rw',
  isa       => HasMethods[qw/debug info warn error/],
  builder   => sub {
    my ($self) = @_;
    my %opts = (
      level => $self->loglevel,
    );
    if (my $log_format = $self->cfg->core->opts->{LogFormat}) {
      $opts{log_format} = $log_format
    }
    if (my $log_time_fmt = $self->cfg->core->opts->{LogTimeFormat}) {
      $opts{time_format} = $log_time_fmt
    }
    Bot::Cobalt::Logger->new( %opts )
  },
);

has loglevel => (
  is        => 'rw',
  isa       => Str,
  builder   => sub { 'info' },
);

has detached => (
  lazy      => 1,
  is        => 'ro',
  isa       => Int,
  builder   => sub { 0 },
);

has debug => (



( run in 0.505 second using v1.01-cache-2.11-cpan-39bf76dae61 )