summaryrefslogtreecommitdiffstats
path: root/lib/Bot/Games.pm
diff options
context:
space:
mode:
authordoy <doy@tozt.net>2008-12-18 06:10:30 -0500
committerdoy <doy@tozt.net>2008-12-18 06:10:30 -0500
commitea0cea0e7ff06bf73dd06d03433fb13448058808 (patch)
tree50d0508018a98bcda650c536242fa70085265e9f /lib/Bot/Games.pm
parent774f76fb000411d1bdbd4c9d9cd0c108120c864f (diff)
downloadbot-games-ea0cea0e7ff06bf73dd06d03433fb13448058808.tar.gz
bot-games-ea0cea0e7ff06bf73dd06d03433fb13448058808.zip
allow not passing an action, to just restart a game
Diffstat (limited to 'lib/Bot/Games.pm')
-rw-r--r--lib/Bot/Games.pm6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Bot/Games.pm b/lib/Bot/Games.pm
index 3cc6626..2b7e9f8 100644
--- a/lib/Bot/Games.pm
+++ b/lib/Bot/Games.pm
@@ -38,12 +38,12 @@ sub said {
my $prefix = $self->prefix;
return if $args->{channel} eq 'msg';
- return unless $args->{body} =~ /^$prefix(\w+)\s+(.*)/;
+ return unless $args->{body} =~ /^$prefix(\w+)(?:\s+(.*))?/;
my ($game_name, $action) = ($1, $2);
return unless $self->valid_game($game_name);
my $game = $self->active_games->{$game_name};
- if (!defined $game) {
+ if (!defined $game || !defined $action) {
$game = $self->game_package($game_name)->new;
$self->active_games->{$game_name} = $game;
my $output = $game->_init($args->{who});
@@ -51,6 +51,8 @@ sub said {
if defined $output;
}
+ return unless defined $action;
+
my $output;
if ($action =~ /-(\w+)\s*(.*)/) {
my ($action, $arg) = ($1, $2);