summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Dessaux2014-12-04 13:14:42 +0100
committerJulien Dessaux2014-12-04 19:53:27 +0100
commitc6ae00f1299e5b13f221f07f7be8c6bf3445d8e1 (patch)
tree3f4378502e5443ee30435935bc3f8b4033468789
parentProtocol update (diff)
downloadavalon-arthur-c6ae00f1299e5b13f221f07f7be8c6bf3445d8e1.tar.gz
avalon-arthur-c6ae00f1299e5b13f221f07f7be8c6bf3445d8e1.tar.bz2
avalon-arthur-c6ae00f1299e5b13f221f07f7be8c6bf3445d8e1.zip
Implemented timeout handling
Diffstat (limited to '')
-rw-r--r--Avalon.pm19
1 files changed, 19 insertions, 0 deletions
diff --git a/Avalon.pm b/Avalon.pm
index 8fd76d8..cd6d874 100644
--- a/Avalon.pm
+++ b/Avalon.pm
@@ -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} = {};