dirkobot/lib/POE/Component/BukkitRestart.pm
2011-08-21 12:44:50 -04:00

24 lines
844 B
Perl

package POE::Component::BukkitRestart;
use strict;
use warnings;
sub spawn {
POE::Session->new(
inline_states => {
_start => sub {
$_[HEAP]->{todo} = [ qw( step1 step2 step2a ) ],
$_[KERNEL]->delay( restartwarning => 45*60 );
},
restartwarning => sub {
my @messages = ("Incoming game prepare for ReBoot!", "What's this bright light aimed at us? It's a ReBoot!", "I'll get you next ReBoot, Gadget! Next TIME!");
$_[KERNEL]->post( 'bukkitdtach', 'queue_command', 'say '.$messages[rand(0+@messages)] );
$_[KERNEL]->delay( restart => 30 );
}
restart => sub {
$_[KERNEL]->post( 'bukkitdtach', 'queue_command', 'save-all' );
$_[KERNEL]->post( 'bukkitdtach', 'queue_command', 'stop' );
$_[KERNEL]->delay( restartwarning => 45*60 );
}
);
}