App-RoboBot
view release on metacpan or search on metacpan
doc/lang/scopes/index.rst view on Meta::CPAN
Statement Scope
===============
.. _lang-scope-lexical:
Lexical Scope
=============
|RB| provides a :ref:`function-core-let` form which permits users to
temporarily define and bind a value to a reusable name, but only for the
expressions provided to the body of the ``(let)``. Names created in this manner
are said to exist in a :index:`lexical scope` because they exist only until the
end of the enclosing form and then are destroyed, becoming unavailable for use
outside that scope.
lib/App/RoboBot/Plugin/Bot/Alarm.pm view on Meta::CPAN
return unless $res && $res->next;
$res->{'exclusions'} = decode_json($res->{'exclusions'});
if ($res->{'do_recalc'} && $res->{'recurrence'}) {
# Alarm's recorded next occurrence has expired, so we need to recalc
# and updated the database before we send the alarm back to the caller.
# Pad the clause so a lack of exclusions doesn't generate bad SQL.
my @where = qw( false );
my @binds;
foreach my $excl (@{$res->{'exclusions'}}) {
push(@where, 'to_char(s.new_emit, ?) ~* ?');
push(@binds, $excl->{'format'}, $excl->{'pattern'});
}
# TODO: Alarms which have been suspended for a long time (where "long"
# is defined by the scale of their recurrence rate), will not get
# a new_emit properly from this query. I.e. a daily alarm that
# has been suspended for more than 100 days will get an empty
# resultset. Fix this in a way that is better than simply using
# larger and larger multiples on the interval for the stop in
# generate_series().
my $new_emit = $self->bot->config->db->do(q{
select date_trunc('seconds', s.new_emit) as new_emit
from alarms_alarms a,
generate_series(a.next_emit, a.next_emit + (a.recurrence * 100), a.recurrence) s(new_emit)
where a.id = ? and a.recurrence is not null and not (} . join(' or ', @where) . q{)
and s.new_emit > (now() + (a.recurrence / 2))
order by s.new_emit asc
limit 1
}, $res->{'id'}, @binds);
if ($new_emit && $new_emit->next) {
# We have a properly calculated next_emit, so update the alarm in
# the database with a returning * clause so we can get the alarm
# back to our caller.
$res = $self->bot->config->db->do(q{
update alarms_alarms set next_emit = ? where id = ? returning *
}, $new_emit->{'new_emit'}, $res->{'id'});
unless ($res && $res->next) {
lib/App/RoboBot/Plugin/Social/Achievements.pm view on Meta::CPAN
SQL query which is used to determine a person's eligibility. The query must
return a true value in the first column of the first row to indicate that the
user may earn the achievement. Anything else will consider the user ineligible
at that time.
Achievements are currently earned only a single time. There is no support for
recurring achievements (tiers/levels which increment).
Because the SQL query is executed every time a message is processed from a user
who has not yet earned the achievement, they must be written for speed. The SQL
query will receive a single bind variable: the ``nick_id`` of the user whose
message was just processed.
=head3 Usage
<name> <description> <query>
=head3 Examples
(add-achievement
Chatterbox
share/ubuntu-xenial-16.04-cloudimg-console.log view on Meta::CPAN
[ 1.092867] NetLabel: unlabeled traffic allowed by default
[ 1.240105] amd_nb: Cannot enumerate AMD northbridges
[ 1.376099] clocksource: Switched to clocksource refined-jiffies
[ 1.556031] AppArmor: AppArmor Filesystem Enabled
[ 1.680134] pnp: PnP ACPI init
[ 1.769052] pnp: PnP ACPI: found 4 devices
[ 1.901058] clocksource: acpi_pm: mask: 0xffffff max_cycles: 0xffffff, max_idle_ns: 2085701024 ns
[ 2.076145] clocksource: Switched to clocksource acpi_pm
[ 2.078755] NET: Registered protocol family 2
[ 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
( run in 1.605 second using v1.01-cache-2.11-cpan-2398b32b56e )