Bot-Cobalt
view release on metacpan or search on metacpan
lib/Bot/Cobalt/Core/ContextMeta/Ignore.pm view on Meta::CPAN
use Moo;
extends 'Bot::Cobalt::Core::ContextMeta';
around add => sub {
my $orig = shift;
my ($self, $context, $mask, $reason, $addedby) = @_;
my ($pkg, $line) = (caller)[0,2];
confess "Missing arguments in ignore add()"
unless defined $context and defined $mask;
$mask = normalize_mask($mask);
$addedby = $pkg unless defined $addedby;
$reason = "Added by $pkg" unless defined $reason;
my $meta = +{
AddedBy => $addedby,
lib/Bot/Cobalt/Core/Role/IRC.pm view on Meta::CPAN
return unless defined $context and exists $self->Servers->{$context};
$self->Servers->{$context}
}
*get_irc_object = *get_irc_obj;
sub get_irc_obj {
my ($self, $context) = @_;
if (! $context) {
$self->log->warn(
"get_irc_obj called with no context at "
.join ' ', (caller)[0,2]
);
return
}
my $c_obj = $self->get_irc_context($context);
unless ($c_obj && blessed $c_obj) {
$self->log->warn(
"get_irc_obj called but context $context not found at "
.join ' ', (caller)[0,2]
);
return
}
blessed $c_obj->irc ? $c_obj->irc : ()
}
sub get_irc_casemap {
my ($self, $context) = @_;
if (! $context) {
$self->log->warn(
"get_irc_casemap called with no context at "
.join ' ', (caller)[0,2]
);
return
}
my $c_obj = $self->get_irc_context($context);
unless ($c_obj && blessed $c_obj) {
$self->log->warn(
"get_irc_casemap called but context $context not found at "
.join ' ', (caller)[0,2]
);
return
}
$c_obj->casemap
}
1;
__END__
lib/Bot/Cobalt/Core/Role/Timers.pm view on Meta::CPAN
my ($self) = @_;
my @p = ( 'a'..'f', 1..9 );
my $id = join '', map { $p[rand@p] } 1 .. 4;
$id .= $p[rand@p] while $self->TimerPool->exists($id);
$id
}
sub timer_set {
my ($self, $item) = @_;
my ($caller_pkg, $caller_line) = (caller)[0,2];
my $d_line = "$caller_pkg line $caller_line";
my $timer = $item;
unless (blessed $item && $item->isa('Bot::Cobalt::Timer') ) {
## hashref-style (we hope)
$timer = $self->timer_set_hashref( $item, @_[2 .. $#_] );
}
unless ($timer->has_id) {
$timer->id( $self->timer_gen_unique_id );
lib/Bot/Cobalt/Core/Role/Timers.pm view on Meta::CPAN
$self->log->debug(
"timer_set; ".join ' ', $timer->id, $timer->delay, $timer->event
) if $self->debug > 1;
$timer->id
}
sub timer_set_hashref {
my ($self, $delay, $ev, $id) = @_;
my ($caller_pkg, $caller_line) = (caller)[0,2];
my $d_line = "$caller_pkg line $caller_line";
unless (ref $ev eq 'HASH') {
if (ref $ev) {
$self->log->warn(
"timer_set_hashref expected HASH but got $ev; $d_line"
);
return
} else {
## Assume we were passed a simple string.
lib/Bot/Cobalt/Plugin/WWW.pm view on Meta::CPAN
sub Bot_www_request {
my ($self, $core) = splice @_, 0, 2;
my $request = ${ $_[0] };
my $event = defined $_[1] ? ${$_[1]} : undef ;
my $args = defined $_[2] ? ${$_[2]} : undef ;
unless ($request && $request->isa('HTTP::Request')) {
logger->warn(
"www_request received but no request at "
.join ' ', (caller)[0,2]
);
}
unless ($event) {
## no event at all is legitimate
$event = 'www_not_handled';
}
$args = [] unless $args;
my @p = ( 'a' .. 'f', 1 .. 9 );
( run in 1.628 second using v1.01-cache-2.11-cpan-1e74a51a04c )