summaryrefslogtreecommitdiffstats
path: root/lib/Bot/Games.pm
diff options
context:
space:
mode:
authordoy <doy@tozt.net>2008-12-18 02:12:45 -0500
committerdoy <doy@tozt.net>2008-12-18 02:12:45 -0500
commit58d22a02baec219b389a94782b459b910c523a74 (patch)
treecc3dae8251aaa21e0e4128b9e73f210446288a4b /lib/Bot/Games.pm
parent76698a2014338a2675cb78359061f5b6884ab04c (diff)
downloadbot-games-58d22a02baec219b389a94782b459b910c523a74.tar.gz
bot-games-58d22a02baec219b389a94782b459b910c523a74.zip
expand functionality of game actions - force attribute access to be read-only, and disallow access to _private members, and pass along extra args
Diffstat (limited to 'lib/Bot/Games.pm')
-rw-r--r--lib/Bot/Games.pm11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Bot/Games.pm b/lib/Bot/Games.pm
index 25ad254..a084d78 100644
--- a/lib/Bot/Games.pm
+++ b/lib/Bot/Games.pm
@@ -34,9 +34,14 @@ sub said {
= $self->game_package($game_name)->new
unless defined $game;
- if ($action =~ /-(.*)/) {
- my $action = $1;
- return $game->$action($args{who}) if $game->can($action);
+ if ($action =~ /-(\w+)\s*(.*)/) {
+ my ($action, $arg) = ($1, $2);
+ return "$action is private in $game_name"
+ if $action =~ s/^_//;
+ return $game->$action
+ if $game->meta->has_attribute($action);
+ return $game->$action($args{who}, $arg)
+ if $game->can($action);
return "Unknown command $action for game $game_name.";
}