#**************************************************************************
#   Copyright (C) 2008 by Michael Andreen <harvATruinDOTnu>               *
#                                                                         *
#   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 <command> | 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 <command> 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;

