diff options
author | Julien Dessaux | 2014-12-04 13:14:42 +0100 |
---|---|---|
committer | Julien Dessaux | 2014-12-04 19:53:27 +0100 |
commit | c6ae00f1299e5b13f221f07f7be8c6bf3445d8e1 (patch) | |
tree | 3f4378502e5443ee30435935bc3f8b4033468789 | |
parent | Protocol update (diff) | |
download | avalon-arthur-c6ae00f1299e5b13f221f07f7be8c6bf3445d8e1.tar.gz avalon-arthur-c6ae00f1299e5b13f221f07f7be8c6bf3445d8e1.tar.bz2 avalon-arthur-c6ae00f1299e5b13f221f07f7be8c6bf3445d8e1.zip |
Implemented timeout handling
-rw-r--r-- | Avalon.pm | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -7,9 +7,28 @@ use strict; use warnings; use v5.12; use experimental qw(switch); +use POE; +use Time::HiRes qw(time); use base qw(Bot::BasicBot::Pluggable::Module); +### Game logic ############################################################### +sub set_timeout { + my ( $self, $value) = @_; + $poe_kernel->alarm( avalon_timeout => time() + $value ); +} + +sub timeout_occurred { + my $self = shift; + $self->say( channel => $self->{avalon}->{config}->{'game.channel'}, body => "timeout" ); +} + +### IRC methods override ###################################################### +sub connected { + my $self = shift; + $poe_kernel->state( 'avalon_timeout', $self, 'timeout_occurred' ); +} + sub init { my $self = shift; $self->{avalon} = {}; |