throws CoreException
{
if (command.equals("help"))
{
Map modules = bot.getNamedModules();
Module module = null;
// display module-specific help
if (arguments != null &&
arguments.trim().length() > 0)
{
Matcher logsearch_matcher = HELP_PATTERN.matcher(arguments.toLowerCase());
// check if the syntax is correct
if (!logsearch_matcher.matches() ||
(logsearch_matcher.groupCount() < 1 &&
logsearch_matcher.groupCount() > 2))
{
bot.send(new Privmsg(nick, "Invalid syntax '"+command+" "+arguments+"'."));
return;
}
// get the different help arguments
String module_name = null;
String help_key = null;
module_name = logsearch_matcher.group(1);
if (logsearch_matcher.groupCount() > 1)
{
help_key = logsearch_matcher.group(2);
if (0 == help_key.length())
{
help_key = null;
}
}
// check if the module is known
module = (Module)modules.get(module_name);
if (null == module)
{
bot.send(new Privmsg(nick, "Unknown module '"+module_name+"'."));
return;
}
// obtain the requested help text
Map helpmap = module.getHelpMap();
if (null == helpmap ||
!helpmap.containsKey(help_key))
{
bot.send(new Privmsg(nick, "Couldn't find the requested help information in module '"+module_name+"'."));
return;
}
// output the help text
String help = (String)helpmap.get(help_key);
help = StringUtils.replace(help, VAR_MODULENAME, module.getName());
outputHelp(bot, nick, help);
}
// display help about all the installed modules
else
{
if (modules.size() > 0)
{
StringBuffer module_help = new StringBuffer(MODULES_HELP);
String description = null;
Iterator modules_it = modules.values().iterator();
while (modules_it.hasNext())
{
module = (Module)modules_it.next();
module_help.append(AttributeCode.BOLD+module.getName()+AttributeCode.BOLD+AttributeCode.ENDLINE);
description = module.getDescription();
if (description != null)
{
module_help.append(module.getDescription()+AttributeCode.ENDLINE);
}
}
// output the help text
outputHelp(bot, nick, module_help.toString());