diff options
author | doy <doy@tozt.net> | 2009-01-25 16:23:10 -0500 |
---|---|---|
committer | doy <doy@tozt.net> | 2009-01-25 16:23:10 -0500 |
commit | 8986e827e89606c8c51fbae6b7eed5340839190b (patch) | |
tree | 32006912725bdfde87c20f236ee3f8779e7a677f | |
parent | 7f8a679ab1be5fcc130b996c44fcc64531046521 (diff) | |
download | bot-games-8986e827e89606c8c51fbae6b7eed5340839190b.tar.gz bot-games-8986e827e89606c8c51fbae6b7eed5340839190b.zip |
allow $say to be called as a method (while still using B::BB's $self) to allow installing it in plugins and using it from there as $self->say
-rw-r--r-- | lib/Bot/Games.pm | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/Bot/Games.pm b/lib/Bot/Games.pm index b5a215e..a2a2ed5 100644 --- a/lib/Bot/Games.pm +++ b/lib/Bot/Games.pm @@ -40,7 +40,7 @@ sub said { my $self = shift; my ($args) = @_; my $prefix = $self->prefix; - my $say = sub { $self->say(%$args, body => $self->_format(@_)) }; + my $say = sub { shift; $self->say(%$args, body => $self->_format(@_)) }; return if $args->{channel} eq 'msg'; return unless $args->{body} =~ /^$prefix(\w+)(?:\s+(.*))?/; @@ -58,7 +58,7 @@ sub said { } if (!$self->done_init->{$game_name} && (!defined($action) || $action !~ /^-/)) { - $say->($game->init($args->{who})) if $game->can('init'); + $self->$say($game->init($args->{who})) if $game->can('init'); $self->done_init->{$game_name} = 1; } @@ -69,11 +69,11 @@ sub said { # XXX: maybe the meta stuff should get pushed out into the plugins # themselves, and this should become $game->meta->get_command or so? if (my $method_meta = _get_command($game, $action)) { - $say->($method_meta->execute($game, $arg, + $self->$say($method_meta->execute($game, $arg, {player => $args->{who}})); } else { - $say->("Unknown command $action for game $game_name"); + $self->$say("Unknown command $action for game $game_name"); } } else { @@ -81,11 +81,11 @@ sub said { # handle that properly either, so # also, this should probably be factored into $say, i think? my $turn = $game->turn($args->{who}, $action); - $say->($turn) if $turn; + $self->$say($turn) if $turn; } if (my $end_msg = $game->is_over) { - $say->($end_msg); + $self->$say($end_msg); delete $self->active_games->{$game_name}; } return; |