diff options
author | Jesse Luehrs <doy@tozt.net> | 2009-10-31 02:50:52 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2009-10-31 02:50:52 -0500 |
commit | 0260da349d165ae8b90c23a00359879b25c62334 (patch) | |
tree | 65b3a8e44e5d35e42627d5317b431adfba102095 /lib | |
parent | c124d12dd54c2ec6525a1b90e5c584988894e83b (diff) | |
download | im-engine-plugin-commands-0260da349d165ae8b90c23a00359879b25c62334.tar.gz im-engine-plugin-commands-0260da349d165ae8b90c23a00359879b25c62334.zip |
move !help out into its own default plugin
Diffstat (limited to 'lib')
-rw-r--r-- | lib/IM/Engine/Plugin/Commands.pm | 15 | ||||
-rw-r--r-- | lib/IM/Engine/Plugin/Commands/Command/Help.pm | 16 |
2 files changed, 23 insertions, 8 deletions
diff --git a/lib/IM/Engine/Plugin/Commands.pm b/lib/IM/Engine/Plugin/Commands.pm index 4bd556c..e5ecec8 100644 --- a/lib/IM/Engine/Plugin/Commands.pm +++ b/lib/IM/Engine/Plugin/Commands.pm @@ -96,12 +96,6 @@ sub incoming { return unless $text =~ /^\Q$prefix\E(\w+)(?:\s+(.*))?/; my ($command_name, $action) = (lc($1), $2); - if ($command_name eq 'help') { - $command_name = $action; - $command_name =~ s/^-//; - $action = '-help'; - } - $command_name = $self->_find_command($command_name); return unless $command_name; @@ -145,7 +139,8 @@ sub incoming { } } else { - $self->say($command->default($sender, $action)); + my $output = $command->default($sender, $action); + $self->say($output) if defined $output; } if (!$command->is_active) { @@ -165,7 +160,11 @@ sub say { around commands => sub { my $orig = shift; my $self = shift; - return ($self->$orig(@_), 'IM::Engine::Plugin::Commands::Command::Cmdlist'); + return ( + $self->$orig(@_), + 'IM::Engine::Plugin::Commands::Command::Cmdlist', + 'IM::Engine::Plugin::Commands::Command::Help', + ); }; sub command_list { diff --git a/lib/IM/Engine/Plugin/Commands/Command/Help.pm b/lib/IM/Engine/Plugin/Commands/Command/Help.pm new file mode 100644 index 0000000..b28472a --- /dev/null +++ b/lib/IM/Engine/Plugin/Commands/Command/Help.pm @@ -0,0 +1,16 @@ +package IM::Engine::Plugin::Commands::Command::Help; +use IM::Engine::Plugin::Commands::OO; + +sub default { + my $self = shift; + my ($sender, $action) = @_; + $self->is_active(0); + my $prefix = $self->_ime_plugin->prefix; + my $message = IM::Engine::Incoming->new( + sender => $self->_ime_plugin->_last_message->sender, + message => "${prefix}$action -help", + ); + return $self->_ime_plugin->incoming($message); +} + +1; |