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);
}
// Print 6 commands per line
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)))));
}
sendCommandsList(sender, commandsNames, false);
if (isOp) {
send(sender, Utils.bold("The op commands are:"));
send(sender, Utils.helpIndent(String.join(" ", opsCommandsNames)));
send(sender, Utils.bold("The op commands are:"), false);
sendCommandsList(sender, opsCommandsNames, false);
}
}
@ -1015,6 +1009,20 @@ public class Mobibot extends PircBot {
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.
*
@ -1152,6 +1160,7 @@ public class Mobibot extends PircBot {
twitterEntries.remove(index);
}
/**
* Post all the links on twitter on shutdown.
*/

View file

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