package heufybot.modules;

import heufybot.utils.StringUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Help extends Module
{
	public Help()
	{
		this.authType = AuthType.Anyone;
		this.apiVersion = "0.5.0";
		this.triggerTypes = new TriggerType[] { TriggerType.Message };
		this.trigger = "^" + commandPrefix + "(help)($| .*)";
	}
	
	public void processEvent(String source, String message, String triggerUser, List<String> params)
	{
		if (params.size() == 1)
		{
			ArrayList<String> moduleNames = new ArrayList<String>();
			for(Module module : bot.getModuleInterface().getModuleList())
			{
				moduleNames.add(module.toString());
			}

			Collections.sort(moduleNames);
			String response = "Modules loaded: " + StringUtils.join(moduleNames, ", ");
			bot.getIRC().cmdPRIVMSG(source, response);
		}
		else
		{
			params.remove(0);
			String helpParams = StringUtils.join(params, " ");
			String help = bot.getModuleInterface().getModuleHelp(helpParams);
			if(help != null)
			{
				bot.getIRC().cmdPRIVMSG(source, help);
			}
			else
			{
				bot.getIRC().cmdPRIVMSG(source, "Module or command matching \"" + helpParams + "\" is not loaded or does not exist!");
			}
		}
	}

	@Override
	public String getHelp(String message)
	{
		return "Commands: " + commandPrefix + "help (<module>) | Shows all modules that are currently loaded or shows help for a given module. Command syntax will be as such: command <parameter>. Parameters in brackets are optional.";
	}

	@Override
	public void onLoad() 
	{
	}

	@Override
	public void onUnload()
	{
	}
}

@@ -250,15 +250,10 @@
 n = 
-%220.5.0%22
+60
 ;%0A%09%09
@@ -409,16 +409,31 @@
 (String 
+server, String 
 source, 
@@ -605,24 +605,42 @@
 odule : bot.
+getServer(server).
 getModuleInt
@@ -831,36 +831,45 @@
 , %22);%0A%09%09%09bot.get
-IRC(
+Server(server
 ).cmdPRIVMSG(sou
@@ -995,16 +995,34 @@
 p = bot.
+getServer(server).
 getModul
@@ -1089,36 +1089,45 @@
 %09%09%09%7B%0A%09%09%09%09bot.get
-IRC(
+Server(server
 ).cmdPRIVMSG(sou
@@ -1171,12 +1171,21 @@
 .get
-IRC(
+Server(server
 ).cm

Update Help to the new module API