Bot-Backbone
view release on metacpan or search on metacpan
lib/Bot/Backbone/Bot.pm view on Meta::CPAN
=head2 shutdown
$bot->shutdown;
You may call this at any time while your bot is running to shutdown all the services. This notifies each service that it should shutdown (i.e., finish or terminate any pending jobs in the event loop). It then clears the L</services> hash, which shoul...
=head1 CAVEATS
This thing sort of kind of needs L<POE> to be any kind of useful. However, L<POE> seems to have weird drawbacks. I have some planned work-arounds for this being an explicit and required dependency, but it's there for now.
Second, if you use the Jabber chat service, you need L<AnyEvent>. Mostly, L<AnyEvent> and L<POE> seem to get along, but it's slow and I've found that timers, in particular, just plain don't work quite right.
=head1 AUTHOR
Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Qubling Software LLC.
This is free software; you can redistribute it and/or modify it under
lib/Bot/Backbone/Service/Role/BareMetalChat.pm view on Meta::CPAN
traits => [ 'Array' ],
handles => {
'_enqueue_message' => 'push',
#'_empty_message_queue' => [ map => sub { undef $_ } ],
'_empty_message_queue' => 'clear',
},
);
after shutdown => sub {
my $self = shift;
for my $timer (@{ $self->_message_queue }) {
undef $timer;
}
$self->_message_queue([]);
#$self->_empty_message_queue;
};
1;
__END__
=pod
lib/Bot/Backbone/Service/Role/SendPolicy.pm view on Meta::CPAN
_apply_send_policy($self->send_policy, $send_policy_result, $params)
if $self->has_send_policy;
return unless $send_policy_result->{allow};
# If this is a bare metal chat... then apply any required delay
if (($send_policy_result->{after} // 0) > 0
and $self->does('Bot::Backbone::Service::Role::BareMetalChat')) {
# Setting Timer
my $w = AnyEvent->timer(
after => $send_policy_result->{after},
cb => sub { $self->$next($params) },
);
$self->_enqueue_message($w);
return;
}
# Allowed and no delays... so GO!
t/send_policy.t view on Meta::CPAN
$bot->construct_services;
# For reference during testing below
my $chat1 = $bot->get_service('chat1');
my $chat2 = $bot->get_service('chat2');
my $chat3 = $bot->get_service('chat3');
# TODO Figure out what incantation is required to get this version of the
# test run to work.
#my $w;
#$w = AnyEvent->timer(
# interval => 0.01,
# cb => sub {
# state $counter = 0;
#
# $counter++;
#
# if ($counter < 300) {
# warn "SENDING $counter\n";
# $bot->get_service('chat1')->send_message(text => $counter);
# $bot->get_service('chat2')->send_message(text => $counter);
( run in 0.882 second using v1.01-cache-2.11-cpan-49f99fa48dc )