App-RoboBot

 view release on metacpan or  search on metacpan

lib/App/RoboBot/Channel.pm  view on Meta::CPAN

package App::RoboBot::Channel;
$App::RoboBot::Channel::VERSION = '4.004';
use v5.20;

use namespace::autoclean;

use Moose;
use MooseX::ClassAttribute;
use MooseX::SetOnce;

use JSON;

has 'id' => (
    is        => 'rw',
    isa       => 'Int',
    traits    => [qw( SetOnce )],
    predicate => 'has_id',
);

has 'name' => (
    is       => 'ro',
    isa      => 'Str',
    required => 1,
    predicate => 'has_name' # TODO: this is pointless, but something is still calling it and that needs to be fixed
);

has 'extradata' => (
    is      => 'rw',
    isa     => 'HashRef',
    default => sub { {} },
);

has 'log_enabled' => (
    is      => 'rw',
    isa     => 'Bool',
    default => 1,
);

has 'network' => (
    is        => 'ro',
    isa       => 'App::RoboBot::Network',
    required  => 1,
    predicate => 'has_network' # TODO: this is pointless, but something is still calling it and that needs to be fixed
);

has 'config' => (
    is       => 'ro',
    isa      => 'App::RoboBot::Config',
    required => 1,
);

class_has 'log' => (
    is        => 'rw',
    predicate => 'has_logger',
);

sub find_by_id {
    my ($class, $bot, $id) = @_;

    my $logger = $bot->logger('core.channel');

    $logger->debug(sprintf('Attempting to locate channel by ID %d.', $id));

    my $res = $bot->config->db->do(q{
        select c.id, c.name, c.extradata, c.log_enabled, n.name as network



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