Added setCommandsList method.

This commit is contained in:
Erik C. Thauvin 2020-03-28 15:00:56 -07:00
parent 9b2dc8587f
commit abbb322b5d
2 changed files with 20 additions and 11 deletions

View file

@ -650,16 +650,10 @@ public class Mobibot extends PircBot {
Collections.sort(opsCommandsNames); Collections.sort(opsCommandsNames);
} }
// Print 6 commands per line sendCommandsList(sender, commandsNames, false);
final int chunk = 6;
for (int i = 0; i < commandsNames.size(); i += chunk) {
send(sender, Utils.helpIndent(
String.join(" ", commandsNames.subList(i, Math.min(commandsNames.size(), i + chunk)))));
}
if (isOp) { if (isOp) {
send(sender, Utils.bold("The op commands are:")); send(sender, Utils.bold("The op commands are:"), false);
send(sender, Utils.helpIndent(String.join(" ", opsCommandsNames))); sendCommandsList(sender, opsCommandsNames, false);
} }
} }
@ -1015,6 +1009,20 @@ public class Mobibot extends PircBot {
send(who, Utils.colorize(message, color), false); send(who, Utils.colorize(message, color), false);
} }
/**
* Send a formatted commands/modules, etc. list.
*
* @param nick The nick to send the list to.
* @param list The list to format.
*/
public final void sendCommandsList(final String nick, final List<String> list, final boolean isPrivate) {
final int chunk = 8; // 8 commands per line.
for (int i = 0; i < list.size(); i += chunk) {
send(nick, Utils.helpIndent(
String.join(" ", list.subList(i, Math.min(list.size(), i + chunk)))), isPrivate);
}
}
/** /**
* Sets the backlogs URL. * Sets the backlogs URL.
* *
@ -1152,6 +1160,7 @@ public class Mobibot extends PircBot {
twitterEntries.remove(index); twitterEntries.remove(index);
} }
/** /**
* Post all the links on twitter on shutdown. * Post all the links on twitter on shutdown.
*/ */

View file

@ -58,8 +58,8 @@ class Modules : AbstractCommand() {
if (modulesNames.isEmpty()) { if (modulesNames.isEmpty()) {
bot.send(sender, "There are no enabled modules.", true) bot.send(sender, "There are no enabled modules.", true)
} else { } else {
bot.send(sender, Utils.bold("The enabled modules are: ")) bot.send(sender, Utils.bold("The enabled modules are: "), false)
bot.send(sender, Utils.helpIndent(modulesNames.joinToString(", "))) bot.sendCommandsList(sender, modulesNames, false )
} }
} else { } else {
bot.helpDefault(sender, isOp) bot.helpDefault(sender, isOp)