X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Commands%2FBasic.pm;fp=Commands%2FBasic.pm;h=f0404876f1bba0e4a08093a054b3bf320ba719a0;hb=4f1948e0fe10075464732db5cc2168207c00c7aa;hp=0000000000000000000000000000000000000000;hpb=02cffbdd44754378b27e1b87a1998368c1098973;p=NDIRC.git diff --git a/Commands/Basic.pm b/Commands/Basic.pm new file mode 100644 index 0000000..f040487 --- /dev/null +++ b/Commands/Basic.pm @@ -0,0 +1,63 @@ +#************************************************************************** +# Copyright (C) 2008 by Michael Andreen * +# * +# This program is free software; you can redistribute it and/or modify * +# it under the terms of the GNU General Public License as published by * +# the Free Software Foundation; either version 2 of the License, or * +# (at your option) any later version. * +# * +# This program is distributed in the hope that it will be useful, * +# but WITHOUT ANY WARRANTY; without even the implied warranty of * +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# GNU General Public License for more details. * +# * +# You should have received a copy of the GNU General Public License * +# along with this program; if not, write to the * +# Free Software Foundation, Inc., * +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * +#**************************************************************************/ + +package NDIRC::Commands::Basic; + +use strict; +use warnings; + +use Moose; +use MooseX::MethodAttributes; + +sub commands + : Help(commands | Gives help about all available commands or lists all commands available in the current channel) +{ + my ($self, $c, $command) = @_; + + unless($command){ + my @commands; + for (sort keys %{$c->disp->commands}){ + next unless $c->disp->has_command($_,$c->channel); + my $acl = $c->disp->commands->{$_}->acl; + next if $acl && !$c->check_user_roles(@$acl); + + push @commands,$_; + } + $c->reply(join ', ', @commands); + }elsif (exists $c->disp->commands->{$command}){ + for (@{$c->disp->commands->{$command}->help}){ + $c->reply($_); + } + } + +} + +sub help + : Help(Prints basic help) + : Type(help) +{ + my ($self, $c, $command) = @_; + + $c->reply("Use .commands to show help about a specific command. " + . "Use .commands to list the diffenrent commands you have access to in this channel. " + . "Instead of . you can use ! to get reply in pm or ~ to get reply in channel."); +} + +1; +