view release on metacpan or search on metacpan
lib/App/RoboBot/Network/Slack.pm view on Meta::CPAN
);
sub BUILD {
my ($self) = @_;
$self->client(AnyEvent::SlackRTM->new(
$self->token
));
$self->client->on( 'hello' => sub {
$self->keepalive(AnyEvent->timer(
interval => 60,
cb => sub { $self->reconnect if $self->client->finished }
));
});
$self->client->on( 'message' => sub {
my ($cl, $msg) = @_;
$self->handle_message($msg);
});
}
lib/App/RoboBot/Plugin/API/Github.pm view on Meta::CPAN
},
);
sub init {
my ($self, $bot) = @_;
# Kick off the watcher with a short delay for the first check, to give the
# bot a little time to settle into things before firing off notifications
# in channels.
$self->watcher(
AnyEvent->timer(
after => 30,
cb => sub { $self->_run_watcher($bot) },
)
);
}
sub list_repo_watchers {
my ($self, $message, $command, $rpl) = @_;
unless ($message->has_channel) {
lib/App/RoboBot/Plugin/API/Github.pm view on Meta::CPAN
bot => $bot,
);
$response->push(@notices);
$response->send;
}
}
}
$self->watcher(
AnyEvent->timer(
after => 90,
cb => sub { $self->_run_watcher($bot) },
)
);
}
__PACKAGE__->meta->make_immutable;
1;
lib/App/RoboBot/Plugin/API/Kegerator.pm view on Meta::CPAN
# loop later on.
if (exists $self->bot->config->plugins->{'kegerator'}{'notify'}) {
$self->bot->config->plugins->{'kegerator'}{'notify'} = [
$self->bot->config->plugins->{'kegerator'}{'notify'}
] if ref($self->bot->config->plugins->{'kegerator'}{'notify'}) eq 'HASH';
# Only set the watcher if we have at least one channel to notify.
return unless @{$self->bot->config->plugins->{'kegerator'}{'notify'}} > 0;
$self->watcher(
AnyEvent->timer(
after => 30,
cb => sub { $self->_run_watcher($bot) },
)
);
}
}
sub show_ontap {
my ($self, $message, $command, $rpl, $tap_no) = @_;
lib/App/RoboBot/Plugin/API/Kegerator.pm view on Meta::CPAN
# TODO: If any tap#'s were marked as new, call the beer detail API endpoint
# to get beer name, ABV, IBU, etc.
# TODO: If any @output to send, construct a mock Response object for each
# plugin->notice[server+channel], and send notifications out.
# TODO: Update plugin's last_check timestamp.
$self->watcher(
AnyEvent->timer(
after => 30,
cb => sub { $self->_run_watcher($bot) },
)
);
}
__PACKAGE__->meta->make_immutable;
1;
lib/App/RoboBot/Plugin/Bot/Alarm.pm view on Meta::CPAN
use App::RoboBot::Response;
extends 'App::RoboBot::Plugin';
=head1 bot.alarm
Exports functions for setting and modifying alarms, which can trigger messages
at specified times or intervals.
In addition to the exported functions, this module maintains a collection of
persistent AnyEvent timer objects which are used to fire the alarm messages
asynchronously from any regular message processing.
=cut
has '+name' => (
default => 'Bot::Alarm',
);
has '+description' => (
default => 'Exports functions for setting and modifying alarms, which can trigger messages at specified times or intervals.',
lib/App/RoboBot/Plugin/Bot/Alarm.pm view on Meta::CPAN
from alarms_alarms
where not is_suspended
});
return unless $res;
while ($res->next) {
my $alarm = $self->_get_alarm($self->bot, $res->{'id'});
next unless defined $alarm;
$self->_add_timer($alarm);
}
}
sub set_alarm {
my ($self, $message, $command, $rpl, $keyed, $name, @args) = @_;
return unless $message->has_channel;
$name = $name->evaluate($message, $rpl) if defined $name && blessed($name) && $name->can('evaluate');
lib/App/RoboBot/Plugin/Bot/Alarm.pm view on Meta::CPAN
}, \%alarm);
if ($res && $res->next) {
$alarm{'id'} = $res->{'id'};
} else {
$message->response->raise('Could not save your alarm. Please try again.');
return;
}
}
$self->_add_timer(\%alarm);
# TODO: Notify channel of alarm creation and next emittance.
$message->response->push(sprintf('The alarm "%s" has been added to this channel.', $name));
return;
}
sub delete_alarm {
my ($self, $message, $command, $rpl, $name) = @_;
return unless $message->has_channel;
lib/App/RoboBot/Plugin/Bot/Alarm.pm view on Meta::CPAN
# Update suspended bool in database.
$self->bot->config->db->do(q{
update alarms_alarms set is_suspended = false where id = ?
}, $res->{'id'});
# Delegate to _get_alarm so that it can handle calculations for next_emit.
my $alarm = $self->_get_alarm($self->bot, $res->{'id'});
return unless defined $alarm;
$self->_add_timer($alarm);
$message->response->push(sprintf('The alarm "%s" has been resumed.', $name));
return;
}
sub suspend_alarm {
my ($self, $message, $command, $rpl, $name) = @_;
return unless $message->has_channel && defined $name;
lib/App/RoboBot/Plugin/Bot/Alarm.pm view on Meta::CPAN
unless ($res && $res->next) {
$message->response->raise('There is no alarm named "%s" in this channel.', $name);
return;
}
if ($res->{'is_suspended'}) {
$message->response->raise('The alarm "%s" is already suspended.', $name);
return;
}
# Remove from the active alarm timers.
delete $self->alarms->{$res->{'id'}};
# Update in the database.
$self->bot->config->db->do(q{
update alarms_alarms set is_suspended = true where id = ?
}, $res->{'id'});
$message->response->push(sprintf('The alarm "%s" has been suspended.', $name));
return;
}
sub _get_alarm {
my ($self, $bot, $alarm_id) = @_;
# We buffer the comparison of the current next_emit to now() by a little bit
# into the future to account for the possibility of timer drift, and any
# other delays that may occur between when the timer is schedule to fire and
# when our bot's single execution thread finally reaches this point. One
# minute is a major buffer, but alarms cannot be scheduled to trigger more
# than a few times each hour anyway.
my $res = $bot->config->db->do(q{
select a.*,
case
when a.next_emit <= (now() + interval '1 minute') then 1
else 0
end as do_recalc
from alarms_alarms a
lib/App/RoboBot/Plugin/Bot/Alarm.pm view on Meta::CPAN
$message = $expr->evaluate($msg, {});
}
} elsif ($alarm->{'message'}) {
$message = $alarm->{'message'};
}
$response->push($message) if defined $message && $message =~ m{\w+};
$response->send;
if ($alarm->{'next_emit'} && $alarm->{'recurrence'}) {
$self->_add_timer($alarm);
}
}
sub _add_timer {
my ($self, $alarm) = @_;
my $res = $self->bot->config->db->do(q{
select extract(epoch from ? - now())::int as delay
}, $alarm->{'next_emit'});
return unless $res && $res->next && $res->{'delay'} > 0;
$self->alarms->{$alarm->{'id'}} = AnyEvent->timer(
after => $res->{'delay'},
cb => sub { $self->_emit_alarm($alarm->{'id'}) },
);
}
__PACKAGE__->meta->make_immutable;
1;
share/ubuntu-xenial-16.04-cloudimg-console.log view on Meta::CPAN
[ 0.000000] Build-time adjustment of leaf fanout to 64.
[ 0.000000] RCU restricting CPUs from NR_CPUS=256 to nr_cpu_ids=2.
[ 0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=64, nr_cpu_ids=2
[ 0.000000] NR_IRQS:16640 nr_irqs:440 16
[ 0.000000] Console: colour VGA+ 80x25
[ 0.000000] console [tty1] enabled
[ 0.000000] console [ttyS0] enabled
[ 0.000000] tsc: Unable to calibrate against PIT
[ 0.000000] tsc: using PMTIMER reference calibration
[ 0.000000] tsc: Detected 1695.804 MHz processor
[ 0.024036] Calibrating delay loop (skipped), value calculated using timer frequency.. 3391.60 BogoMIPS (lpj=6783216)
[ 0.026970] pid_max: default: 32768 minimum: 301
[ 0.028025] ACPI: Core revision 20150930
[ 0.030665] ACPI: 2 ACPI AML tables successfully acquired and loaded
[ 0.033483] Security Framework initialized
[ 0.034725] Yama: becoming mindful.
[ 0.036038] AppArmor: AppArmor initialized
[ 0.038125] Dentry cache hash table entries: 262144 (order: 9, 2097152 bytes)
[ 0.040523] Inode-cache hash table entries: 131072 (order: 8, 1048576 bytes)
[ 0.042746] Mount-cache hash table entries: 4096 (order: 3, 32768 bytes)
[ 0.044024] Mountpoint-cache hash table entries: 4096 (order: 3, 32768 bytes)
share/ubuntu-xenial-16.04-cloudimg-console.log view on Meta::CPAN
[ 2.086838] TCP established hash table entries: 16384 (order: 5, 131072 bytes)
[ 2.095764] TCP bind hash table entries: 16384 (order: 6, 262144 bytes)
[ 2.097767] TCP: Hash tables configured (established 16384 bind 16384)
[ 2.105036] UDP hash table entries: 1024 (order: 3, 32768 bytes)
[ 2.106817] UDP-Lite hash table entries: 1024 (order: 3, 32768 bytes)
[ 2.111005] NET: Registered protocol family 1
[ 2.115238] pci 0000:00:00.0: Limiting direct PCI/PCI transfers
[ 2.116909] pci 0000:00:01.0: Activating ISA DMA hang workarounds
[ 2.118718] Trying to unpack rootfs image as initramfs...
[ 4.443939] Freeing initrd memory: 8496K (ffff880036f58000 - ffff8800377a4000)
[ 4.648344] RAPL PMU detected, API unit is 2^-32 Joules, 4 fixed counters 10737418240 ms ovfl timer
[ 4.909457] hw unit of domain pp0-core 2^-0 Joules
[ 5.039674] hw unit of domain package 2^-0 Joules
[ 5.089239] hw unit of domain dram 2^-0 Joules
[ 5.090535] hw unit of domain pp1-gpu 2^-0 Joules
[ 5.092192] platform rtc_cmos: registered platform RTC device (no PNP device found)
[ 5.094499] Scanning for low memory corruption every 60 seconds
[ 5.096665] futex hash table entries: 512 (order: 3, 32768 bytes)
[ 5.098304] audit: initializing netlink subsys (disabled)
[ 5.100920] audit: type=2000 audit(1481509661.100:1): initialized
[ 5.103199] Initialise system trusted keyring